Category Archives: WEB API

ASP.NET WEB API documentation using Swagger – Global operation for 500 response code

Some api response codes, such as 500 for Internal server error, are the same for all API endpoints. Let’s see how to implement such general behaviour using Swashbuckle. Add below classes: Register new operation filter in SwaggerConfig.cs And after running … Continue reading

Posted in Documentation, WEB API | Tagged , | Leave a comment

ASP.NET WEB API documentation using Swagger – Extend schema generation using SchemaFilters and FluentValidation rules

In this post we will see how to extend schema generation using FluentValidation rules. We will see how to display min/max constraints for Integer type in Swagger UI and how to extend default examples to show valid email for email attribute.To … Continue reading

Posted in ASP.NET, Documentation, WEB API | Tagged , | Leave a comment

ASP.NET Web API documentation using Swagger – Useful links

Some of good additions to Swagger might be quite difficult to find so I put useful links here: Generating model examples: https://mattfrear.com/2015/04/21/generating-swagger-example-responses-with-swashbuckle #1 https://mattfrear.com/2016/01/25/generating-swagger-example-requests-with-swashbuckle #2 https://github.com/mattfrear/Swashbuckle.Examples Using markdown in descriptions: It is possible to render really cool description in Swagger … Continue reading

Posted in Documentation, WEB API | Tagged , | Leave a comment

ASP.NET Web API documentation using Swagger – Use schema mapper for generic data types

If get back to previous post, you could see that descriptions for StartDate and EndDate are duplicated. DateTime description shall be consistent across all API, so to not repeat yourself let’s use MapType feature of Swashbuckle configuration. Open SwaggerConfig and … Continue reading

Posted in Documentation, WEB API | Tagged , | Leave a comment

ASP.NET Web API documentation using Swagger – Add custom headers

In this post, we will look into how to add custom headers to your Swagger documentation using Swashbuckle. We will add well-known “Accept-Language” header with conditionally visibility based on API method! Setup application culture based on Accept-Language header First, add … Continue reading

Posted in Documentation, WEB API | Tagged , | Leave a comment

ASP.NET Web API documentation using Swagger – Introduction

Providing always up-to-date and exhaustive documentation for your WEB API could be quite a challenging task. Swagger and Swashbuckle did a great job to provide uniform documentation for any kind of API. Let’s look into this using simple demo discount API example. … Continue reading

Posted in Documentation, WEB API | Tagged , | Leave a comment