swagger icon indicating copy to clipboard operation
swagger copied to clipboard

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

Open amitport opened this issue 8 years ago • 10 comments

https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/

please consider

thanks!

amitport avatar Jan 29 '18 12:01 amitport

As far as I understand this feature requires migrating from swagger 2.0 currently used by @nest/swagger to openapi 3

spreadingmind avatar Oct 04 '18 16:10 spreadingmind

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

hlohrenz avatar Nov 14 '18 18:11 hlohrenz

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

hlohrenz avatar Nov 14 '18 19:11 hlohrenz

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

Epenance avatar Jan 08 '19 07:01 Epenance

It would be great to have this for @ApiResponse also...

vkartaviy avatar May 20 '19 22:05 vkartaviy

Really needed

seblemeur avatar Jul 05 '19 13:07 seblemeur

Is there a rough estimation, when this will be available?

Digister avatar Sep 04 '19 13:09 Digister

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

kamilmysliwiec avatar Dec 03 '19 10:12 kamilmysliwiec

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)

amitport avatar Dec 03 '19 11:12 amitport

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.

lock[bot] avatar Apr 25 '20 09:04 lock[bot]