-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Make the properties with the objects able to be required in certain situations #1664
Comments
Unfortunately, this is a limitation of JSON Schema - there's no real easy way of doing that. |
Related discussions in the OpenAPI Specification repository: |
@jennaprice you need to put the here's what your first two examples would look like: /endpoint
post:
requestBody:
description: Create a Person
required: true
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/person'
required:
- firstName
- lastName
properties:
firstName:
type: string
lastName:
type: string /endpoint
post:
requestBody:
description: Create a Person
required: true
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/person'
required:
- firstName
- lastName |
Closing this; looks like the relevant OpenAPI tickets have this covered. |
I couldn't see how to do this in the documentation, if you have a base object, but in different situations you want to make properties required, you have to rebuild the object.
Expected Behavior
Basically I would like more reusability of Components
Current Behavior
I want to reuse a part of a component and make the properties required in different situations.
in a /create post I will need to require the firstName lastName where as most other calls I will need to require the uuid
So according to the documentation I can overwrite properties, here is what I have tried:
AND
example object:
Possible Solution
If there was a syntax for the required, also as a response object, if I make a field within an required does that indicate that the value of that field in the object will always be present (like uuid for example)
Context
Mostly I find I am writing a creation object and a response body object.
The text was updated successfully, but these errors were encountered: