Specifying multiple content-types in itty-router-openapi responses

I'm looking to return response content-type conditional on request accept header. OpenAPI spec has an example https://swagger.io/docs/specification/describing-responses/
get:
summary: Get all users
responses:
'200':
description: A list of users
content:
application/json:
schema:
$ref: '#/components/schemas/ArrayOfUsers'
application/xml:
schema:
$ref: '#/components/schemas/ArrayOfUsers'
text/plain:
schema:
type: string
get:
summary: Get all users
responses:
'200':
description: A list of users
content:
application/json:
schema:
$ref: '#/components/schemas/ArrayOfUsers'
application/xml:
schema:
$ref: '#/components/schemas/ArrayOfUsers'
text/plain:
schema:
type: string
but I can't find a way to accomplish that with itty-router-openapi response format. I tried something like
responses: {
'200': {
content: {
'application/json': {
schema: new Obj({
type: new Str({ description: "the type of object", default: 'foo', example: 'foo' }),
})
},
'text/plain': {
schema: { type: 'string' }
},
},
},
responses: {
'200': {
content: {
'application/json': {
schema: new Obj({
type: new Str({ description: "the type of object", default: 'foo', example: 'foo' }),
})
},
'text/plain': {
schema: { type: 'string' }
},
},
},
but it seems that the object with the status code key must satisfy
export interface ResponseSchema {
description?: string;
schema?: Record<any, any>;
contentType?: string;
}
export interface ResponseSchema {
description?: string;
schema?: Record<any, any>;
contentType?: string;
}
Is there a way to specify multiple content types there?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server