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

Support explode in Query #1321

Open
7 of 11 tasks
lmazuel opened this issue Aug 7, 2024 · 4 comments
Open
7 of 11 tasks

Support explode in Query #1321

lmazuel opened this issue Aug 7, 2024 · 4 comments

Comments

@lmazuel
Copy link
Member

lmazuel commented Aug 7, 2024

Support of:

@route("/c1/here") op c1(@query(#{ explode: true }) foo: string[]): void;

to mean that the url should explode the query parameter, for instance here foo=a&foo=b if we pass ["a","b"] at the SDK level.

TypeSpec

  1. compiler:core deprecation design:accepted lib:http
    archerzz timotheeguerin

Spec

  1. docs lib:tcgc
    tadelesh

Implementation

  1. lib:tcgc
    tadelesh
  2. tadelesh
  3. weidongxu-microsoft
  4. 0 of 3
    HRLC RLC p0
    MaryGao
  5. DPG DPG/RLC v2.1
    pshao25
  6. tadelesh
@tadelesh
Copy link
Member

tadelesh commented Aug 8, 2024

also this feature could cover the following uri template case:

@route("/action{?name*}") op action(name: string[]): void;

@MaryGao
Copy link
Contributor

MaryGao commented Aug 16, 2024

@lmazuel I want to clarify the scopes for this feature. According to uri temlate design, I think we mainly have below cases.

  • explode: true/false
  • serialized object: array/object/primitive
  • optionality: optional/required

Are they all in scope of this issue?

image

Also there are some legacy cases which are moved from format to encode, we have some cadl-ranch cases to cover array's serliazation, but for object I guest it is not ready yet(at least for JS).

Are all workable cases in scope or only cases of cadl-ranch having in scope?

image

@lmazuel
Copy link
Member Author

lmazuel commented Aug 16, 2024

"explode" just means this:

  • explode: true => a=1&a=2
  • explode: false => a=1,2

This is orthogonale to how you serialize an array, an object, or a primitive. You should already have those scenarios covered, independently of "explode"

As of today, TypeSpec implies CSV (comma separated), it's not in scope to discuss pipe or space. DeepObject is not in scope either.

Optionality or required has nothing to do with the feature (the query parameter can be optional or required, it doesn't impact the value). Explode is about the value, not the optionality or not of the query key.

@lmazuel
Copy link
Member Author

lmazuel commented Aug 20, 2024

Additional note about after a comment I saw on the cadl-ranch PR, if "explode" is used on a non-array parameter, it's just ignored. The way url template RFC is written, given people could use a union like string | string[] and therefore there are scenario when it may be possible that a primitive type is associated with "explode". This is ok, just the explode should be ignored (not a failure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants