Skip to content

Commit

Permalink
fix: check for presence of operationId
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Nov 30, 2020
1 parent f51a6b0 commit 177d3ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/rulesets/oas/functions/oasOpIdUnique.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ export const oasOpIdUnique: IFunction = targetVal => {
const seenIds: unknown[] = [];

for (const { path, operation } of getAllOperations(paths)) {
if (!('operationId' in paths[path][operation])) {
continue;
}

const { operationId } = paths[path][operation];

if (seenIds.includes(operationId)) {
results.push({
message: 'operationId must be unique.',
path: ['paths', path, operation, 'operationId'],
});
} else {
seenIds.push(operationId);
}

seenIds.push(operationId);
}

return results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ OpenAPI 3.x detected
2:6 warning info-description OpenAPI object info `description` must be present and non-empty string. info
7:9 warning operation-description Operation `description` must be present and non-empty string. paths./test.get
7:9 warning operation-tags Operation should have non-empty `tags` array. paths./test.get
8:20 error operation-operationId-unique Every operation must have a unique `operationId`. paths./test.get.operationId
10:9 error parser Mapping key must be a string scalar rather than number paths./test.get.responses[200]
12:10 warning operation-description Operation `description` must be present and non-empty string. paths./test.post
12:10 warning operation-tags Operation should have non-empty `tags` array. paths./test.post
Expand Down

0 comments on commit 177d3ab

Please sign in to comment.