From 73a096b408baa9c42d9290f0fa3ffca2472e8671 Mon Sep 17 00:00:00 2001 From: Pan Shao <97225342+pshao25@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:12:21 +0800 Subject: [PATCH] Revert "Add Test in Versioning/Removed" (#737) * Revert "Add Test in Versioning/Removed (#627)" This reverts commit 92f3c4df3e448fce613ddad5c43c6e64577609e9. * update --------- Co-authored-by: Pan Shao --- .changeset/four-kings-think.md | 5 ++ .../cadl-ranch-specs/cadl-ranch-summary.md | 43 ----------- .../http/versioning/removed/main.tsp | 71 +------------------ .../http/versioning/removed/mockapi.ts | 35 +-------- 4 files changed, 9 insertions(+), 145 deletions(-) create mode 100644 .changeset/four-kings-think.md diff --git a/.changeset/four-kings-think.md b/.changeset/four-kings-think.md new file mode 100644 index 00000000..fbeb6ca8 --- /dev/null +++ b/.changeset/four-kings-think.md @@ -0,0 +1,5 @@ +--- +"@azure-tools/cadl-ranch-specs": patch +--- + +Revert the change for version remove diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 57a92762..02deaf5a 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -9109,49 +9109,6 @@ Expected request body: { "prop": "foo" } ``` -### Versioning_Removed_modelV3 - -- Endpoint: `post /versioning/removed/api-version:{version}/v3` - -path: "/versioning/removed/api-version:v1/v3" -Expected request body: - -```json -{ "id": "123", "enumProp": "enumMemberV1" } -``` - -Expected response body: - -```json -{ "id": "123", "enumProp": "enumMemberV1" } -``` - -path: "/versioning/removed/api-version:v2/v3" -Expected request body: - -```json -{ "id": "123", "enumProp": "enumMemberV1" } -``` - -Expected response body: - -```json -{ "id": "123", "enumProp": "enumMemberV1" } -``` - -path: "/versioning/removed/api-version:v2preview/v3" -Expected request body: - -```json -{ "id": "123", "enumProp": "enumMemberV2Preview" } -``` - -Expected response body: - -```json -{ "id": "123", "enumProp": "enumMemberV2Preview" } -``` - ### Versioning_Removed_v2 - Endpoint: `post /versioning/removed/api-version:{version}/v2` diff --git a/packages/cadl-ranch-specs/http/versioning/removed/main.tsp b/packages/cadl-ranch-specs/http/versioning/removed/main.tsp index 0b0d0fd2..858c5bcc 100644 --- a/packages/cadl-ranch-specs/http/versioning/removed/main.tsp +++ b/packages/cadl-ranch-specs/http/versioning/removed/main.tsp @@ -1,11 +1,9 @@ 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. @@ -22,7 +20,7 @@ using TypeSpec.Rest; endpoint: url, /** - * Need to be set as 'v1', 'v2preview' or 'v2' in client. + * Need to be set as 'v1' or 'v2' in client. */ version: Versions, } @@ -34,17 +32,12 @@ namespace Versioning.Removed; */ enum Versions { /** - * The original version v1. + * The version v1. */ v1: "v1", /** - * The V2 Preview version. - */ - v2preview: "v2preview", - - /** - * The latest version v2. + * The version v2. */ v2: "v2", } @@ -73,14 +66,6 @@ model ModelV2 { unionProp: UnionV2; } -model ModelV3 { - id: string; - - @removed(Versions.v2preview) - @added(Versions.v2) - enumProp: EnumV3; -} - enum EnumV2 { @removed(Versions.v2) enumMemberV1, @@ -88,14 +73,6 @@ enum EnumV2 { enumMemberV2, } -enum EnumV3 { - @removed(Versions.v2preview) - @added(Versions.v2) - enumMemberV1, - - enumMemberV2Preview, -} - @removed(Versions.v2) union UnionV1 { string, @@ -146,45 +123,3 @@ 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 preview version */ -@scenario -@scenarioDoc(""" - path: "/versioning/removed/api-version:v1/v3" - Expected request body: - ```json - { "id": "123", "enumProp": "enumMemberV1" } - ``` - - Expected response body: - ```json - { "id": "123", "enumProp": "enumMemberV1" } - ``` - - path: "/versioning/removed/api-version:v2/v3" - Expected request body: - ```json - { "id": "123", "enumProp": "enumMemberV1" } - ``` - - Expected response body: - ```json - { "id": "123", "enumProp": "enumMemberV1" } - ``` - - - path: "/versioning/removed/api-version:v2preview/v3" - Expected request body: - ```json - { "id": "123", "enumProp": "enumMemberV2Preview" } - ``` - - Expected response body: - ```json - { "id": "123", "enumProp": "enumMemberV2Preview" } - ``` - - """) -@post -@route("/v3") -op modelV3(@body body: ModelV3): ModelV3; diff --git a/packages/cadl-ranch-specs/http/versioning/removed/mockapi.ts b/packages/cadl-ranch-specs/http/versioning/removed/mockapi.ts index 4d436924..2118c265 100644 --- a/packages/cadl-ranch-specs/http/versioning/removed/mockapi.ts +++ b/packages/cadl-ranch-specs/http/versioning/removed/mockapi.ts @@ -1,29 +1,8 @@ -import { mockapi, passOnSuccess, json } from "@azure-tools/cadl-ranch-api"; +import { passOnSuccess, mockapi, json } from "@azure-tools/cadl-ranch-api"; import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api"; export const Scenarios: Record = {}; -const pathsAndProperties = [ - { - path: "/versioning/removed/api-version:v1/v3", - expectedBody: { id: "123", enumProp: "enumMemberV1" }, - responseBody: { id: "123", enumProp: "enumMemberV1" }, - status: 200, - }, - { - path: "/versioning/removed/api-version:v2/v3", - expectedBody: { id: "123", enumProp: "enumMemberV1" }, - responseBody: { id: "123", enumProp: "enumMemberV1" }, - status: 200, - }, - { - path: "/versioning/removed/api-version:v2preview/v3", - expectedBody: { id: "123", enumProp: "enumMemberV2Preview" }, - responseBody: { id: "123", enumProp: "enumMemberV2Preview" }, - status: 200, - }, -]; - Scenarios.Versioning_Removed_v2 = passOnSuccess( mockapi.post("/versioning/removed/api-version:v2/v2", (req) => { req.expect.bodyEquals({ prop: "foo", enumProp: "enumMemberV2", unionProp: "bar" }); @@ -33,15 +12,3 @@ Scenarios.Versioning_Removed_v2 = passOnSuccess( }; }), ); - -const mockHandlers = pathsAndProperties.map(({ path, expectedBody, responseBody, status }) => - mockapi.post(path, (req) => { - req.expect.bodyEquals(expectedBody); - return { - status, - body: json(responseBody), - }; - }), -); - -Scenarios.Versioning_Removed_modelV3 = passOnSuccess(mockHandlers);