diff --git a/.chronus/changes/constant_generated_name-2024-4-22-16-8-23.md b/.chronus/changes/constant_generated_name-2024-4-22-16-8-23.md new file mode 100644 index 0000000000..436f868832 --- /dev/null +++ b/.chronus/changes/constant_generated_name-2024-4-22-16-8-23.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +don't add constant value to generated name \ No newline at end of file diff --git a/packages/typespec-client-generator-core/src/public-utils.ts b/packages/typespec-client-generator-core/src/public-utils.ts index d9a45ebfa7..e5d44246f5 100644 --- a/packages/typespec-client-generator-core/src/public-utils.ts +++ b/packages/typespec-client-generator-core/src/public-utils.ts @@ -27,7 +27,7 @@ import { isStatusCode, } from "@typespec/http"; import { Version, getVersions } from "@typespec/versioning"; -import { capitalCase, pascalCase } from "change-case"; +import { pascalCase } from "change-case"; import pluralize from "pluralize"; import { getClientNameOverride, @@ -551,7 +551,7 @@ function buildNameFromContextPaths( currContextPathType?.kind === "Number" || currContextPathType?.kind === "Boolean" ) { - createName = `${createName}${contextPath[j].displayName}${capitalCase(String(currContextPathType.value))}`; + createName = `${createName}${contextPath[j].displayName}`; } else if (!currContextPathType?.name) { // is anonymous model node createName = `${createName}${contextPath[j].displayName}`; diff --git a/packages/typespec-client-generator-core/test/types.test.ts b/packages/typespec-client-generator-core/test/types.test.ts index d46864c639..4184d66916 100644 --- a/packages/typespec-client-generator-core/test/types.test.ts +++ b/packages/typespec-client-generator-core/test/types.test.ts @@ -2029,7 +2029,7 @@ describe("typespec-client-generator-core: types", () => { strictEqual(sdkType.kind, "constant"); strictEqual(sdkType.valueType.kind, "string"); strictEqual(sdkType.value, "json"); - strictEqual(sdkType.name, "TestPropJson"); + strictEqual(sdkType.name, "TestProp"); strictEqual(sdkType.isGeneratedName, true); }); it("boolean", async function () { @@ -2045,7 +2045,7 @@ describe("typespec-client-generator-core: types", () => { strictEqual(sdkType.kind, "constant"); strictEqual(sdkType.valueType.kind, "boolean"); strictEqual(sdkType.value, true); - strictEqual(sdkType.name, "TestPropTrue"); + strictEqual(sdkType.name, "TestProp"); strictEqual(sdkType.isGeneratedName, true); }); it("number", async function () { @@ -2061,7 +2061,7 @@ describe("typespec-client-generator-core: types", () => { strictEqual(sdkType.kind, "constant"); strictEqual(sdkType.valueType.kind, "int32"); strictEqual(sdkType.value, 4); - strictEqual(sdkType.name, "TestProp4"); + strictEqual(sdkType.name, "TestProp"); strictEqual(sdkType.isGeneratedName, true); }); });