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

Add Test in Versioning/Removed #627

Merged
merged 38 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bdd85fe
Update main.tsp
mcgallan Jul 9, 2024
287cbe9
add
mcgallan Jul 9, 2024
5634359
summary
mcgallan Jul 9, 2024
778feed
Merge branch 'main' into 0709-latestversion
mcgallan Jul 11, 2024
4e35e50
Merge branch 'main' into 0709-latestversion
mcgallan Jul 11, 2024
ef473b9
Update main.tsp
mcgallan Jul 15, 2024
6f8d0bc
Update main.tsp
mcgallan Jul 16, 2024
349ef55
Merge branch 'main' into 0709-latestversion
mcgallan Jul 16, 2024
29922c7
Merge branch 'main' into 0709-latestversion
mcgallan Jul 17, 2024
a04bad2
Merge branch 'main' into 0709-latestversion
mcgallan Jul 17, 2024
3e91227
Merge branch 'main' into 0709-latestversion
mcgallan Jul 18, 2024
6cc4e5f
Merge branch 'main' into 0709-latestversion
mcgallan Jul 18, 2024
3c3cf29
Merge branch 'main' into 0709-latestversion
mcgallan Jul 18, 2024
6e0441f
Merge branch 'main' into 0709-latestversion
mcgallan Jul 18, 2024
e3c079b
Merge branch 'main' into 0709-latestversion
mcgallan Jul 30, 2024
ae0be6f
Merge branch 'main' into 0709-latestversion
mcgallan Aug 2, 2024
fd89030
update
mcgallan Aug 5, 2024
080a2b3
Update mockapi.ts
mcgallan Aug 5, 2024
8ce413f
Merge branch 'main' into 0709-latestversion
mcgallan Aug 5, 2024
90d806b
Update main.tsp
mcgallan Aug 26, 2024
b26bce0
Merge remote-tracking branch 'upstream/main' into 0709-latestversion
mcgallan Aug 26, 2024
cde40fb
Update cadl-ranch-summary.md
mcgallan Aug 26, 2024
292e4f6
Merge remote-tracking branch 'upstream/main' into 0709-latestversion
mcgallan Aug 28, 2024
13cf568
update
mcgallan Aug 29, 2024
62d978e
Merge branch '0709-latestversion' of https://github.com/mcgallan/cadl…
mcgallan Aug 29, 2024
85c16f6
fix
mcgallan Aug 29, 2024
38fd04b
fix
mcgallan Aug 29, 2024
8d30891
Merge branch 'main' into 0709-latestversion
mcgallan Aug 30, 2024
d39d451
update
mcgallan Aug 30, 2024
a721e9d
Update mockapi.ts
mcgallan Sep 2, 2024
81e2b7b
update
mcgallan Sep 2, 2024
5b3a103
Update cadl-ranch-summary.md
mcgallan Sep 2, 2024
864ac88
Merge remote-tracking branch 'upstream/main' into 0709-latestversion
mcgallan Sep 24, 2024
f6ca856
update
mcgallan Sep 24, 2024
29eb7a2
Update cadl-ranch-summary.md
mcgallan Sep 24, 2024
5952dec
refine
mcgallan Sep 25, 2024
19b6d7f
Merge branch 'main' into 0709-latestversion
mcgallan Sep 25, 2024
3f1d99b
Update
mcgallan Sep 25, 2024
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: 5 additions & 0 deletions .changeset/pink-crews-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Add a test for the combination of @added and @removed in versioning/removed.
10 changes: 10 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -8360,6 +8360,16 @@ Expected request body:
{ "prop": "foo", "enumProp": "enumMemberV2", "unionProp": "bar" }
```

### Versioning_Removed_v3

- Endpoint: `post /versioning/removed/api-version:{version}/v3`

Expected request body:

```json
{ "id": "123", "type": "foo" }
```

### Versioning_RenamedFrom_NewInterface

- Endpoint: `post /versioning/renamed-from/api-version:{version}/interface/test`
Expand Down
32 changes: 30 additions & 2 deletions packages/cadl-ranch-specs/http/versioning/removed/main.tsp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import "@typespec/http";
import "@azure-tools/cadl-ranch-expect";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";

using TypeSpec.Http;
using TypeSpec.Versioning;
using TypeSpec.Rest;

/**
* Test for the `@removed` decorator.
Expand Down Expand Up @@ -32,12 +34,17 @@ namespace Versioning.Removed;
*/
enum Versions {
/**
* The version v1.
* The original version v1.
*/
v1: "v1",

/**
* The version v2.
* The beta version.
*/
beta: "beta",
mcgallan marked this conversation as resolved.
Show resolved Hide resolved

/**
* The latest version v2.
*/
v2: "v2",
}
Expand Down Expand Up @@ -66,6 +73,14 @@ model ModelV2 {
unionProp: UnionV2;
}

model ModelV3 {
mcgallan marked this conversation as resolved.
Show resolved Hide resolved
id: string;

@removed(Versions.beta)
@added(Versions.v2)
type: string;
}

enum EnumV2 {
@removed(Versions.v2)
enumMemberV1,
Expand Down Expand Up @@ -123,3 +138,16 @@ interface InterfaceV1 {
@route("/v1")
v1InInterface(@body body: ModelV1): ModelV1;
}

/** This operation should be generated with the signatures of both the latest and the original versions, rather than beta version */
@scenario
@scenarioDoc("""

mcgallan marked this conversation as resolved.
Show resolved Hide resolved
Expected request body:
```json
{ "id": "123", "type": "foo" }
```
""")
@post
@route("/v3")
op v3(@body body: ModelV3): ModelV3;
mcgallan marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions packages/cadl-ranch-specs/http/versioning/removed/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ Scenarios.Versioning_Removed_v2 = passOnSuccess(
};
}),
);

Scenarios.Versioning_Removed_v3 = passOnSuccess(
mockapi.post("/versioning/removed/api-version:v3/v3", (req) => {
req.expect.bodyEquals({ id: "123", type: "bar" });
return {
status: 200,
body: json({ id: "123", type: "bar" }),
};
}),
);
Loading