0

I have a scenario where my ASP.NET WEB API returns 2 different models depending upon the request object. I am using swagger UI (through swashbuckle) to document my ASP.NET WEB API and currently is unable to find a way to document these 2 models against 1 ASP.NET WEB API action. I have tried googling but was not fruitful. any help will be appreciated.

Umer Hayyat
  • 396
  • 1
  • 5
  • 13

1 Answers1

1

The OpenAPI (formerly known as Swagger) specification version 2 does not have any way of describing two different models for the same operation. With the new OpenAPI V3 you can use a schema with the oneOf attribute to describe multiple possible response shapes.

However, there isn't much tooling available yet for V3.

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243