Skip to content
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

fix: 101 and 202 responses do not need content entries #320

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spectral/rulesets/.defaultsForSpectral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ rules:
content-entry-provided:
description: Request bodies and non-204 responses should define a content object
given:
- $.paths[*][*].responses[?(@property != '204')]
- $.paths[*][*].responses[?(@property != '204' && @property != '202' && @property != '101')]
- $.paths[*][*].requestBody
severity: warn
formats: ["oas3"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const inCodeValidator = require('../../../../src/lib');

describe('spectral - test content entry validation does not produce false positives', function() {
it('should not error when content object provided or for 204 response without content', async () => {
it('should not error when content object provided or for 101, 202, 204 response without content', async () => {
const spec = {
openapi: '3.0.0',
info: {
Expand All @@ -27,6 +27,13 @@ describe('spectral - test content entry validation does not produce false positi
}
}
},
'101': {
description:
'Switching protocols response with no response body'
},
'202': {
description: 'Success response with no response body'
},
'204': {
description: 'Success response with no response body'
}
Expand Down