-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support the required keyword in the same way as RequiredAttribute #2764
Comments
+1 this is causing a lot of problem in API communication with frontend team members |
This functionality has been implemented in DotSwashbuckle v3.0.1 |
Why did you do this? Required-keyword in C# has nothing to do with nullability. It is there to enforce initialization of properties in constructor or constructor-initializers. It is perfectly fine in C# to declare a property as a required nullable int like this: |
See #2879. |
When using .NETs required keyword, the properties that it is used on do not get marked as required in SwaggerGen. I set up a project to reproduce the issue. When adding the RequiredAttribute to the property, the result changes to the expected behavior.
I assume that this line could fix the problem if it checked for
RequiredMemberAttribute
too.Thank you for investigating!
Version: 6.5.0
C# 11/.NET 7 and up
SwashbuckleReproduction.zip
The text was updated successfully, but these errors were encountered: