diff --git a/src/lib/blueprint.ts b/src/lib/blueprint.ts index 7fda9a7..1291eb2 100644 --- a/src/lib/blueprint.ts +++ b/src/lib/blueprint.ts @@ -148,9 +148,12 @@ const createRoute = ( path: string, pathItem: Record, ): Route => { + const pathParts = path.split('/') + const routePath = `/${pathParts.slice(1, -1).join('/')}` + return { - path, - namespace: { path: path.split('/').slice(0, 2).join('/') }, + path: routePath, + namespace: { path: `/${pathParts[1]}` }, endpoints: createEndpoints(path, pathItem), subroutes: [], } @@ -174,12 +177,15 @@ const createEndpoint = ( operation: Record, path: string, ): Endpoint => { + const pathParts = path.split('/') + const endpointPath = `/${pathParts.slice(1, -1).join('/')}` + return { name: 'operationId' in operation && typeof operation['operationId'] === 'string' ? operation['operationId'] : `${path.replace(/\//g, '')}${method.charAt(0).toUpperCase() + method.slice(1).toLowerCase()}`, - path: `/${path.split('/').slice(1, -1).join('/')}`, + path: endpointPath, description: 'description' in operation && typeof operation['description'] === 'string' ? operation['description'] diff --git a/test/snapshots/blueprint.test.ts.md b/test/snapshots/blueprint.test.ts.md index b781a09..804fc4e 100644 --- a/test/snapshots/blueprint.test.ts.md +++ b/test/snapshots/blueprint.test.ts.md @@ -84,7 +84,7 @@ Generated by [AVA](https://avajs.dev). namespace: { path: '/foos', }, - path: '/foos/get', + path: '/foos', subroutes: [], }, ], diff --git a/test/snapshots/blueprint.test.ts.snap b/test/snapshots/blueprint.test.ts.snap index 03d6041..7bc4312 100644 Binary files a/test/snapshots/blueprint.test.ts.snap and b/test/snapshots/blueprint.test.ts.snap differ diff --git a/test/snapshots/seam-blueprint.test.ts.md b/test/snapshots/seam-blueprint.test.ts.md index f070af0..5b8e254 100644 --- a/test/snapshots/seam-blueprint.test.ts.md +++ b/test/snapshots/seam-blueprint.test.ts.md @@ -172,7 +172,7 @@ Generated by [AVA](https://avajs.dev). namespace: { path: '/acs', }, - path: '/acs/systems/list', + path: '/acs/systems', subroutes: [], }, ], diff --git a/test/snapshots/seam-blueprint.test.ts.snap b/test/snapshots/seam-blueprint.test.ts.snap index 7717ace..1a3e856 100644 Binary files a/test/snapshots/seam-blueprint.test.ts.snap and b/test/snapshots/seam-blueprint.test.ts.snap differ