Forum Discussion

aruna_reddy's avatar
New Member
5 years ago

Conditional validation in request body



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


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.



1 Reply

  • 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.