Skip to content

Commit

Permalink
test: update tests to comply with the recent operation id change
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Oct 23, 2024
1 parent 52c7e79 commit 5d40caf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions e2e/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"/api/v1/alias1": {
"get": {
"operationId": "AppController_withAliases0_v1",
"operationId": "AppController_withAliases[0]_v1",
"parameters": [
{
"name": "x-tenant-id",
Expand All @@ -60,7 +60,7 @@
},
"/api/v1/alias2": {
"get": {
"operationId": "AppController_withAliases1_v1",
"operationId": "AppController_withAliases[1]_v1",
"parameters": [
{
"name": "x-tenant-id",
Expand All @@ -79,7 +79,7 @@
},
"/api/v2/alias1": {
"get": {
"operationId": "AppController_withAliases2_v2",
"operationId": "AppController_withAliases[2]_v2",
"parameters": [
{
"name": "x-tenant-id",
Expand All @@ -98,7 +98,7 @@
},
"/api/v2/alias2": {
"get": {
"operationId": "AppController_withAliases3_v2",
"operationId": "AppController_withAliases[3]_v2",
"parameters": [
{
"name": "x-tenant-id",
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger-explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class SwaggerExplorer {
);
const isAlias =
allRoutePaths.length > 1 && allRoutePaths.length !== versions.length;
const methodKey = isAlias ? `${method.name}${index}` : method.name;
const methodKey = isAlias ? `${method.name}[${index}]` : method.name;
return {
method: RequestMethod[requestMethod].toLowerCase(),
path: fullPath === '' ? '/' : fullPath,
Expand Down
20 changes: 10 additions & 10 deletions test/explorer/swagger-explorer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ describe('SwaggerExplorer', () => {
});

// GET
expect(routes[1].root!.operationId).toEqual(operationPrefix + 'find');
expect(routes[1].root!.operationId).toEqual(operationPrefix + 'find[0]');
expect(routes[1].root!.method).toEqual('get');
expect(routes[1].root!.path).toEqual(
'/globalPrefix/modulePath/foos/{objectId}'
Expand Down Expand Up @@ -374,7 +374,7 @@ describe('SwaggerExplorer', () => {
});

// GET alias
expect(routes[2].root!.operationId).toEqual(operationPrefix + 'find');
expect(routes[2].root!.operationId).toEqual(operationPrefix + 'find[1]');
expect(routes[2].root!.method).toEqual('get');
expect(routes[2].root!.path).toEqual(
'/globalPrefix/modulePath/foo/{objectId}'
Expand Down Expand Up @@ -1427,7 +1427,7 @@ describe('SwaggerExplorer', () => {
`/globalPrefix/v${CONTROLLER_VERSION}/modulePath/with-version`
);
expect(routes[0].root.operationId).toEqual(
`WithVersionController_foo`
`WithVersionController_foo_v1`
);
});

Expand All @@ -1446,7 +1446,7 @@ describe('SwaggerExplorer', () => {
`/globalPrefix/v${METHOD_VERSION}/modulePath/with-version`
);
expect(routes[1].root.operationId).toEqual(
`WithVersionController_bar`
`WithVersionController_bar_v2`
);
});

Expand All @@ -1467,15 +1467,15 @@ describe('SwaggerExplorer', () => {
}/modulePath/with-multiple-version`
);
expect(routes[0].root.operationId).toEqual(
`WithMultipleVersionsController_foo`
`WithMultipleVersionsController_foo_v3`
);
expect(routes[1].root.path).toEqual(
`/globalPrefix/v${
CONTROLLER_MULTIPLE_VERSIONS[1] as string
}/modulePath/with-multiple-version`
);
expect(routes[1].root.operationId).toEqual(
`WithMultipleVersionsController_foo`
`WithMultipleVersionsController_foo_v4`
);
});

Expand All @@ -1496,14 +1496,14 @@ describe('SwaggerExplorer', () => {
}/modulePath/with-multiple-version-neutral`
);
expect(routes[0].root.operationId).toEqual(
`WithMultipleVersionsNeutralController_foo`
`WithMultipleVersionsNeutralController_foo[0]_v5`
);

expect(routes[1].root.path).toEqual(
`/globalPrefix/modulePath/with-multiple-version-neutral`
);
expect(routes[1].root.operationId).toEqual(
`WithMultipleVersionsNeutralController_foo`
`WithMultipleVersionsNeutralController_foo[1]`
);
});
});
Expand Down Expand Up @@ -1601,15 +1601,15 @@ describe('SwaggerExplorer', () => {
}/modulePath/with-multiple-version-neutral`
);
expect(routes[0].root.operationId).toEqual(
`WithMultipleVersionsNeutralController.foo.v${
`WithMultipleVersionsNeutralController.foo[0].v${
CONTROLLER_MULTIPLE_VERSIONS_NEUTRAL[0] as string
}`
);
expect(routes[1].root.path).toEqual(
`/globalPrefix/modulePath/with-multiple-version-neutral`
);
expect(routes[1].root.operationId).toEqual(
`WithMultipleVersionsNeutralController.foo`
`WithMultipleVersionsNeutralController.foo[1]`
);
});
});
Expand Down

0 comments on commit 5d40caf

Please sign in to comment.