Skip to content

Commit

Permalink
added handle * too and update snaps again
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Oct 29, 2024
1 parent 291bf48 commit 12f989f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const sharedOas = {
get: {
deprecated: true,
'x-discontinued': 'route discontinued version or date',
operationId: '%2Fbar#0',
operationId: 'get-bar',
parameters: [
{
description: 'The version of the API to use',
Expand Down Expand Up @@ -154,7 +154,7 @@ export const sharedOas = {
'/foo/{id}/{path*}': {
get: {
description: 'route description',
operationId: '%2Ffoo%2F%7Bid%7D%2F%7Bpath*%7D#0',
operationId: 'get-foo-id-path',
parameters: [
{
description: 'The version of the API to use',
Expand Down Expand Up @@ -278,7 +278,7 @@ export const sharedOas = {
},
post: {
description: 'route description',
operationId: '%2Ffoo%2F%7Bid%7D%2F%7Bpath*%7D#1',
operationId: 'post-foo-id-path',
parameters: [
{
description: 'The version of the API to use',
Expand Down
7 changes: 7 additions & 0 deletions packages/kbn-router-to-openapispec/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ describe('getOpId', () => {
},
output: 'get-my-resource-id',
},
{
input: {
method: 'get',
path: '/api/my/resource/{path*}',
},
output: 'get-my-resource-path',
},
])('$input.method $input.path -> $output', ({ input, output }) => {
expect(getOpId(input)).toBe(output);
});
Expand Down
4 changes: 1 addition & 3 deletions packages/kbn-router-to-openapispec/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ export const getOpId = ({ path, method }: { path: string; method: string }): str
return `${method.toLocaleLowerCase()}-${path
.replace(/^\//, '')
.replace(/\/$/, '')
.replace(/\{/g, '')
.replace(/\}/g, '')
.replace(/\?/g, '')
.replace(/[\{\}\?\*]/g, '')
.replace(/\//g, '-')}`;
};

0 comments on commit 12f989f

Please sign in to comment.