diff --git a/packages/kbn-router-to-openapispec/src/util.test.ts b/packages/kbn-router-to-openapispec/src/util.test.ts index e3011aa1a5a73..ee34976e47152 100644 --- a/packages/kbn-router-to-openapispec/src/util.test.ts +++ b/packages/kbn-router-to-openapispec/src/util.test.ts @@ -117,10 +117,12 @@ describe('assignToPaths', () => { assignToPaths(paths, '/foo', {}); assignToPaths(paths, '/bar/{id?}', {}); assignToPaths(paths, '/bar/file/{path*}', {}); + assignToPaths(paths, '/bar/file/{path*}/{id?}', {}); expect(paths).toEqual({ '/foo': {}, '/bar/{id}': {}, '/bar/file/{path}': {}, + '/bar/file/{path}/{id}': {}, }); }); }); diff --git a/packages/kbn-router-to-openapispec/src/util.ts b/packages/kbn-router-to-openapispec/src/util.ts index 1088259e73d05..61c69caf538f9 100644 --- a/packages/kbn-router-to-openapispec/src/util.ts +++ b/packages/kbn-router-to-openapispec/src/util.ts @@ -132,7 +132,7 @@ export const assignToPaths = ( path: string, pathObject: OpenAPIV3.PathItemObject ): void => { - const pathName = path.replace(/[\?\*]/, ''); + const pathName = path.replace(/[\?\*]/g, ''); paths[pathName] = { ...paths[pathName], ...pathObject }; };