[typespec-ts] Query Parameters Encoding Issues for $select, *, and tags=key=value
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
We're migrating App Configuration services to typespec and we're running into issues with query parameters
### Issues
| Raw emitter output without workarounds | Expected URL |
| --- | --- |
| `/kv/sortQueryParams19?%2524select=key&api-version=2023-11-01&label=dev` | `/kv/sortQueryParams19?$select=key&api-version=2023-11-01&label=dev` |
| `/kv?api-version=2023-11-01&key=%2A&label=dev&tags=tag2%3Dvalue2` | `/kv?api-version=2023-11-01&key=*&label=dev&tags=tag2%3Dvalue2` |
1. `$Select` is double-encoded.
In `models.tsp`, we have the query parameters defined [here](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/appconfiguration/data-plane/AppConfiguration/models.tsp#L368-L372) as `$Select`. In the generation, the emitter writes the parameter name `$Select` literally into the URI template in [operations.ts](https://github.com/minhanh-phan/azure-sdk-for-js/blob/72ef4f7942a248629fadf566849f20a12d4cd3e2/sdk/appconfiguration/app-configuration/src/generated/api/operations.ts#L1100-L1106). Then this is passed into [`expandUrlTemplate`](https://github.com/minhanh-phan/azure-sdk-for-js/blob/72ef4f7942a248629fadf566849f20a12d4cd3e2/sdk/appconfiguration/app-configuration/src/generated/static-helpers/urlTemplate.ts#L175) and gets encoded the second time, so it becomes `%2524Select`. The workaround for this is to manually modify the generated `operations.ts` file back to `$Select`.
**Expected behavior**: the URL request should contain `$Select=...`
2. `*` is encoded by default & `tags=tag3=value3` is not encoded if `skipUrlEncoding` is set
App Configuration allows wildcard filter `*`, so we can set `key=*`. When passing through `expandUrlTemplate`, it is now encoded to `key=%2A`.
We found out we can set `skipUrlEncoding` to ensure `*` is not encoded, but then `tags3=value3` will no longer be encoded correctly
**Expected behavior**: the URL request should contain `key=*` & `tags=tag2=value2`
### For more context:
**tsp-location.yaml**
```yaml
directory: specification/appconfiguration/data-plane/AppConfiguration
commit: 4ec78287ae650c72e27c67ae8126f9d58a8254b5
repo: Azure/azure-rest-api-specs
```
- This is the initial generation from the above tsp file: https://github.com/Azure/azure-sdk-for-js/pull/38154/changes/72ef4f7942a248629fadf566849f20a12d4cd3e2
- This is the test that will be failing with no modification: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/appconfiguration/app-configuration/test/public/queryParam.spec.ts
Contributor guide
Assessment
This issue has not been assessed yet.