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

Fix @path decorator do not accurately reflect the options parameters #5455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/rest"
---

In some scenarios, the options for the `@path` decorator do not accurately reflect the provided parameters, including the `#{allowReserved: true}` which is the `x-ms-skip-url-encoding` option. This change addresses and fixes this issue.
11 changes: 7 additions & 4 deletions packages/rest/src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,19 @@ function cloneKeyProperties(context: DecoratorContext, target: Model, resourceTy
// filtering. NOTE: Check for name equality instead of function equality
// to deal with multiple copies of core being used.
...keyProperty.decorators.filter((d) => d.decorator.name !== $visibility.name),
{
decorator: $path,
args: [],
},
{
decorator: $resourceTypeForKeyParam,
args: [{ node: target.node, value: resourceType, jsValue: resourceType }],
},
];

if (!keyProperty.decorators.some((d) => d.decorator.name === $path.name)) {
AlitzelMendez marked this conversation as resolved.
Show resolved Hide resolved
AlitzelMendez marked this conversation as resolved.
Show resolved Hide resolved
decorators.push({
decorator: $path,
args: [],
});
}

// Clone the key property and ensure that an optional key property doesn't
// become an optional path parameter
const newProp = program.checker.cloneType(keyProperty, {
Expand Down
Loading