-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Labels
Description
I was trying to return a oneOf schema as a paginated Entity, but unfortunately it's is not possible to pass a custom schema or model by string into @PaginatedSwaggerDocs. So I had to create a CustomType manually for that and reference it by string with an type-ignore.
Example:
CustomType defined in the swagger:
CustomType:
oneOf:
- $ref: '#/components/schemas/Case1'
- $ref: '#/components/schemas/Case2'
- $ref: '#/components/schemas/Case3'
discriminator:
propertyName: type
mapping:
a: '#/components/schemas/Case1'
b: '#/components/schemas/Case2'
c: '#/components/schemas/Case3'
d: '#/components/schemas/Case3'Trying to use this @PaginatedSwaggerDocs('CustomType', paginationConfig) shows a type error because string is not assignable to DTO.
But when ignoring the typecheck the build of the swagger is successful anyway, because getSchemaPath accepts a string, for referencing a schema.
So either allowing string as a parameter in the @PaginatedSwaggerDocs or allowing CustomSchemas by passing something like:
@PaginatedSwaggerDocs({ schema: {
CustomType: {
oneOf: [
{
$ref: getSchemaPath(Case1)
},
{
$ref: getSchemaPath(Case2)
},
{
$ref: getSchemaPath(Case3)
}
],
discriminator: {
propertyName: 'type',
mapping: {
a: getSchemaPath(Case1),
b getSchemaPath(Case2),
c: getSchemaPath(Case3),
d: getSchemaPath(Case3)
}
}
}
}
}, paginationConfig)Reactions are currently unavailable