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

can a parameter be used both for query and path? #965

Closed
seralf opened this issue Mar 6, 2017 · 3 comments
Closed

can a parameter be used both for query and path? #965

seralf opened this issue Mar 6, 2017 · 3 comments

Comments

@seralf
Copy link

seralf commented Mar 6, 2017

Hi, I'm trying to organize better my parameter definition.

Given two paths:

/example/{project}/api

/example/api?project={project}

I wonder if it's possible to maintain a single re-usable definition for a parameter wich can be used either as path parameter or query parameter.

My problem is that I have multiple endpoints which re-use the same parameters, and sometimes both the structures are present! Since the general definition is helpful (it allows me to define default values which can be used to suggest meaningful examples to test), I'd like to avoid a twin definition just to specify the type of a parameter...

at the moment I have something like:

...
parameters:
  project_path:
    name: project
    in: path
    type: string
    description: name of a project
    required: true
    default: my example project
  project_query:
    name: project
    in: query
    type: string
    description: name of a project
    required: true
    default: my example project

and I wish I'd have something like:

...
parameters:
  project_path:
    name: project
    in: 
     - path
     - query
    type: string
    description: name of a project
    required: true
    default: my example project

thanks in advance for any suggestion

@seralf seralf changed the title can a parameter be both for query and path? can a parameter be used both for query and path? Mar 6, 2017
@ePaul
Copy link
Contributor

ePaul commented Mar 6, 2017

With OpenAPI 2.0 or OpenAPI 3.0 this is not possible.

I also don't think this would work for required parameters like in your example ... it can only be a path parameter in the first path, and only be a query parameter in the second path.

I could imaging having the same definition for a form and query parameter (or possibly also header parameter, though there I would imagine a different name).

@webron
Copy link
Member

webron commented Mar 6, 2017

It's not possible. Check out #213, #123, #164.

@webron webron closed this as completed Mar 6, 2017
@seralf
Copy link
Author

seralf commented Mar 6, 2017 via email

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

3 participants