-
-
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
[Required] attribute not applied to generated C# int properties #5111
Comments
The |
@roeldewit The That is why public class Product
{
[Required]
public int Id { get; set; }
} with the the "definitions": {
"Product": {
"type": "object",
"required": [
"Id"
],
"properties": {
"Id": {
"type": "integer",
"format": "int32"
}
}
}
} while public class Product
{
public int Id { get; set; }
} will generate "Product": {
"type": "object",
"properties": {
"Id": {
"type": "integer",
"format": "int32"
}
}
} So why after a simple roundtrip with NSwag from C# class to openapi.json back to C# class is this information lost? E.g. when simply using the generated class in an API that also generates an OpenAPI suddenly the definitions would look different. |
Hi, I also have this issue. I have a two step chain where I generate a C# Client with NSwag and later use the generated models again, making a typescript client for the frontend. I'd like to reuse the same model, but the generated typescript types now do not have the "correct" optionality. It would be great if the generated model would keep the Required attribute! |
Describe the bug
Generating the code for
via (e.g.)
Generates a C# class of
I would have expected for the
Id
property to retain aRequired
attribute as well. Or am I missing something here?Version used
14.2.0
The text was updated successfully, but these errors were encountered: