Skip to content

Commit a8dff8c

Browse files
CLOUDP-271994: IPA-106: Validate Create methods accepts no query params (ignore envelope and pretty query params)
1 parent 97114bd commit a8dff8c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const componentSchemas = {
2222
type: 'string',
2323
},
2424
},
25+
envelope: {
26+
name: 'envelope',
27+
in: 'query',
28+
},
29+
pretty: {
30+
name: 'pretty',
31+
in: 'query',
32+
},
2533
},
2634
};
2735

@@ -49,6 +57,12 @@ testRule('xgen-IPA-106-create-method-should-not-have-query-parameters', [
4957
{
5058
$ref: '#/components/parameters/PathParam',
5159
},
60+
{
61+
$ref: '#/components/parameters/envelope',
62+
},
63+
{
64+
$ref: '#/components/parameters/pretty',
65+
},
5266
],
5367
},
5468
},

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { isCustomMethodIdentifier } from './utils/resourceEvaluation.js';
55
const RULE_NAME = 'xgen-IPA-106-create-method-should-not-have-query-parameters';
66
const ERROR_MESSAGE = 'Create operations should not have query parameters.';
77

8+
const ignoredParameters = ['envelope', 'pretty'];
9+
810
export default (input, _, { path }) => {
911
const resourcePath = path[1];
1012

@@ -23,7 +25,7 @@ export default (input, _, { path }) => {
2325
}
2426

2527
for (const parameter of postMethod.parameters) {
26-
if (parameter.in === 'query') {
28+
if (parameter.in === 'query' && !ignoredParameters.includes(parameter.name)) {
2729
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE);
2830
}
2931
}

0 commit comments

Comments
 (0)