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

Ability for multiple query parameters as template #1794

Closed
boesing opened this issue Jan 2, 2019 · 2 comments
Closed

Ability for multiple query parameters as template #1794

boesing opened this issue Jan 2, 2019 · 2 comments

Comments

@boesing
Copy link

boesing commented Jan 2, 2019

Hey there,

is it possible to declare a set of query parameters which can be re-used in multiple requests?

For example:

paths:
  /foo/bar/baz:
    get:
      parameters:
        - in: query
          name: barbaz
          summary: This is a dedicated query parameter only for /foo/bar/baz
        # Shared
        - in: query
          name: foo
        - in: query
          name: bar
        - in: query
          name: baz
  /qoo/ooq:
    get:
      parameters:
        - in: query
          name: qoo
          summary: This is a dedicated query parameter only for /qoo/ooq
        # Shared
        - in: query
          name: foo
        - in: query
          name: bar
        - in: query
          name: baz

I am thinking about something like:

paths:
  /foo/bar/baz:
    get:
      parameters:
        - in: query
          name: barbaz
          summary: This is a dedicated query parameter only for /foo/bar/baz
          # Shared
        - in: query
          $ref: '#/components/parameters/SharedParameters'
  /qoo/ooq:
    get:
      parameters:
        - in: query
          name: qoo
          summary: This is a dedicated query parameter only for /qoo/ooq
        # Shared
        - in: query
          $ref: '#/components/parameters/SharedParameters'

components:
  parameters:
    SharedParameters:
      schema:
        type: collection
        items: ["foo", "bar", "baz"]
    foo:
      name: foo
      schema:
        type: string
      description: foo description
      summary: foo summary
    bar:
      name: bar
      schema:
        type: string
      description: bar description
      summary: bar summary
    baz:
      name: baz
      schema:
        type: string
      description: baz description
      summary: baz summary

Parameter type collection could be handled as a list of parameters which. But maybe there is another way of sharing query parameters between requests?

@MikeRalphson
Copy link
Member

You can of course use $refs to parameters at the pathItem level, or in the components/parameters object, individually. What you are suggesting is somewhat similar to the idea of traits, as covered by OAI/Overlay-Specification#38, #756, OAI/Overlay-Specification#34

I tried to come up with a strawman proposal in this gist

/cc @darrelmiller as we talked about this recently.

@boesing
Copy link
Author

boesing commented Jan 4, 2019

Yes, that looks quite exactly what I am looking for. 👍

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