-
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
Example of Parameters object reuse #1029
Comments
Reusing any component, regardless of type (header, parameter, response, ...) is the same so if you've seen one example, you've seen them all. The way this works is you define the object in I'm not saying we shouldn't have an example, just wanting to help you figure this out now instead of waiting on a change. |
Thanks. I understood how the $ref is expressed as there's plenty of examples. What I specifically wanted to know was when you implement the reuse in an parameter object. Is it like this? get:
parameters:
- $ref: #/components/parameters/person
- in: query
name: another_random_parameter
type: string Cheers |
Yes, that's exactly right. |
Sweet. Thanks! |
No problem. I'll keep this open to let the suggestion of having an explicit |
IS this the right place to ask about overrides of references? In the example above, person may be defined in: body, but I would like to to re-use it in: formData without defining multiple objects. The second declaration is discarded it it is in the reference. IF so, this would need to be documented, as it is the one I most frequently bump into stopping real re-use of parameters. |
What you want to do isn't possible with one parameter definition because you can't use a reference and then override/replace/merge properties into it. Due to OAI not allowing JSON References everywhere, you will have some duplication somewhere. There are a few different ways to approach this, each with its own level of duplication. Below is one example: components:
schemas:
Person:
type: object
properties:
name:
type: string
age:
type: integer
parameters:
FormPerson:
name: person
in: formData
schema:
$ref: '#/components/schemas/Person'
BodyPerson:
name: person
in: body
schema:
$ref: '#/components/schemas/Person' There are multiple ways to do reuse to help with this. |
Ah, I am only used to OAI2 spec without the standardised component section. Your form is indeed more lightweight, but only in OAI3. Good to know this is being addressed in the roadmap, thanks. |
You could do the same with 2.0, just using |
The request to override parameter fields is being tracked as #2026. This issue is only for tracking the originally requested example. |
Given that we haven't seen more complaints about this, and the confusion was likely due to changes from the 2.0 timeframe, I'm going to close this. We can't add an example of every possible use of |
Hello. I can't find an example in the draft specification of Parameters object reuse i.e. when encapsulated by a Component object.
Suggest one is added to the draft specification for clarity and ease-of-use.
Apologies if there's already an issue open for this.
The text was updated successfully, but these errors were encountered: