Forum Discussion

aruna_reddy's avatar
aruna_reddy
New Member
6 years ago

Conditional validation in request body

Hi,

 

I have a post method which takes request body ((Dynamic) List of maps). I am trying to work on validations within the request body like 

if key1's value > 1 then key2, key3 are mandatory

or 

if key4 is provided, key5 cannot be empty

 

The list of maps is dynamic and not predefined. Is there something in openapi which helps in solving above scenario.

Any help is really appreciated.

Thanks,

Aruna

  • Schema validation is based on JSON Schema, which doesn't have direct support for conditional validation. You may be able to describe some use cases, but the fine control of allowing some/all/one of them is going to be extremely verbose and difficult to maintain.