Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/serverless-openapi-typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ export default class ServerlessOpenapiTypeScript {
if (customTags) openApi.tags = openApi.tags.concat(customTags)

Object.values(openApi.paths).forEach(path => {
Object.values(path).forEach(method => {
Object.entries(path).forEach(([methodName, method]) => {
const httpEvent = this.functions[method.operationId]?.events?.find(
(e: ApiGatewayEvent) => e.http
(e: ApiGatewayEvent) => (e.http as any).method === methodName
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript-wise e.http could be string so TS cried but I see in the next lines we used it as an object so I did that.

) as ApiGatewayEvent;
const http: HttpEvent = httpEvent.http;
if (http.documentation?.tag) {
Expand All @@ -234,7 +234,7 @@ export default class ServerlessOpenapiTypeScript {
method.tags = [tagName];
}

method.operationId = kebabCase(`${this.serverless.service.custom?.documentation?.title}-${method.operationId}`);
method.operationId = kebabCase(`${this.serverless.service.custom?.documentation?.title}-${method.operationId}-${methodName}`);
});
});
}
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/expect-openapi-custom-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ info:
paths:
/create:
post:
operationId: project-create-func
operationId: project-create-func-post
summary: Create Function
description: |
Create Function1
Expand All @@ -37,7 +37,7 @@ paths:
- FooBarTitle
/delete:
delete:
operationId: project-delete-func
operationId: project-delete-func-delete
summary: Delete Function
description: Delete
parameters: []
Expand All @@ -49,7 +49,7 @@ paths:
- Project
/get:
get:
operationId: project-get-func
operationId: project-get-func-get
summary: Get Function
parameters: []
responses:
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/expect-openapi-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ info:
paths:
/create/{funcName}:
post:
operationId: project-create-func
operationId: project-create-func-post
summary: Create Function
description: |
Create Function1
Expand Down Expand Up @@ -163,7 +163,7 @@ paths:
- Project
/delete/{funcName}:
delete:
operationId: project-delete-func
operationId: project-delete-func-delete
summary: Delete Function
description: Delete
parameters:
Expand All @@ -181,7 +181,7 @@ paths:
- Project
/update:
put:
operationId: project-update-func
operationId: project-update-func-put
summary: Delete Function
description: Delete
requestBody:
Expand All @@ -202,7 +202,7 @@ paths:
- Project
/get/{funcName}:
get:
operationId: project-get-func
operationId: project-get-func-get
summary: Get Function
parameters:
- name: funcName
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/expect-openapi-hyphenated-functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ info:
paths:
/create:
post:
operationId: project-create-func
operationId: project-create-func-post
summary: Create Function
description: |
Create Function1
Expand All @@ -37,7 +37,7 @@ paths:
- FooBarTitle
/delete:
delete:
operationId: project-delete-all-func
operationId: project-delete-all-func-delete
summary: Delete Function
description: Delete
parameters: []
Expand All @@ -49,7 +49,7 @@ paths:
- Project
/get:
get:
operationId: project-get-func
operationId: project-get-func-get
summary: Get Function
parameters: []
responses:
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/expect-openapi-query-param-type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ info:
paths:
/get:
get:
operationId: func
operationId: func-get
summary: Get Function
parameters:
- name: name
Expand Down