cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional validation in request body

New Member

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

1 REPLY 1
Highlighted
Moderator

Re: Conditional validation in request body

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.

New Here?
Join us and watch the welcome video:
Join the Online Event to Win
Top Kudoed Authors