import { Method , Config , SwaggerJson , SwaggerRequest , SwaggerResponse , } from "../types" ; import { generateServiceName } from "../utils" ; export const APPLICATION_JSON = "application/json" ; export type ResponsesType = { [ path ] : { path : string ; method : Method ; response : { [ status ] : SwaggerResponse [ "content" ] ; } ; } ; } ; export const extractResponses = ( input , config ) : ResponsesType => { const ret = { } ; Object . entries ( input . paths ) . forEach ( ( [ path , value ] ) => { Object . entries ( value ) . forEach ( ( [ method , options ] ) => { const { operationId , responses } = options ; const response = { } ; Object . keys ( responses ) . forEach ( ( statusCode ) => { const { content } = responses [ statusCode ] ; response [ statusCode ] = content ; } ) ; const key = generateServiceName ( path , method , operationId , config ) ; ret [ key ] = { method : method as Method , path , response , } ; } ) ; } ) ; return ret ; } ;