Restrict linting to resources annotated with x-aep-resource#69
Draft
rambleraptor wants to merge 2 commits intoaep-dev:mainfrom
Draft
Restrict linting to resources annotated with x-aep-resource#69rambleraptor wants to merge 2 commits intoaep-dev:mainfrom
rambleraptor wants to merge 2 commits intoaep-dev:mainfrom
Conversation
This change modifies the linter to only test methods on paths that have the x-aep-resource extension. Methods on paths without this annotation are no longer tested by AEP rules. Changes: - Added custom functions to check for x-aep-resource before applying rules - Created get-no-request-body.js for AEP-132 (GET operations) - Created delete-no-request-body.js for AEP-135 (DELETE body validation) - Created delete-response-204.js for AEP-135 (DELETE response codes) - Created request-body-required.js for request body validation - Updated parameter-names-unique.js to check for x-aep-resource - Updated all rule files to use custom functions instead of JSONPath filters - Updated all tests to include x-aep-resource annotations - Added tests verifying rules don't apply without x-aep-resource All tests pass with 97% code coverage.
This is a work-in-progress implementation to correctly check for x-aep-resource on resource schemas rather than path items. Completed: - Created resource-utils.js with helper functions: * resolveRef() - Resolve $ref to actual schemas * hasAepResource() - Check if schema has x-aep-resource * findResourceSchema() - Find resource schema from operations * findResourceSchemaForCustomMethod() - Handle custom methods * shouldLintOperation() - Determine if operation should be linted - Created comprehensive tests (27 tests, all passing): * test/resource-utils.test.js - Updated all validation functions to use new utilities: * get-no-request-body.js * delete-no-request-body.js * delete-response-204.js * request-body-required.js * parameter-names-unique.js Outstanding Issues: - Integration tests failing - need to determine correct way to access full OpenAPI document (including components/schemas) from Spectral custom functions via otherValues parameter - Need to update remaining test files (0135, parameter-names-unique, etc.) - Need to verify document access works with Spectral's resolution The utility functions are solid and well-tested. The remaining work is to properly wire them into Spectral's custom function interface.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change modifies the linter to only test methods on paths that have the x-aep-resource extension. Methods on paths without this annotation are no longer tested by AEP rules.
Changes:
All tests pass with 97% code coverage.