diff options
Diffstat (limited to 'packages/sra-api/src/responses.ts')
-rw-r--r-- | packages/sra-api/src/responses.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/sra-api/src/responses.ts b/packages/sra-api/src/responses.ts new file mode 100644 index 000000000..cd7352058 --- /dev/null +++ b/packages/sra-api/src/responses.ts @@ -0,0 +1,24 @@ +import { ResponsesObject } from '@loopback/openapi-v3-types'; + +import { errorResponses } from './errors'; +import { headers } from './headers'; + +export const generateResponses = (schemaName?: string, example?: any, description: string = 'OK'): ResponsesObject => { + const responses = { + '200': { + headers, + description, + content: {}, + }, + ...errorResponses, + }; + if (schemaName) { + responses['200'].content = { + 'application/json': { + schema: { $ref: `#/components/schemas/${schemaName}` }, + example, + }, + }; + } + return responses; +}; |