Skip to content

Query parameters objects (like params[variable]=toto, ....) #595

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

Closed
nox-404 opened this issue Mar 10, 2016 · 13 comments
Closed

Query parameters objects (like params[variable]=toto, ....) #595

nox-404 opened this issue Mar 10, 2016 · 13 comments

Comments

@nox-404
Copy link

nox-404 commented Mar 10, 2016

Hi,
I'm gonna be a bit lazy and just post it back here, so here is a question/suggestion/request

Is there a way to describe object parameters like this :

  • filter[name]=a
  • filter[ip]=10.
  • ...

What i got :
Before

What i need :
Before

The field between the brackets should be able to be a select (enum) or an input field

And when one is filled, it should add another one beneath it (and with an enum it should remove or not the selected value (configurable))

I originally posted it there

@whitlockjc
Copy link
Member

I think this is more about tooling support. The OpenAPI specification allows you to describe parameters the way you requested already so nothing needs to change. Since you've already created an issue in swagger-ui (swagger-api/swagger-ui#2027), that's the best course of action.

Since you were already talking to @webron in the swagger-ui issue, I'll let him decide how to handle this issue.

@webron
Copy link
Member

webron commented Mar 11, 2016

If I understand what @nox-404 is asking, that's not really supported by the spec now. Query parameter names are not parameterized and can't be controlled that way. You can define an enum for the values, but not for the name.

What concerns me here is the control on the type of the parameter. So if you have name it'd be a string, but if you have age it'll be an integer? Not sure how we'd represent that elegantly.

@nox-404
Copy link
Author

nox-404 commented Mar 12, 2016

@webron yes that's what i mean, and i don't have any idea on how to describe it yet too

@webron
Copy link
Member

webron commented Mar 14, 2016

Parent: #565

@whitlockjc
Copy link
Member

I don't understand how this can't be done by OpenAPI already. Take a look at apigee-127/swagger-tools#294 and you'll see that people are already doing this, although it's working due to the fact that the query string parsing library supports it. But in the referenced issue, you'll see how some are already doing this and it was a tooling issue to support it.

@webron
Copy link
Member

webron commented Mar 14, 2016

That's a fair point. It could be a display issue only. Tools could have a way to collect filter[*] entries under one roof, though again, there's a problem with the description and the type.

It could also be a convenience issue - instead of having to repeat the same definition for each filter with a fixed name, you can have one with an enum of 'types' for the filter. Not sure this is something we need to support, but it's fair to consider.

@raymondfeng
Copy link
Contributor

We have to workaround the issue today by passing stringified json to complex query parameters, for example:

filter={"where":{"name":"John"}}

@Vanuan
Copy link

Vanuan commented Apr 21, 2016

@raymondfeng How do you define such format?

I tried this in the swagger editor:

      parameters:
        - name: filter
          in: query
          required: false
          schema:
            $ref: '#/definitions/Person'

But it complains that in: query isn't supported for object types:

No enum match for: query

@fehguy
Copy link
Contributor

fehguy commented Apr 21, 2016

@raymondfeng @Vanuan please see here:

#654

For the next spec, you will be allowed complex parameters for all locations. What's left is the serializationStrategy, which is quite different from produces and consumes. If you have thoughts on defining that, it'd be helpful.

@Vanuan
Copy link

Vanuan commented Apr 22, 2016

I don't quite understand what produces and consumes are used for and how are they related to serializationStrategy.

@fehguy
Copy link
Contributor

fehguy commented Feb 1, 2017

See #804

@fehguy fehguy closed this as completed Feb 1, 2017
@itsjavi
Copy link

itsjavi commented Mar 19, 2017

For now, until we have schemas available for all parameters in the 3.0 spec, one option is to use a string like: ?filter=with_pictures(true),ids(1,2,3),location.latitude(51.5033640) this is URL safe (excepting comma, that needs encoding) and it is shorter and simpler than using brackets for sending complex objects via query strings, where we cannot use a body (like on GET requests).

Of course the server should be able to interpret them, but for new APIs I would recommend it.

@ravanscafi
Copy link

is it possible nowadays? i'm a little bit lost

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

8 participants