Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ testRule('xgen-IPA-117-plaintext-response-must-have-example', [
},
},
},
// Ignores JSON/YAML
// Ignores JSON/YAML/gzip
'/resourceTwo': {
get: {
responses: {
Expand All @@ -46,6 +46,9 @@ testRule('xgen-IPA-117-plaintext-response-must-have-example', [
'application/vnd.atlas.2024-08-05+yaml': {
type: 'string',
},
'application/vnd.atlas.2024-08-05+gzip': {
type: 'binary',
},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions tools/spectral/ipa/rulesets/IPA-117.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ rules:

##### Implementation details
- The rule only applies to 2xx responses
- The rule ignores JSON and YAML responses (passed as `allowedTypes`)
- The rule ignores JSON, YAML and GZIP responses (passed as `allowedTypes`)
- The rule checks for the presence of the example property as a sibling to the `schema` property, or inside the `schema` object
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-117-plaintext-response-must-have-example'
severity: warn
Expand All @@ -176,7 +176,7 @@ rules:
field: '@key'
function: 'IPA117PlaintextResponseMustHaveExample'
functionOptions:
allowedTypes: ['json', 'yaml']
allowedTypes: ['json', 'yaml', 'gzip']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Instead of adding it as gzip, how about checking if the schema format is binary and ignoring them accordingly? That way, we wouldn't need to list all future possible binary media types

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's a good idea. It'll ignore other filetypes if there would be new ones in the future

xgen-IPA-117-objects-must-be-well-defined:
description: |
Components of type "object" must be well-defined, i.e. have of one of the properties:
Expand Down
2 changes: 1 addition & 1 deletion tools/spectral/ipa/rulesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ For APIs that respond with plain text, for example CSV, API producers must provi

##### Implementation details
- The rule only applies to 2xx responses
- The rule ignores JSON and YAML responses (passed as `allowedTypes`)
- The rule ignores JSON, YAML and GZIP responses (passed as `allowedTypes`)
- The rule checks for the presence of the example property as a sibling to the `schema` property, or inside the `schema` object

#### xgen-IPA-117-objects-must-be-well-defined
Expand Down
Loading