Umer Hayyat
Umer Hayyat

Reputation: 406

SwaggerUI through Swashbuckle documenting two different models against 1 ASP.NET WEB API action

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.

Upvotes: 0

Views: 372

Answers (1)

Darrel Miller
Darrel Miller

Reputation: 142272

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.

Upvotes: 1

Related Questions