Skip to content

Commit 156e55b

Browse files
CLOUDP-306573: Address comment
1 parent 1ed4716 commit 156e55b

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

tools/spectral/ipa/__tests__/IPA117PlaintextResponseMustHaveExample.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ testRule('xgen-IPA-117-plaintext-response-must-have-example', [
4747
type: 'string',
4848
},
4949
'application/vnd.atlas.2024-08-05+gzip': {
50-
type: 'binary',
50+
type: 'string',
51+
format: 'binary',
52+
},
53+
'application/vnd.atlas.2023-08-05+gzip': {
54+
schema: {
55+
type: 'string',
56+
format: 'binary',
57+
},
5158
},
5259
},
5360
},

tools/spectral/ipa/rulesets/IPA-117.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ rules:
166166
167167
##### Implementation details
168168
- The rule only applies to 2xx responses
169-
- The rule ignores JSON, YAML and GZIP responses (passed as `allowedTypes`)
169+
- The rule ignores JSON and YAML responses (passed as `allowedTypes`)
170+
- The rule ignores responses with `format: 'binary'` (i.e. file types)
170171
- The rule checks for the presence of the example property as a sibling to the `schema` property, or inside the `schema` object
171172
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-117-plaintext-response-must-have-example'
172173
severity: warn
@@ -176,7 +177,7 @@ rules:
176177
field: '@key'
177178
function: 'IPA117PlaintextResponseMustHaveExample'
178179
functionOptions:
179-
allowedTypes: ['json', 'yaml', 'gzip']
180+
allowedTypes: ['json', 'yaml']
180181
xgen-IPA-117-objects-must-be-well-defined:
181182
description: |
182183
Components of type "object" must be well-defined, i.e. have of one of the properties:

tools/spectral/ipa/rulesets/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ For APIs that respond with plain text, for example CSV, API producers must provi
728728

729729
##### Implementation details
730730
- The rule only applies to 2xx responses
731-
- The rule ignores JSON, YAML and GZIP responses (passed as `allowedTypes`)
731+
- The rule ignores JSON and YAML responses (passed as `allowedTypes`)
732+
- The rule ignores responses with `format: 'binary'` (i.e. file types)
732733
- The rule checks for the presence of the example property as a sibling to the `schema` property, or inside the `schema` object
733734

734735
#### xgen-IPA-117-objects-must-be-well-defined

tools/spectral/ipa/rulesets/functions/IPA117PlaintextResponseMustHaveExample.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ export default (input, { allowedTypes }, { documentInventory, path }) => {
3232

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

35+
// Ignore binary formats, i.e. files
36+
if (
37+
(response['type'] && response['format'] === 'binary') ||
38+
(response['schema'] && response['schema']['format'] === 'binary')
39+
) {
40+
return;
41+
}
42+
3543
if (hasException(response, RULE_NAME)) {
3644
collectException(response, RULE_NAME, path);
3745
return;

0 commit comments

Comments
 (0)