Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate projected name #2910

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions .chronus/changes/deprecate-projected-name-2024-1-12-21-5-53.md
Original file line number Diff line number Diff line change
@@ -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")
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: internal
packages:
- "@typespec/openapi3"
---
1 change: 1 addition & 0 deletions packages/compiler/lib/decorators.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions packages/compiler/test/projected-names.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/openapi3/test/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe("openapi3: models", () => {
const res = await oapiForModel(
"Foo",
`model Foo {
#suppress "deprecated" "for testing"
@projectedName("json", "xJson")
x: int32;
};`
Expand Down Expand Up @@ -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;
Expand Down
Loading