Closed pvarsh closed 4 months ago
I'm looking to have a conditional response content type (for example based on the request's "Accept" header value).
If the client asks for "application/json", I want to return
'200': { contentType: 'application/json', schema: new Obj({ id: new Str({ example: "123" }), attributes: new Obj({ timestamp: new Str({ example: '2020-08-01T18:41:00.000Z' }), }), }), },
If the client asks for "audio/mpeg", I want to return
'200': { contentType: 'audio/mpeg', schema: new Str({ format: 'binary' }),
If I'm correct, the current code only allows one content type per status code (src/types.ts)
export declare type RouteResponse = Omit<ResponseConfig, 'content'> & { schema?: Record<any, any> contentType?: string } export declare type OpenAPIRouteSchema = Omit< RouteConfig, 'method' | 'path' | 'requestBody' | 'parameters' | 'responses' > & { requestBody?: Record<string, any> parameters?: Record<string, RouteParameter> | RouteParameter[] responses?: { [statusCode: string]: RouteResponse } }
Is that something that can be supported?
Hey @pvarsh i've just published a new version (1.0.13) that adds support for this, read the docs here
I'm looking to have a conditional response content type (for example based on the request's "Accept" header value).
If the client asks for "application/json", I want to return
If the client asks for "audio/mpeg", I want to return
If I'm correct, the current code only allows one content type per status code (src/types.ts)
Is that something that can be supported?