As far as I understand this feature requires migrating from swagger 2.0 currently used by @nest/swagger to openapi 3
I need this in a lot of my response case scenarios :( I'm returning a payload similar to this:
{
"items": Item[],
"articles": NewsArticle[]
}
Any chance this is going to be upgraded? Or is there a way to do tell Swagger that my response looks like this? Because currently, I cannot figure it out so my swagger-codegen isn't generating the typescript files for these objects :(
For anybody wanting a workaround for now so your codegen still detects it to generate a typescript file for it for your front-end, I used this code:
export class HomePayload {
@ApiModelProperty({
isArray: true
})
items: Object; // This will eventually change to an Entity
@ApiModelProperty({
isArray: true
})
articles: NewsArticle;
}
Then in my controller, I just have this:
@ApiOkResponse({
type: HomePayload,
description: 'Returns payload for homepage.'
})
@Get('home')
home() {
// Code here
}
Then my Swagger documentation looks like this:

Any updates on this? Running into the same issue in a lot of places of our swagger type generations
It would be great to have this for @ApiResponse also...
Really needed
Is there a rough estimation, when this will be available?
Available in 4.0.0
https://docs.nestjs.com/recipes/swagger#oneof-anyof-allof
You can use the same approach with @ApiBody(), @ApiQuery() etc etc
Thanks! @kamilmysliwiec , BTW, completely unrelated, note that the auto-scroll to hash (#oneof-anyof-allof) does not work (it actually goes to #circular-dependencies) (using chrome latest)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Any updates on this? Running into the same issue in a lot of places of our swagger type generations