-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can a schema parameter's 'required' attribute be overridden? #1590
Comments
Yes, since https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26 |
Brilliant, thanks! I'll have to read up some more on the possibilities of |
Even if the issue is closed, my question would have the same or similar title, so I decided to append it here. I got a JSON schema which refers to other JSON schemas, which also refer to other JSON schemas and so on... so it's pretty nested. => Now, if I want to override the "required" attribute of one of the nested JSON schemas, would the following structure work, i.e. be valid? "allOf": [
{
"$ref": "offer.json"
},
{
"properties": {
"vehicleOffers": {
"items": {
"properties": {
"vehicles": {
"items": {
"required": [
"options"
]
}
}
}
}
}
}
}
] |
@emvau the schemas in an As for nesting, the 2nd schema under
The reason for all of the ifs is that Note that requiring |
@handrews thanks for the very detailed explanation! Makes all sense to me and happily also confirms the way I tried to solve my problem with. |
just in case someone is looking for a solution to override a schema easily: you can use swagger-cli and mix references MySchema.yaml
src/spec.yaml
The reason for doing this is that it allows to have your schema properties only in a single file instead of dispatching properties everywhere (which make things complicated when adding or removing properties) |
I have a common object defined in
schemas
referenced in a couple of endpoints. However, the specific set of required fields differ between the references. For example, one endpoint requires propertiesfoo
andbar
, while another endpoint requires propertiesfoo
andqux
.Is it possible to override the
required
list when referencing a schema? Is there another fairly DRY way to accomplish this? (The only workaround I can think of is inlining the schema everywhere, which leads to duplication and possibility of inconsistencies.)If it's not possible, could this be implemented?
The text was updated successfully, but these errors were encountered: