You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sending a POST request to create items; however, the submission options tend to vary based on the reportType property. Since I stopped using Joi and switched to express-openapi-validator, could you help me validate if reportType = "item1" then the requestBody must match item1.requestBody?
Actually, when the data matches a schema, it does validate the type. However, if I try to send:
{
reportType: "item1"
}
The request goes through without any issues since it does not match any requestBody. Has anyone encountered a similar problem where the input type to validate depends on a property? If so, what would you recommend?
UPDATE:
I have added a discriminator and it still didn't work.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am sending a POST request to create items; however, the submission options tend to vary based on the reportType property. Since I stopped using
Joi
and switched toexpress-openapi-validator
, could you help me validate ifreportType = "item1"
then the requestBody must matchitem1.requestBody
?Request Body:
item1.requestBody.yaml
:item2.requestBody.yaml
:Actually, when the data matches a schema, it does validate the type. However, if I try to send:
The request goes through without any issues since it does not match any requestBody. Has anyone encountered a similar problem where the input type to validate depends on a property? If so, what would you recommend?
UPDATE:
I have added a discriminator and it still didn't work.
Beta Was this translation helpful? Give feedback.
All reactions