From 658bccf499d28ccc24e608886a4e1f9b443cfcda Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 22 May 2024 16:06:57 -0400 Subject: [PATCH 1/2] don't add constant value to generated name --- packages/typespec-client-generator-core/src/public-utils.ts | 4 ++-- packages/typespec-client-generator-core/test/types.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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); }); }); From a85f9ea9bc1eae8a49fce71fa18346169d5c4450 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 22 May 2024 16:08:29 -0400 Subject: [PATCH 2/2] add changeset --- .../changes/constant_generated_name-2024-4-22-16-8-23.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/constant_generated_name-2024-4-22-16-8-23.md 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