Skip to content

Commit

Permalink
Fix @path decorator do not accurately reflect the options parameters (
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitzelMendez authored Jan 6, 2025
1 parent 9181b54 commit 5faa336
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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)) {
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

0 comments on commit 5faa336

Please sign in to comment.