0

I need to show in Swagger "nullable: true" where one field of request body is nullable and required conditionally.

I've tried following annotation. but doesn't help

[RequiredIfAttribute( "IdentificationType", IdentificationType.GROUP_MEMBER )]
[JsonProperty( Required = Required.AllowNull )]
public Title? PassengerTitle

Title is enum, RequiredIfAttribute is custom attribute.

I also tried to create SchemaFilter based on ISchemaFilter also don't know where to add get the hint there

Hier is a sample screen what I mean

enter image description here

Emin Hasanov
  • 1,299
  • 1
  • 13
  • 29
  • 1
    OpenAPI doesn't support conditionally required parameters. The correct way is to use polymorphism where one variant has the field as mandatory and the other doesn't have the field at all. – Agent_L Oct 12 '21 at 10:07
  • Where did you get that example? the idea will be to look at the generated json on that and see where that is coming from, then we can craft that into the SchemaFilter – Helder Sepulveda Nov 24 '21 at 23:41

0 Answers0