2

Why does not Swashbuckle generate the required constraint for all the not Nullable value types? Anyway, is it a good idea to do so?

Attila Cseh
  • 235
  • 2
  • 13
  • Possible duplicate of [Indicate required properties of complex input parameter object in Swagger UI](https://stackoverflow.com/questions/41282520/indicate-required-properties-of-complex-input-parameter-object-in-swagger-ui) – Helen Oct 05 '17 at 07:56

1 Answers1

2

By default, Swashbuckle does not mark as required any fields of exposed objects.

To do so, you should just add the RequiredAttribute on properties you need to be required from the Swagger definition file.

Swagger specifications are at start not treating any fields as required by default; from specifications on required:

Determines whether this parameter is mandatory. If the parameter is in "path", this property is required and its value MUST be true. Otherwise, the property MAY be included and its default value is false

Benjamin Soulier
  • 2,223
  • 1
  • 18
  • 30