I have the following schema doc
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "foo",
"definitions": {
"stuff": {
"type": "object",
"properties": {
"id": {
"description": "the id",
"type": "string"
},
"type": {
"description": "the type",
"type": "string"
}
},
"oneOf": [{
"required": ["id"]
}, {
"required": ["type"]
}],
},
},
"type": "object",
"properties": {
"bar": {
"description": "blah",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/stuff"
}
}
},
"required": ["bar"]
}
and I'm trying to create the flask restx model, but I'm not sure how to model the required OneOf fields?
I think the following will work, but then it ignores the oneof requirement.
stuff_model = (
"Stuff Model",
"id": fields.String(description="the id", required=False),
"type": fields.String(description="the type", required=False)
)
bar_model = (
"Bar Model",
"bar": fields.Nested(stuff_model, required=True)
)