Reputation: 1122
I use Swashbuckle.AspNetCore library to generate Swagger documentation. Is it possible to add multiple error messages to one status code? For example I have field which has validations so I need this in my documentation:
Code Description
400 Invalid format
Field is required
Should be greater than 10
In previous version of library we had [SwaggerResponse]
where I could put validation errors into description, but the attribute is not available in newest version. We have [ProducesResponseType]
attribute which doesn't have description parameter.
Upvotes: 0
Views: 2183
Reputation: 483
You can use Swashbuckle.AspNetCore.Filters to specify multiple examples.
c.ExampleFilters()
and services.AddSwaggerExamplesFromAssemblies(Assembly.GetEntryAssembly())
to my Startup.cs
.SwaggerResponse
and SwaggerResponseExample
annotation but I was able to achieve desired result with only using SwaggerResponseExample
.Upvotes: 2