@@ -19,6 +19,8 @@ OpenAPI specifications define REST APIs in a standard format. These commands hel
1919 - [ ` optimize ` ] ( #optimize )
2020 - [ ` bootstrap ` ] ( #bootstrap )
2121 - [ ` localize ` ] ( #localize )
22+ - [ ` explore ` ] ( #explore )
23+ - [ ` snip ` ] ( #snip )
2224- [ Common Options] ( #common-options )
2325- [ Output Formats] ( #output-formats )
2426- [ Examples] ( #examples )
@@ -730,6 +732,186 @@ Address:
730732- You want to simplify file management for complex multi-file specifications
731733- You're creating documentation packages that include all referenced files
732734
735+ # ## `explore`
736+
737+ Interactively explore an OpenAPI specification in a terminal user interface.
738+
739+ ` ` ` bash
740+ # Launch the explorer
741+ openapi spec explore ./spec.yaml
742+
743+ # Get help on keyboard shortcuts
744+ # (Press '?' in the explorer)
745+ ` ` `
746+
747+ What the explorer provides :
748+
749+ - **Interactive navigation** - Browse all API operations with vim-style keyboard shortcuts
750+ - **Operation details** - View parameters, request bodies, responses, and more
751+ - **Color-coded methods** - Visual differentiation by HTTP method (GET=green, POST=blue, etc.)
752+ - **Fold/unfold details** - Toggle detailed information with Space or Enter
753+ - **Search through operations** - Quickly find endpoints in large specifications
754+ - **Help modal** - Built-in keyboard shortcut reference
755+
756+ **Keyboard Navigation:**
757+
758+ | Key | Action |
759+ | ----------------- | -------------------------- |
760+ | `↑` / `k` | Move up |
761+ | `↓` / `j` | Move down |
762+ | `gg` | Jump to top |
763+ | `G` | Jump to bottom |
764+ | `Ctrl-U` | Scroll up by half screen |
765+ | `Ctrl-D` | Scroll down by half screen |
766+ | `Enter` / `Space` | Toggle operation details |
767+ | `?` | Show/hide help |
768+ | `q` / `Esc` | Quit |
769+
770+ **What you can view:**
771+
772+ - Operation ID, summary, and description
773+ - HTTP method and path
774+ - Parameters (name, location, required status, description)
775+ - Request body content types
776+ - Response status codes and descriptions
777+ - Tags and deprecation warnings
778+
779+ **Benefits:**
780+
781+ - **Faster understanding** - Quickly grasp API structure without parsing YAML/JSON
782+ - **Better navigation** - Jump between operations more efficiently than text editors
783+ - **Visual clarity** - Color-coding and formatting make operations easier to distinguish
784+ - **No tool installation** - Works in any terminal, no browser required
785+ - **Offline friendly** - Explore specifications without network access
786+
787+ **Use Explore when:**
788+
789+ - You need to understand a new or unfamiliar API specification
790+ - You want to quickly review endpoints and their parameters
791+ - You're debugging API structure or looking for specific operations
792+ - You prefer terminal-based workflows over web-based viewers
793+ - You need to present or demo API operations in a meeting
794+
795+ # ## `snip`
796+
797+ Remove selected operations from an OpenAPI specification and automatically clean up unused components.
798+
799+ ` ` ` bash
800+ # Interactive mode - browse and select operations via TUI
801+ openapi spec snip ./spec.yaml
802+ openapi spec snip ./spec.yaml ./filtered-spec.yaml
803+
804+ # CLI mode - remove by operation ID
805+ openapi spec snip --operationId deleteUser --operationId adminDebug ./spec.yaml
806+
807+ # CLI mode - remove by operation ID (comma-separated)
808+ openapi spec snip --operationId deleteUser,adminDebug ./spec.yaml
809+
810+ # CLI mode - remove by path:method
811+ openapi spec snip --operation /users/{id}:DELETE --operation /admin:GET ./spec.yaml
812+
813+ # CLI mode - remove by path:method (comma-separated)
814+ openapi spec snip --operation /users/{id}:DELETE,/admin:GET ./spec.yaml
815+
816+ # CLI mode - mixed approaches
817+ openapi spec snip --operationId deleteUser --operation /admin:GET ./spec.yaml
818+
819+ # Write in-place (CLI mode only)
820+ openapi spec snip -w --operation /internal/debug:GET ./spec.yaml
821+ ` ` `
822+
823+ **Two Operation Modes:**
824+
825+ **Interactive Mode** (no operation flags):
826+ - Launch a terminal UI to browse all operations
827+ - Select operations with Space key
828+ - Press 'a' to select all, 'A' to deselect all
829+ - Press 'w' to write the result (prompts for file path)
830+ - Press 'q' or Esc to cancel
831+
832+ **Command-Line Mode** (operation flags specified):
833+ - Remove operations specified via flags without UI
834+ - Supports `--operationId` for operation IDs
835+ - Supports `--operation` for path:method pairs
836+ - Both flags support comma-separated values or multiple flags
837+
838+ **What snip does:**
839+
840+ 1. Removes the specified operations from the document
841+ 2. Removes path items that become empty after operation removal
842+ 3. Automatically runs Clean() to remove unused components
843+ 4. Preserves all other operations and valid references
844+
845+ **Before snipping:**
846+
847+ ` ` ` yaml
848+ paths:
849+ /users:
850+ get:
851+ operationId: getUsers
852+ responses:
853+ '200':
854+ $ref: '#/components/responses/UserResponse'
855+ delete:
856+ operationId: deleteAllUsers
857+ responses:
858+ '204':
859+ description: No content
860+ /admin/debug:
861+ get:
862+ operationId: debugInfo
863+ responses:
864+ '200':
865+ description: Debug info
866+ components:
867+ schemas:
868+ User:
869+ type: object
870+ UnusedSchema:
871+ type: object
872+ responses:
873+ UserResponse:
874+ description: User response
875+ ` ` `
876+
877+ **After snipping** (removed deleteAllUsers and debugInfo):
878+
879+ ` ` ` yaml
880+ paths:
881+ /users:
882+ get:
883+ operationId: getUsers
884+ responses:
885+ '200':
886+ $ref: '#/components/responses/UserResponse'
887+ components:
888+ schemas:
889+ User:
890+ type: object
891+ responses:
892+ UserResponse:
893+ description: User response
894+ # DELETE operation removed, /admin/debug path removed entirely
895+ # UnusedSchema cleaned up automatically
896+ ` ` `
897+
898+ **Benefits of snipping:**
899+
900+ - **Reduce API surface**: Remove deprecated or internal operations before publishing
901+ - **Create filtered specs**: Generate subsets of your API for specific clients or use cases
902+ - **Interactive selection**: Visual browser makes it easy to identify and select operations
903+ - **Automatic cleanup**: Unused components are removed automatically
904+ - **Flexible input**: Support both operation IDs and path:method pairs
905+ - **Batch processing**: Remove multiple operations in one command
906+
907+ **Use Snip when:**
908+
909+ - You need to remove deprecated operations from a specification
910+ - You want to create a filtered version of your API for specific clients
911+ - You're preparing a public API specification and need to remove internal endpoints
912+ - You want to reduce the size and complexity of a specification
913+ - You need to create different API variants from a single source
914+
733915# # Common Options
734916
735917All commands support these common options :
0 commit comments