Skip to content
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

[Question] Use $ref with and override some values #2029

Closed
yaroslawww opened this issue Oct 11, 2019 · 2 comments
Closed

[Question] Use $ref with and override some values #2029

yaroslawww opened this issue Oct 11, 2019 · 2 comments

Comments

@yaroslawww
Copy link

Often, when creating an entity, some parameters are required, but when updating, these parameters are optional. Is it possible to inherit from a parameter and change its data?

Now it works like this:

openapi: 3.0.0
info:
  title: Example
  version: 1.0.0 
components:
  parameters:
    name: 
      in: query
      name: name
      required: false
      schema:
        type: string
      description: User name
    name_required: 
      in: query
      name: name
      required: true
      schema:
        type: string
      description: User name

paths:
  /contact:
    post:
      summary: Create contact.
      parameters:
        - $ref: '#/components/parameters/name_required'
      responses:
        '201':
          description: Created
    put:
      summary: Update contact.
      parameters:
        - $ref: '#/components/parameters/name'
      responses:
        '200':
          description: OK

But I want it so that you can just overwrite the data, for example like this:

openapi: 3.0.0
info:
  title: Example
  version: 1.0.0 
components:
  parameters:
    name: 
      in: query
      name: name
      required: false
      schema:
        type: string
      description: User name

paths:
  /contact:
    post:
      summary: Create contact.
      parameters:
        - $ref: '#/components/parameters/name'
          required: true
      responses:
        '201':
          description: Created
    put:
      summary: Update contact.
      parameters:
        - $ref: '#/components/parameters/name'
      responses:
        '200':
          description: OK

Perhaps there are ideas how to implement this? Or are there other ways not to duplicate the code?

@yaroslawww
Copy link
Author

Duplicate of #2026

@MikeRalphson
Copy link
Member

Closing as a duplicate, thanks for identifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants