question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Different Styles for Query Parameters

See original GitHub issue

Is it possible to have multiple different styles for query parameters under the same path/operation? This mostly relates to explode. For example, would something like this make sense:

/users?id=3|id=4|id=5&q=1

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
darrelmillercommented, Mar 15, 2018

I hadn’t seen those docs. In my opinion that example is wrong. One of the goals of the changes that were made with OAS 3.0 was to try and make the parameter serialization align as closely as possible with RFC6570 without breaking backward compatibility. The Style concept encapsulates two different things from 6570, the separator and the prefix. Characters like the dot, semi-colon and slash are prefixes and commas are separators in 6570. The explode operator (which is concept taken directly from 6570) causes the prefix and key= to be repeated for each value. It isn’t related to the separator. So, when you mix styles with different prefixes, the serialization is fairly straightforward.

Consider the template:
{/segments*}{;coords*}{?params*}

where segments = [“foo”,“bar”]
coords = {“x”: 2 ,“y”: 3] params = {“sort”: “up”, “view”: “minimal” }

you would get:

/foo/bar;x=2;y=3?sort=up&view=minimal

Now only a subset of 6570 is supported currently in OAS, so you can’t actual represent the above template yet. However, the serialization rules should attempt to follow 6570 where possible. Note that the ? prefix is special in that the first value gets a ? and subsequent ones get an &. You can also use the & prefix where every value gets the & prefix.

For Pipe and Space delimiting, it should play the same role a comma plays in 6570. i.e. it should separate values when they are not exploded. I see no value in introducing more capability that is incompatible with 6570. Ideally, I would like tooling folks to be able to use existing off the shelf 6570 libraries. I see no reason for us to have to reinvent URL construction code.

1reaction
darrelmillercommented, Mar 19, 2018

@dekryptic 2. I said undefined, but I sort of lied. OAS doesn’t explicitly define what to do with objects that are not exploded, but 6570 does and that is what the example shows. See https://tools.ietf.org/html/rfc6570#section-3.2.2 I’m not really sure we want to specify that behavior because it really isn’t very useful.

  1. Welcome to the challenge of 6570. It works pretty well for serialization. It sucks royally for deserialization. It wasn’t intended to work for deserialization. We are at the mercy of URL designers to create URLs that don’t suck.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Correct way to pass multiple values for same parameter name ...
b) Use the ASCI encoding for a comma. c) Use a different character, ;|¦¬ , etc. d) State that a comma cannot be...
Read more >
A Beginner's Guide to URL Parameters - SEMrush
URL parameters are made of a key and a value, separated by an equal sign (=). Multiple parameters are each then separated by...
Read more >
Parameter Serialization - Swagger
Parameter Serialization · style defines how multiple values are delimited. Possible styles depend on the parameter location – path, query, header or cookie....
Read more >
Query Parameters - FastAPI
You can declare multiple path parameters and query parameters at the same ... Here the query parameter needy is a required query parameter...
Read more >
Using parameters - Power Query - Microsoft Learn
Where to use parameters. A parameter can be used in many different ways, but it's more commonly used in two scenarios: Step argument:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found