Skip to content

Commit

Permalink
Handle asterisk paths in kbn-router-to-openapispec
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl committed Nov 14, 2024
1 parent 2ed3008 commit 87e054c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/kbn-router-to-openapispec/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
getPathParameters,
createOpIdGenerator,
GetOpId,
assignToPaths,
extractTags,
} from './util';
import { assignToPaths, extractTags } from './util';

describe('extractTags', () => {
test.each([
Expand Down Expand Up @@ -115,9 +116,11 @@ describe('assignToPaths', () => {
const paths = {};
assignToPaths(paths, '/foo', {});
assignToPaths(paths, '/bar/{id?}', {});
assignToPaths(paths, '/bar/file/{path*}', {});
expect(paths).toEqual({
'/foo': {},
'/bar/{id}': {},
'/bar/file/{path}': {},
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-router-to-openapispec/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const assignToPaths = (
path: string,
pathObject: OpenAPIV3.PathItemObject
): void => {
const pathName = path.replace('?', '');
const pathName = path.replace(/[\?\*]/, '');
paths[pathName] = { ...paths[pathName], ...pathObject };
};

Expand Down

0 comments on commit 87e054c

Please sign in to comment.