Swagger: feature request: support 'oneof-anyof-allof-not'

Created on 29 Jan 2018  路  10Comments  路  Source: nestjs/swagger

Most helpful comment

Any updates on this? Running into the same issue in a lot of places of our swagger type generations

All 10 comments

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:
image

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itslenny picture itslenny  路  3Comments

leefordjudes picture leefordjudes  路  4Comments

mogusbi picture mogusbi  路  3Comments

Fiorello picture Fiorello  路  5Comments

kalaivanan-muthusamy picture kalaivanan-muthusamy  路  4Comments