diff --git a/.chronus/changes/deprecate-projected-name-2024-1-12-21-5-53.md b/.chronus/changes/deprecate-projected-name-2024-1-12-21-5-53.md new file mode 100644 index 0000000000..2236f0634b --- /dev/null +++ b/.chronus/changes/deprecate-projected-name-2024-1-12-21-5-53.md @@ -0,0 +1,14 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: deprecation +packages: + - "@typespec/compiler" +--- + +Deprecate `@projectedName` decorator. `@encodedName` should be used instead. + +Example: +```diff +-@projectedName("json", "exp") ++@encodedName("application/json", "exp") +``` diff --git a/.chronus/changes/deprecate-projected-name-2024-1-12-21-9-58.md b/.chronus/changes/deprecate-projected-name-2024-1-12-21-9-58.md new file mode 100644 index 0000000000..957a83097d --- /dev/null +++ b/.chronus/changes/deprecate-projected-name-2024-1-12-21-9-58.md @@ -0,0 +1,6 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: internal +packages: + - "@typespec/openapi3" +--- diff --git a/packages/compiler/lib/decorators.tsp b/packages/compiler/lib/decorators.tsp index c40db4f1b2..4e8cf7a5be 100644 --- a/packages/compiler/lib/decorators.tsp +++ b/packages/compiler/lib/decorators.tsp @@ -366,6 +366,7 @@ extern dec overload(target: Operation, overloadbase: Operation); * } * ``` */ +#deprecated "Use `@encodedName` instead for changing the name over the wire." extern dec projectedName( target: unknown, targetName: valueof string, diff --git a/packages/compiler/test/projected-names.test.ts b/packages/compiler/test/projected-names.test.ts index 4ea0bd3304..cf9418fc0a 100644 --- a/packages/compiler/test/projected-names.test.ts +++ b/packages/compiler/test/projected-names.test.ts @@ -13,6 +13,7 @@ describe("compiler: projected-names", () => { it("@projectName updates the name when running projection", async () => { const { expireAt } = (await runner.compile(` model Foo { + #suppress "deprecated" "for testing" @projectedName("json", "exp") @test expireAt: int32; } @@ -24,6 +25,7 @@ describe("compiler: projected-names", () => { it("@projectName doesn't affect a different target", async () => { const { expireAt } = (await runner.compile(` model Foo { + #suppress "deprecated" "for testing" @projectedName("json", "exp") @test expireAt: int32; } @@ -35,6 +37,7 @@ describe("compiler: projected-names", () => { it("can project to different targets", async () => { const { expireAt } = (await runner.compile(` model Foo { + #suppress "deprecated" "for testing" @projectedName("json", "exp") @projectedName("csharp", "ExpireAtCS") @test expireAt: int32; @@ -49,6 +52,7 @@ describe("compiler: projected-names", () => { it("can project a different target on top of a projected one", async () => { const { expireAt } = (await runner.compile(` model Foo { + #suppress "deprecated" "for testing" @projectedName("json", "exp") @projectedName("csharp", "ExpireAtCS") @test expireAt: int32; @@ -93,7 +97,9 @@ describe("compiler: projected-names", () => { it("projectedName overrides a previous renaming", async () => { const { expireAt, renamedProperty } = (await runner.compile(` model Foo { + #suppress "deprecated" "for testing" @projectedName("json", "jsonExpireAt") @test expireAt: int32; + #suppress "deprecated" "for testing" @projectedName("json", "jsonRenamedProperty") @test renamedProperty: string; } diff --git a/packages/openapi3/test/models.test.ts b/packages/openapi3/test/models.test.ts index 27d920de27..d5abc6659b 100644 --- a/packages/openapi3/test/models.test.ts +++ b/packages/openapi3/test/models.test.ts @@ -26,6 +26,7 @@ describe("openapi3: models", () => { const res = await oapiForModel( "Foo", `model Foo { + #suppress "deprecated" "for testing" @projectedName("json", "xJson") x: int32; };` @@ -60,6 +61,7 @@ describe("openapi3: models", () => { const res = await oapiForModel( "Foo", `model Foo { + #suppress "deprecated" "for testing" @encodedName("application/json", "xJson") @projectedName("json", "projectedJson") x: int32;