Skip to content
Draft
Changes from 1 commit
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
5 changes: 2 additions & 3 deletions packages/typespec-ts/src/modular/buildClientContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ export function buildClientContext(
: [];
const apiVersionInEndpoint =
templateArguments && templateArguments.find((p) => p.isApiVersionParam);
const parameterName = getClientParameterName(apiVersionParam);
if (!apiVersionInEndpoint && apiVersionParam.clientDefaultValue) {
apiVersionPolicyStatement += `const ${parameterName} = options.${parameterName} ?? "${apiVersionParam.clientDefaultValue}";`;
apiVersionPolicyStatement += `const apiVersion = options.apiVersion ?? "${apiVersionParam.clientDefaultValue}";`;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a version definition can make the code work properly.

}

if (apiVersionParam.kind === "method") {
Expand All @@ -211,7 +210,7 @@ export function buildClientContext(
if (!url.searchParams.get("api-version")) {
req.url = \`\${req.url}\${
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
}api-version=\${${parameterName}}\`;
}api-version=\${${getClientParameterName(apiVersionParam)}}\`;
}

return next(req);
Expand Down