Skip to content
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
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,16 @@ 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: 'string',
format: 'binary',
},
'application/vnd.atlas.2023-08-05+gzip': {
schema: {
type: 'string',
format: 'binary',
},
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions tools/spectral/ipa/rulesets/IPA-117.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ rules:
##### Implementation details
- The rule only applies to 2xx responses
- The rule ignores JSON and YAML responses (passed as `allowedTypes`)
- The rule ignores responses with `format: 'binary'` (i.e. file types)
- 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 Down
1 change: 1 addition & 0 deletions tools/spectral/ipa/rulesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,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 responses with `format: 'binary'` (i.e. file types)
- 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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export default (input, { allowedTypes }, { documentInventory, path }) => {

const response = resolveObject(documentInventory.resolved, path);

// Ignore binary formats, i.e. files
if (
(response['type'] && response['format'] === 'binary') ||
(response['schema'] && response['schema']['format'] === 'binary')
) {
return;
}

if (hasException(response, RULE_NAME)) {
collectException(response, RULE_NAME, path);
return;
Expand Down
Loading