Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0fatal committed Apr 2, 2024
1 parent 2ffb44f commit c1b42fe
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions runtimes/nodejs/src/support/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function extractOpenAPIParams(func: ICloudFunctionData) {
break
}

const comments = ts.getTrailingCommentRanges(func.source.code, type.pos)
const comments = ts.getTrailingCommentRanges(func.source.code, type.end)
let desc = ''
if (comments && comments.length > 0) {
const comment = func.source.code.slice(
Expand Down Expand Up @@ -143,7 +143,11 @@ export function buildOpenAPIDefinition(apiConfig: {
path[method.toLowerCase()] = {
operationId: `${func.name}_${method}`,
summary: func.desc,
requestBody: {
tags: func.tags,
}

if (openApi.requestBody.length > 0) {
path[method.toLowerCase()].requestBody = {
required: true,
content: {
'application/json': {
Expand All @@ -159,8 +163,10 @@ export function buildOpenAPIDefinition(apiConfig: {
},
},
},
},
responses: {
}
}
if (openApi.response.length > 0) {
path[method.toLowerCase()].responses = {
default: {
description: 'success',
content: {
Expand All @@ -178,8 +184,7 @@ export function buildOpenAPIDefinition(apiConfig: {
},
},
},
},
tags: func.tags,
}
}
}
})
Expand Down

0 comments on commit c1b42fe

Please sign in to comment.