-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP-306575: IPA-118: Extensible by Default #642
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
Conversation
| - '**#/components/schemas/UserSecurity/properties/customerX509' # unable to document exceptions, to be covered by CLOUDP-308286 | ||
| rules: | ||
| xgen-IPA-112-field-names-are-camel-case: 'off' | ||
| - files: |
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.
FYI drive-by fix to sync with MMS
| try { | ||
| const errors = []; | ||
|
|
||
| const results = findAdditionalPropertiesFalsePaths(schemaObject, path); |
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.
Can you add a test case where there are multiple additionalProperties: false? (In the same schema, nested for example)
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.
Sure, added them with the name invalid with multiple nested additionalProperties: false and invalid with multiple nested additionalProperties: false - exceptions. Let me know how it looks
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.
Great, thanks!
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.
Pull Request Overview
This PR introduces a new rule (IPA-118) to prevent schemas from restricting additional properties by setting additionalProperties: false, reinforcing the principle of extensibility by default.
- Added a utility (findAdditionalPropertiesFalsePaths) to recursively locate instances of additionalProperties: false in schema objects
- Implemented the IPA118NoAdditionalPropertiesFalse rule that leverages this utility, along with comprehensive tests and documentation updates
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/spectral/ipa/rulesets/functions/utils/compareUtils.js | Adds a utility function to recursively detect paths with additionalProperties: false in schemas. |
| tools/spectral/ipa/rulesets/functions/IPA118NoAdditionalPropertiesFalse.js | Implements the new rule that checks schemas using the utility function. |
| tools/spectral/ipa/rulesets/README.md | Updates documentation to include the IPA-118 rule details. |
| tools/spectral/ipa/rulesets/IPA-118.yaml | Provides the rule configuration for Spectral. |
| tools/spectral/ipa/ipa-spectral.yaml | Adds the IPA-118 rule file to the overall Spectral configuration. |
| tools/spectral/ipa/tests/utils/compareUtils.test.js | Adds tests to verify the correctness of the new utility function. |
| tools/spectral/ipa/tests/IPA118NoAdditionalPropertiesFalse.test.js | Introduces tests to check the new rule's behavior under various scenarios. |
Proposed changes
Jira ticket: CLOUDP-306575
No violations to fix
Checklist
Changes to Spectral
Further comments