Generating Swagger for Validation Attributes on Positional Records in ASP.NET

   When building a web API with ASP.NET in most cases I want to generate Swagger (a.k.a. OpenAPI, what a boring name). Since records became a thing in C# I almost exclusively use positional records for my DTOs. I just assumed that Swashbuckle handles everything perfectly. It was pointed out to me that our Swagger does not mark non-nullable properties as required and I then realized that in Swagger just like in JS non-nullable and required were not the same thing. I started digging and I found out that the OpenAPI specs allows for much more information around validation like a regex pattern, min and max value and a couple more that are rarer. So why are these not generated for my project?
Posted by:   Stilgar
15:18 15.07.2024

On C# 11 Features

On C# 11 Features
   Another year another C# version. Of course, the version just released is 12 but I am going to share my impressions of version 11 after using it for a year. As is my new policy I will only share my impression while leaving the explanation of what they do to Microsoft...
Posted by:   Stilgar
02:19 10.12.2023

On C# 10 Features

On C# 10 Features
   Yeah, I know C# 11 was released weeks ago but I have not written about C# 10 yet! I have been working with C# 10 for a year and it is time to share my impressions. Of course I did not use every feature, especially the low-level ones and in these cases I will share my opinion guided by my expectations about how I would feel if I used it. I will not explain what the features do but you can follow along with Microsoft's explanation of the features here...
Posted by:   Stilgar
02:39 28.11.2022

On C# 9.0 Features

On C# 9.0 Features
   I started writing articles listing every newly released C# feature in the 3.0 timeframe. At the time there was not one good place that would post a list of all the features for a new version with explanations how they worked. You could find a list of features and you could find every feature explained separately in some blog post but it was surprisingly hard to find one list with explanation and people who would sometimes do it for one version didn’t do it for the next. Since C# 7.0 this is no longer the case as the official docs have good, detailed lists by version and there was indeed a C# 6 post somewhere on Codeplex that is now lost. I just kept my habit of writing these posts. However, these days I am a little busier and what is more the amount of features and frequency of releases has increased so I can barely write a post about one version before the next one hits. I do still see value in these posts as I include my opinion about a feature. I sometimes go back and check if I use a feature as much as I expected. From now on in these posts I will just link to the official feature explanation and go on with my opinion. When reading this article you can only read the relevant (linked) section from the docs, the other sections will be linked before discussing them...
Posted by:   Stilgar
19:42 25.09.2021

C# 8.0 Features - Part 3 - All the Small Things

C# 8.0 Features - Part 3 - All the Small Things
In part 3 I am going to cover the small additions to the language. Of course small does not mean they are not useful. Some of these improve day to day usage a lot more than things like default interface members...
Posted by:   Stilgar
15:35 12.09.2020
First Previous 1 2 3 4 5 6 7 8 9 10  ... Next Last