aboutsummaryrefslogblamecommitdiffstats
path: root/packages/sra-api/src/responses.ts
blob: cd7352058a0125b6d54c2880e178419874997a58 (plain) (tree)
1
2
3
4
5




                                                             










                                                                                                                       

                                                                       
                        
              



                     
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;
};