Skip to content

Commit

Permalink
fix: fixed duplicate operation_id
Browse files Browse the repository at this point in the history
  • Loading branch information
timoklingenhoefer committed Jan 30, 2023
1 parent 14db2ea commit 3e1f6f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/swagger-explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export class SwaggerExplorer {
return validMethods.map((meth) => ({
method: meth.toLowerCase(),
path: fullPath === '' ? '/' : fullPath,
operationId: this.getOperationId(instance, method),
operationId: `${this.getOperationId(instance, method)}_${meth.toLowerCase()}`,
...apiExtension
}));
}
Expand Down
3 changes: 1 addition & 2 deletions test/explorer/swagger-explorer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1453,8 +1453,7 @@ describe('SwaggerExplorer', () => {
expect(['get', 'post', 'put', 'delete', 'patch', 'options', 'head'].every((method) => routes.find((route) => route.root.method === method))).toBe(true);
expect(routes.find((route) => route.root.method === 'all')).toBe(undefined);
// check if all routes are equal except for method
expect(routes.filter((v, i, a) => a.findIndex(v2 => ['path', 'operationId', 'parameter'].every(k => v2[k] === v[k])) === i).length).toEqual(1);
expect(routes[0].root).toEqual(expect.objectContaining({ path: '/globalPrefix/modulePath/*', operationId: 'AllController_all' }));
expect(routes.filter((v, i, a) => a.findIndex(v2 => ['path', 'parameter'].every(k => v2[k] === v[k])) === i).length).toEqual(1);
});
});
});

0 comments on commit 3e1f6f4

Please sign in to comment.