Author Archives: Alexander

ApprovalTests > Customize output file names

By default ApprovalTests generate output file to the same location where test class resides, with the file name as ClassType.MethodName. This behaviour is configured in `UnitTestFrameworkNamer` class, that is default namer for ApprovalTests. Long test names issue Tests are usually … Continue reading

Posted in Unit test | Tagged , | Leave a comment

Generate WinMerge report file on CI server when running Approval tests

In our automation tests projects we rely on Approval tests to assert test output files. It could be for example JSON API responses or XML messages generated by integration services. This approach worked very well for us, in local when … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

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