Allowing multiple content types for the same response status code
pvarsh opened this issue · 1 comments
pvarsh commented
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?