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

What to do if a request contains same parameter multiple times? #837

Open
jratike80 opened this issue Jun 11, 2023 · 1 comment
Open

What to do if a request contains same parameter multiple times? #837

jratike80 opened this issue Jun 11, 2023 · 1 comment
Labels
Part 1: Core Issue related to Part 1 - Core question

Comments

@jratike80
Copy link
Contributor

I ask because I saw this MapServer discussion in GitHub MapServer/MapServer#6893 (comment) about what to do if a request happens to contain for example &crs= or &bbox-crs= many times

@rouault commented

I've had a bit of trouble to figure out what we should do in that situation, but I believe the answer comes indirectly from the fact that the OpenApi query parameters defined in the OGC API spec use "style: form" and "explode: false". Looking at https://swagger.io/docs/specification/serialization/, it means that if "foo=bar&foo=baz" was synthetized, then foo should be interpreted as an array [bar, baz] which doesn't make sense for the requests we are interested in.

The question is relevant to core as well. By some tests made against PyGeoAPI demo site this server picks the first key-value pair and discards the next ones.

This returns a feature with gid=15
https://demo.pygeoapi.io/stable/collections/ogr_gpkg_poi/items?gid=15&gid=24
This returns a feature with gid=24
https://demo.pygeoapi.io/stable/collections/ogr_gpkg_poi/items?gid=24&gid=15
This does not find anything because feature with gid=16 does not exist
https://demo.pygeoapi.io/stable/collections/ogr_gpkg_poi/items?gid=16&gid=15

@cportele cportele added question Part 1: Core Issue related to Part 1 - Core labels Jun 19, 2023
@cportele cportele added this to Backlog in Part 1: Core via automation Jun 19, 2023
@cportele
Copy link
Member

As pointed out by Even, the behavior will depend on the style and explode values.

If style is form and explode is true for a custom query parameter, then foo=bar&foo=baz is mapped to an array [ 'bar', 'baz' ] for foo.

If explode is false, which is used for all query parameters in the standards, then AFAIK there are no provisions in OpenAPI or any other standard how to handle this. The server could throw an error or pick a value (which is what pygeoapi seems to do).

If clients are expected to submit foo=bar&foo=baz, then you should set explode to false. Or use explode as false and submit foo=bar,baz. This is what is done, e.g., with the bbox parameter. Note that multiple values for a parameter imply that the type is array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Part 1: Core Issue related to Part 1 - Core question
Projects
Part 1: Core
  
Backlog
Development

No branches or pull requests

2 participants