I have one schema which I want to use for 2 properties:
{
"title": "testschema",
"type": "object",
"additionalProperties": false,
"required": [
"prop2"
],
"properties": {
"prop1": {
"type": "object",
"$ref": "#/components/schemas/commonSchema"
},
"prop2": {
"type": "object",
"$ref": "#/components/schemas/commonSchema"
}
}
}
Now I want that prop2 should be validated for the requiredproperties mentioned in common schema, but prop1 should not. Since this ref schema is shared, I cannot keep the requiredproperties in the commonschema. Is there a way wherein I can add these validations on a ref schema without having them added in it directly?
Also note that I'm dynamically creating this schema in c# so not sure how the conditional required conditions are to be programmed in the schema.Is there a way to sate this condition in commonschema that if its parent schema title=="prop2" then apply the required fields validation