aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-api/src/responses.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sra-api/src/responses.ts')
-rw-r--r--packages/sra-api/src/responses.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/packages/sra-api/src/responses.ts b/packages/sra-api/src/responses.ts
index 03a0cced8..cd7352058 100644
--- a/packages/sra-api/src/responses.ts
+++ b/packages/sra-api/src/responses.ts
@@ -3,16 +3,22 @@ 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 => ({
- '200': {
- headers,
- description,
- content: {
+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,
},
- },
- },
- ...errorResponses,
-});
+ };
+ }
+ return responses;
+};