-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP-271997: IPA-108 - Deletion coverage #474
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
| severity: error | ||
| given: $.paths[*].delete.responses['404'] | ||
| then: | ||
| field: content |
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.
IMHO not worth to have function here
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.
To be able to collect adoption, we need custom functions for every rule
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.
In addition, error schema checks belongs to IPA-114: Errors. Checking if DELETE method must include 404 response will be fine for the IPA-108:Delete
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.
Agree. Possible fix for IPA to move this claim to errors etc.
| description: 'DELETE method must return 204 No Content' | ||
| message: '{{error}} http://go/ipa/108' | ||
| severity: error | ||
| given: '$.paths.*' |
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.
This can be $.paths[*].delete similar to xgen-IPA-104-get-method-response-code-is-200 rule, the custom function would be much cleaner
| description: 'DELETE method must not have request body' | ||
| message: '{{error}} http://go/ipa/108' | ||
| severity: error | ||
| given: '$.paths.*' |
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.
This can be $.paths[*].delete, similar to the comment above
| description: 'DELETE method must include 404 response' | ||
| message: '{{error}} http://go/ipa/108' | ||
| severity: error | ||
| given: '$.paths.*' |
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.
This can be $.paths[*].delete, similar to the comment above
| function: deleteMethod404Response | ||
|
|
||
| xgen-IPA-108-delete-204-content-type: | ||
| description: '204 response must not include content-type header' |
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 lead me to the IPA guideline mentioning this?
| import { collectAdoption, collectAndReturnViolation, collectException } from './utils/collectionUtils.js'; | ||
|
|
||
| const RULE_NAME = 'xgen-IPA-108-delete-response-should-be-void'; | ||
| const ERROR_MESSAGES = { |
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.
This function should only capture NON_EMPTY_RESPONSE case
| xgen-IPA-108-delete-response-should-be-void: | ||
| description: 'Delete method response must be void http://go/ipa/108' | ||
| message: '{{error}} http://go/ipa/108' | ||
| severity: error |
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.
All the severity levels should be warning
40b2bce to
a559d88
Compare
|
@yelizhenden-mdb previous PR were not ready for review. This should work now. |
|
Closing to experiment with Auto PR creation feature |
Overview
This PR implements a new set of Spectral rules for validating DELETE operations in OpenAPI specifications according to the IPA-108 guidelines. The rules ensure consistent implementation of DELETE endpoints across our APIs.
Features Implemented
Rule Definitions
Created IPA-108.yaml ruleset defining four validation rules for DELETE operations:
- Ensuring DELETE responses are empty (204 No Content)
- Validating that DELETE methods return a 204 status code
- Preventing DELETE methods from having request bodies
- Requiring DELETE methods to include 404 responses for not found resources
Rule Functions
Implemented four function modules that perform the actual validation:
Test Coverage
Added comprehensive test cases for each rule:
Technical Details
Related Documentation
IPA-108 guidelines for DELETE operations: http://go/ipa/108