diff --git a/.chronus/changes/fix-set-x-ms-skip-url-encoding-2024-11-26-17-14-53.md b/.chronus/changes/fix-set-x-ms-skip-url-encoding-2024-11-26-17-14-53.md new file mode 100644 index 0000000000..7cf606c5b6 --- /dev/null +++ b/.chronus/changes/fix-set-x-ms-skip-url-encoding-2024-11-26-17-14-53.md @@ -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. diff --git a/packages/rest/src/resource.ts b/packages/rest/src/resource.ts index 13de2131a4..d65d1f3d61 100644 --- a/packages/rest/src/resource.ts +++ b/packages/rest/src/resource.ts @@ -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, {