If I have a property:
public int? Test { get; set; }
The correspoding swagger defination is:
test integer($int32)
nullable: true
However, when I add [Required]
attribute to it:
[Required]
public int? Test { get; set; }
My swagger defination is:
test* integer($int32)
Why is it no longer nullable?
The [Reqiured]
attribute you are using forces the value, to not be null
.
According to the documentation:
The RequiredAttribute attribute specifies that when a field on a form is validated, the field must contain a value. A validation exception is raised if the property is null, contains an empty string (""), or contains only white-space characters.