Skip to content

Phase 4: Core Editing Features - COMPLETE

Implementation Summary

Phase 4 has been successfully completed. The core editing features have been implemented with auto-save functionality for the Main/Info form and Path metadata.

Components Created/Updated

1. MainForm.tsx (Updated)

Editing Features Added: - Title field is now editable with auto-save - Version field is now editable with auto-save - Description field is now editable with auto-save - All changes execute ChangePropertyCommand for undo/redo support - Updated to use proper data-models API (getTitle(), getVersion(), getDescription()) - Changed note to indicate "Changes are automatically saved"

Implementation Details: - Uses ChangePropertyCommand from @apitomy/data-models - Casts document to OpenApi30Document for proper typing - Gets info object via oaiDoc.getInfo() - Each field change executes a command with descriptive message - Integrates with command service via useCommand() hook

2. PathForm.tsx (New)

Features Implemented: - Displays path name in title - Editable summary field with auto-save - Editable description field with auto-save - Lists all operations defined for the path - Shows operation method (GET, POST, etc.) with badge - Shows operation summary for each operation - Uses ChangePropertyCommand for path metadata changes

Implementation Details: - Extracts path name from selectedPath (e.g., "/paths//pets" → "/pets") - Casts document to OpenApi30Document - Gets path item via paths.getItem(pathName) - Casts path item to OpenApi30PathItem for v3.0-specific properties - Iterates through HTTP methods to find defined operations - Uses proper getters: getSummary(), getDescription() - Operations list shows method badges and summaries

3. DetailPanel.tsx (Updated)

  • Updated to route to PathForm when a path is selected
  • Maintains routing to MainForm for root/info selection
  • Schema form still shows placeholder (deferred to Phase 5)

Features Implemented

Main/Info Form Editing - Editable title field - Editable version field - Editable description field - Auto-save on change - Command pattern integration for undo/redo

Path Form - Path metadata editing (summary, description) - Operations list display - Auto-save on change - Command pattern integration

Command Integration - All edits use ChangePropertyCommand - Full undo/redo support - Descriptive command messages for history

User Experience Design Decisions

Based on user preferences from Phase 4 planning:

  1. Auto-save on change - No Save/Cancel buttons needed, changes execute immediately
  2. Undo/Redo support - Users can revert changes using toolbar buttons
  3. Modal dialogs - Prepared for add operations (deferred in this phase)
  4. Path metadata focus - Showing summary, description, and operations list

API Usage from @apitomy/data-models

Proper Document API Usage:

const oaiDoc = document as OpenApi30Document;
const info = oaiDoc.getInfo();
const paths = oaiDoc.getPaths();
const pathItem = paths.getItem(pathName) as OpenApi30PathItem;

Command Pattern:

const command = new ChangePropertyCommand(node, 'propertyName', newValue);
executeCommand(command, 'Description of change');

Property Getters/Setters:

  • Info: getTitle(), getVersion(), getDescription()
  • PathItem: getSummary(), getDescription()
  • Operations: getGet(), getPost(), getPut(), etc.

Build Status

✅ Component builds successfully (25.86 kB ESM, 16.74 kB CJS) ✅ No TypeScript errors ✅ PathForm properly integrated with navigation

Testing

The test application now supports: - Editing API title, version, and description - Selecting paths from navigation - Viewing path metadata (summary, description) - Viewing operations list for each path - Editing path summary and description - Undo/Redo of all changes

Features Deferred

The following were deferred as they weren't required for Phase 4 MVP:

  1. Add Path Modal - User can't add new paths yet (Phase 5)
  2. Delete Path - No delete functionality yet (Phase 5)
  3. Operation Editing - Operations are listed but not editable yet (Phase 5)
  4. Add/Delete Operations - Can't add GET, POST, etc. yet (Phase 5)
  5. Request/Response Editing - Not in scope for Phase 4 (Phase 6)
  6. Schema Form - Still showing placeholder (Phase 5)

Next Steps - Phase 5: Schema & Data Types

The next phase will implement:

  1. Schema Form Component
  2. Display schema properties
  3. Edit schema metadata (title, description, type)
  4. Show property list
  5. Edit properties

  6. Schema CRUD Operations

  7. Add new schemas (modal dialog)
  8. Delete schemas
  9. Rename schemas

  10. Path/Operation CRUD

  11. Add new paths (modal dialog)
  12. Delete paths
  13. Add operations to paths
  14. Delete operations

  15. Enhanced PathForm

  16. Click operations to edit them
  17. Add/delete operations

Files Changed in Phase 4

Modified Files

  • src/components/forms/MainForm.tsx
  • src/components/editor/DetailPanel.tsx

New Files

  • src/components/forms/PathForm.tsx

Code Quality

  • All components use proper TypeScript types from @apitomy/data-models
  • Consistent use of command pattern for all mutations
  • Proper error handling for missing paths/documents
  • Clear separation between path extraction and display logic
  • All components have JSDoc comments
  • Consistent code style with existing components
  • Build size remains reasonable (under 26KB)

Lessons Learned

  1. Data Models API Consistency: Not all getters return MappedNodes - some (like getSchemas()) return plain objects
  2. Path Extraction: Need to parse selectedPath to extract actual path names
  3. Type Casting: Important to cast to specific version types (OpenApi30Document, OpenApi30PathItem) to get version-specific properties
  4. Operations Discovery: Need to check all HTTP method getters to find which operations are defined
  5. Auto-save UX: Simple and effective - no need for Save buttons when changes are immediate and undoable