I have this route which can return one of these two different DTOs:
@Get()
@ApiQuery({ name: 'legacy', description: "'Y' to get houses legacy" })
async findAllHouses(
@Query('legacy') legacy: string,
): Promise<HousesDto[] | HousesLegacyDto[]> {
...
}
I want to display both of these ResponseDTO
s in swagger.
I've tried this decorator:
@ApiOkResponse({
schema: { oneOf: refs(HousesDto, HousesLegacyDto) },
})
// OR
@ApiOkResponse({
schema: {
oneOf: [
{ $ref: getSchemaPath(HousesDto) },
{ $ref: getSchemaPath(HousesLegacyDto) },
],
},
})
with @ApiExtraModels()
on top of DTO classes and @ApiProperty()
on each properties.
But I still get empty objects in Swagger and I suppose it would not have even taken array types in consideration.
How can I display both of these schemas properly?