-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Question: 'required' fields based on context #1562
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
Comments
There is a similar query here. You can use the LoadRequest:
allOf:
- $ref: "#/definitions/Dog"
- required:
- breed
SaveRequest:
allOf:
- $ref: "#/definitions/Dog"
- required:
- breed
- name In essence, In OpenAPI 3.0.x |
In my API definition I'm using allOf and required just as @MikeRalphson suggested. Everything is working great so far, but I have a question about requiring nested properties. Let's say that in the example above, that the breed property is actually another object that has properties for breed_name, size, and breed_origin. How would I be able to specify, using the strategy above, that the nested property breed_name is required? |
The original question in this issue was answered in 2018, subsequent questions if still relevant should be filed as their own issues. |
Hi,
here is the definition of Dog:
there is no required fields.
Now I would like to reference the Dog definition in different contexts and want add/modify required parameters on Dog definition. Something like this:
Main idea is to have one Object definition and many references with different required fields. Is possible to define required field based on reference somehow? Or somehow else? I know that one solution is to define three Dogs :/ - every Dog with different required fields. But it is lot of duplication and in real the object Dog is much more bigger. Any idea?
Thanks
kolisko
The text was updated successfully, but these errors were encountered: