-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add slice command to filter OpenAPI specs #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ation IDs, and paths - Add new 'extract' CLI command to slice OpenAPI specifications - Support filtering by operation IDs, tags, and path patterns - Implement SliceFilter with comprehensive test coverage - Use Cobra's StringSliceVar for cleaner flag handling - Include all referenced schemas and components in output - Add validation for input parameters and output formats - Support both YAML and JSON output formats
- Update command name from 'extract' to 'slice' for consistency - Update all examples and documentation to use 'slice' - All tests still pass
- Fix perfsprint linter error - Use errors.New instead of fmt.Errorf when no formatting is needed - Add errors import
- Replace fmt.Errorf with errors.New for non-formatted errors (perfsprint) - Fix receiver naming consistency in SliceFilter.matches method (revive) - Change receiver name from 'e' to 'f' to match other methods
- Add ParametersFilter to remove unused parameters from OpenAPI specs - Add comprehensive tests for ParametersFilter (7 test scenarios) - Move slice functionality from filter package to dedicated slice package - Update FiltersToCleanupRefs to include TagsFilter, ParametersFilter, and SchemasFilter - Fix linting issues (import shadowing and missing period in comment) - Slice command now cleans up unused tags, parameters, and schemas automatically
| Version: "1.0", | ||
| }, | ||
| Paths: openapi3.NewPaths(openapi3.WithPath("/test/{id}", &openapi3.PathItem{ | ||
| Parameters: openapi3.Parameters{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you help me to understand the equivalent of this Parameters field under PathItem in the OpenAPI spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, would it make more sense under Get operation?
| Parameters: nil, | ||
| }, | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, these tests are all cases covering parameters referencing to other schemas? Can we have other tests for response and request bodies referencing to the schemas?
Proposed changes
This PR adds a new
slicecommand to thefoasclithat enables users to slice/filter OpenAPI specifications by operation IDs, tags, or path patterns. This feature allows developers to create smaller, focused OpenAPI specs containing only the endpoints they needExample usage:
Jira ticket: CLOUDP-365849
Checklist
Changes to Spectral
Further comments