Skip to content

Commit

Permalink
Merge 18e48c5 into 7730e0d
Browse files Browse the repository at this point in the history
  • Loading branch information
Pchelolo committed Jul 24, 2019
2 parents 7730e0d + 18e48c5 commit 4cfc1f8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
24 changes: 24 additions & 0 deletions test/features/router/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,28 @@ describe('router - misc', function() {
assert.deepEqual(res.body, '');
});
});

it('should only use unique operationId', () => {
return preq.get({
uri: `${server.config.baseURL()}/?spec`
})
.then((res) => {
const spec = res.body;
const operations = [];
Object.keys(spec.paths).forEach((path) => {
const pathSpec = spec.paths[path];
Object.keys(pathSpec).forEach((method) => {
const operationId = pathSpec[method].operationId;
if (operationId) {
if (operations.includes(operationId)) {
throw new assert.AssertionError({
message: `Duplicated operationId ${operationId} at path ${path}:${method}`
});
}
operations.push(operationId);
}
})
});
})
});
});
4 changes: 2 additions & 2 deletions v1/pcs/media-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
operationId: getContent-media-list
x-monitor: true
x-amples:
- title: Get media-list from storage
Expand Down Expand Up @@ -128,7 +128,7 @@ paths:
To get a 200 response instead, supply `false` to the `redirect` parameter.
schema:
type: boolean
operationId: getContentWithRevision
operationId: getContentWithRevision-media-list
x-monitor: false

components:
Expand Down
4 changes: 2 additions & 2 deletions v1/pcs/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
operationId: getContent-metadata
x-monitor: true
x-amples:
- title: Get metadata from storage
Expand Down Expand Up @@ -137,7 +137,7 @@ paths:
To get a 200 response instead, supply `false` to the `redirect` parameter.
schema:
type: boolean
operationId: getContentWithRevision
operationId: getContentWithRevision-metadata
x-monitor: false

components:
Expand Down
4 changes: 2 additions & 2 deletions v1/pcs/mobile-html.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
operationId: getContent-mobile-html
x-monitor: true
x-amples:
- title: Get mobile-html from storage
Expand Down Expand Up @@ -149,5 +149,5 @@ paths:
To get a 200 response instead, supply `false` to the `redirect` parameter.
schema:
type: boolean
operationId: getContentWithRevision
operationId: getContentWithRevision-mobile-html
x-monitor: false
4 changes: 2 additions & 2 deletions v1/pcs/references.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
operationId: getContent-references
x-monitor: true
x-amples:
- title: Get references from storage
Expand Down Expand Up @@ -131,7 +131,7 @@ paths:
To get a 200 response instead, supply `false` to the `redirect` parameter.
schema:
type: boolean
operationId: getContentWithRevision
operationId: getContentWithRevision-references
x-monitor: false

# copied from MCS spec.yaml
Expand Down
4 changes: 2 additions & 2 deletions v1/pcs/stored_endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ module.exports = (options) => {
return {
spec,
operations: {
getContent: pcs.getContent.bind(pcs),
getContentWithRevision: pcs.getContent.bind(pcs)
[`getContent-${options.name}`]: pcs.getContent.bind(pcs),
[`getContentWithRevision-${options.name}`]: pcs.getContent.bind(pcs)
},
resources: [
{ uri: `/{domain}/sys/key_value/${options.name}` }
Expand Down

0 comments on commit 4cfc1f8

Please sign in to comment.