From b201323d734618fcea63687495d74b8f41fd2b59 Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" <80496810+v-jiaodi@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:31:41 +0800 Subject: [PATCH 1/2] update tspconfig --- .../generated/openapi/openapi.json | 160 +++++++++++++++++ .../generated/typespec-ts/package.json | 167 +----------------- .../typespec-ts/src/api/b/c/index.ts | 45 ----- .../typespec-ts/src/api/b/e/c/index.ts | 45 ----- .../generated/typespec-ts/src/api/b/index.ts | 10 +- .../generated/typespec-ts/src/api/c/index.ts | 78 ++++++++ .../generated/typespec-ts/src/api/d/index.ts | 10 +- .../generated/typespec-ts/src/api/index.ts | 3 + .../typespec-ts/src/classic/b/c/index.ts | 25 --- .../typespec-ts/src/classic/b/e/c/index.ts | 25 --- .../typespec-ts/src/classic/b/e/index.ts | 16 -- .../typespec-ts/src/classic/b/index.ts | 10 +- .../typespec-ts/src/classic/c/index.ts | 28 +++ .../typespec-ts/src/classic/d/index.ts | 5 +- .../typespec-ts/src/classic/index.ts | 4 +- .../generated/typespec-ts/src/fooClient.ts | 6 +- .../generated/typespec-ts/src/index.ts | 11 +- .../generated/typespec-ts/src/models/index.ts | 3 +- .../typespec-ts/src/models/options.ts | 4 +- .../test/hierarchy_generic/tspconfig.yaml | 5 + 20 files changed, 306 insertions(+), 354 deletions(-) create mode 100644 packages/typespec-test/test/hierarchy_generic/generated/openapi/openapi.json delete mode 100644 packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/c/index.ts delete mode 100644 packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/e/c/index.ts create mode 100644 packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/c/index.ts delete mode 100644 packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/c/index.ts delete mode 100644 packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/c/index.ts delete mode 100644 packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/index.ts create mode 100644 packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/c/index.ts diff --git a/packages/typespec-test/test/hierarchy_generic/generated/openapi/openapi.json b/packages/typespec-test/test/hierarchy_generic/generated/openapi/openapi.json new file mode 100644 index 0000000000..d454246259 --- /dev/null +++ b/packages/typespec-test/test/hierarchy_generic/generated/openapi/openapi.json @@ -0,0 +1,160 @@ +{ + "swagger": "2.0", + "info": { + "title": "(title)", + "version": "0000-00-00", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] + }, + "schemes": [ + "https" + ], + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "tags": [], + "paths": { + "/": { + "post": { + "operationId": "Op1", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A" + } + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + } + } + } + }, + "/b": { + "post": { + "operationId": "B_Op1", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/B.A" + } + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + } + } + } + }, + "/b/c": { + "post": { + "operationId": "C_Op1", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/B.A" + } + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + } + } + } + }, + "/b/e": { + "post": { + "operationId": "C_Op1", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/B.E.A" + } + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + } + } + } + }, + "/d": { + "post": { + "operationId": "D_Op1", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A" + } + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + } + } + } + } + }, + "definitions": { + "A": { + "type": "object", + "properties": { + "prop1": { + "type": "string" + } + }, + "required": [ + "prop1" + ] + }, + "B.A": { + "type": "object", + "properties": { + "prop2": { + "type": "string" + } + }, + "required": [ + "prop2" + ] + }, + "B.E.A": { + "type": "object", + "properties": { + "prop3": { + "type": "string" + } + }, + "required": [ + "prop3" + ] + } + }, + "parameters": {} +} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/package.json b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/package.json index 471c679bd7..a28903ac1a 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/package.json +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/package.json @@ -12,40 +12,17 @@ "./package.json": "./package.json", ".": "./src/index.ts", "./api": "./src/api/index.ts", - "./models": "./src/models/index.ts", - "./api/b": "./src/api/b/index.ts", - "./api/b/e/c": "./src/api/b/e/c/index.ts", - "./api/b/c": "./src/api/b/c/index.ts", - "./api/d": "./src/api/d/index.ts" + "./models": "./src/models/index.ts" }, - "dialects": [ - "esm", - "commonjs" - ], - "esmDialects": [ - "browser", - "react-native" - ], + "dialects": ["esm", "commonjs"], + "esmDialects": ["browser", "react-native"], "selfLink": false }, "type": "module", - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], + "keywords": ["node", "azure", "cloud", "typescript", "browser", "isomorphic"], "author": "Microsoft Corporation", "license": "MIT", - "files": [ - "dist", - "README.md", - "LICENSE", - "review/*", - "CHANGELOG.md" - ], + "files": ["dist", "README.md", "LICENSE", "review/*", "CHANGELOG.md"], "dependencies": { "@azure/core-util": "^1.9.2", "@azure-rest/core-client": "^2.1.0", @@ -90,137 +67,5 @@ "test:node": "npm run clean && tshy && npm run unit-test:node && npm run integration-test:node", "test": "npm run clean && tshy && npm run unit-test:node && npm run unit-test:browser && npm run integration-test", "build": "npm run clean && tshy && npm run extract-api" - }, - "exports": { - "./package.json": "./package.json", - ".": { - "browser": { - "types": "./dist/browser/index.d.ts", - "default": "./dist/browser/index.js" - }, - "react-native": { - "types": "./dist/react-native/index.d.ts", - "default": "./dist/react-native/index.js" - }, - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/commonjs/index.d.ts", - "default": "./dist/commonjs/index.js" - } - }, - "./api": { - "browser": { - "types": "./dist/browser/api/index.d.ts", - "default": "./dist/browser/api/index.js" - }, - "react-native": { - "types": "./dist/react-native/api/index.d.ts", - "default": "./dist/react-native/api/index.js" - }, - "import": { - "types": "./dist/esm/api/index.d.ts", - "default": "./dist/esm/api/index.js" - }, - "require": { - "types": "./dist/commonjs/api/index.d.ts", - "default": "./dist/commonjs/api/index.js" - } - }, - "./models": { - "browser": { - "types": "./dist/browser/models/index.d.ts", - "default": "./dist/browser/models/index.js" - }, - "react-native": { - "types": "./dist/react-native/models/index.d.ts", - "default": "./dist/react-native/models/index.js" - }, - "import": { - "types": "./dist/esm/models/index.d.ts", - "default": "./dist/esm/models/index.js" - }, - "require": { - "types": "./dist/commonjs/models/index.d.ts", - "default": "./dist/commonjs/models/index.js" - } - }, - "./api/b": { - "browser": { - "types": "./dist/browser/api/b/index.d.ts", - "default": "./dist/browser/api/b/index.js" - }, - "react-native": { - "types": "./dist/react-native/api/b/index.d.ts", - "default": "./dist/react-native/api/b/index.js" - }, - "import": { - "types": "./dist/esm/api/b/index.d.ts", - "default": "./dist/esm/api/b/index.js" - }, - "require": { - "types": "./dist/commonjs/api/b/index.d.ts", - "default": "./dist/commonjs/api/b/index.js" - } - }, - "./api/b/e/c": { - "browser": { - "types": "./dist/browser/api/b/e/c/index.d.ts", - "default": "./dist/browser/api/b/e/c/index.js" - }, - "react-native": { - "types": "./dist/react-native/api/b/e/c/index.d.ts", - "default": "./dist/react-native/api/b/e/c/index.js" - }, - "import": { - "types": "./dist/esm/api/b/e/c/index.d.ts", - "default": "./dist/esm/api/b/e/c/index.js" - }, - "require": { - "types": "./dist/commonjs/api/b/e/c/index.d.ts", - "default": "./dist/commonjs/api/b/e/c/index.js" - } - }, - "./api/b/c": { - "browser": { - "types": "./dist/browser/api/b/c/index.d.ts", - "default": "./dist/browser/api/b/c/index.js" - }, - "react-native": { - "types": "./dist/react-native/api/b/c/index.d.ts", - "default": "./dist/react-native/api/b/c/index.js" - }, - "import": { - "types": "./dist/esm/api/b/c/index.d.ts", - "default": "./dist/esm/api/b/c/index.js" - }, - "require": { - "types": "./dist/commonjs/api/b/c/index.d.ts", - "default": "./dist/commonjs/api/b/c/index.js" - } - }, - "./api/d": { - "browser": { - "types": "./dist/browser/api/d/index.d.ts", - "default": "./dist/browser/api/d/index.js" - }, - "react-native": { - "types": "./dist/react-native/api/d/index.d.ts", - "default": "./dist/react-native/api/d/index.js" - }, - "import": { - "types": "./dist/esm/api/d/index.d.ts", - "default": "./dist/esm/api/d/index.js" - }, - "require": { - "types": "./dist/commonjs/api/d/index.d.ts", - "default": "./dist/commonjs/api/d/index.js" - } - } - }, - "main": "./dist/commonjs/index.js", - "types": "./dist/commonjs/index.d.ts", - "module": "./dist/esm/index.js" + } } diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/c/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/c/index.ts deleted file mode 100644 index 11bccd9524..0000000000 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/c/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { BA } from "../../../models/models.js"; -import { FooContext as Client } from "../../index.js"; -import { - StreamableMethod, - operationOptionsToRequestParameters, - PathUncheckedResponse, - createRestError, -} from "@azure-rest/core-client"; -import { BCOp1OptionalParams } from "../../../models/options.js"; - -export function _op1Send( - context: Client, - body: BA, - options: BCOp1OptionalParams = { requestOptions: {} }, -): StreamableMethod { - return context - .path("/b/c") - .post({ - ...operationOptionsToRequestParameters(options), - body: { prop2: body["prop2"] }, - }); -} - -export async function _op1Deserialize( - result: PathUncheckedResponse, -): Promise { - const expectedStatuses = ["204"]; - if (!expectedStatuses.includes(result.status)) { - throw createRestError(result); - } - - return; -} - -export async function op1( - context: Client, - body: BA, - options: BCOp1OptionalParams = { requestOptions: {} }, -): Promise { - const result = await _op1Send(context, body, options); - return _op1Deserialize(result); -} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/e/c/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/e/c/index.ts deleted file mode 100644 index ccb5986300..0000000000 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/e/c/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { BEA } from "../../../../models/models.js"; -import { FooContext as Client } from "../../../index.js"; -import { - StreamableMethod, - operationOptionsToRequestParameters, - PathUncheckedResponse, - createRestError, -} from "@azure-rest/core-client"; -import { BECOp1OptionalParams } from "../../../../models/options.js"; - -export function _op1Send( - context: Client, - body: BEA, - options: BECOp1OptionalParams = { requestOptions: {} }, -): StreamableMethod { - return context - .path("/b/e") - .post({ - ...operationOptionsToRequestParameters(options), - body: { prop3: body["prop3"] }, - }); -} - -export async function _op1Deserialize( - result: PathUncheckedResponse, -): Promise { - const expectedStatuses = ["204"]; - if (!expectedStatuses.includes(result.status)) { - throw createRestError(result); - } - - return; -} - -export async function op1( - context: Client, - body: BEA, - options: BECOp1OptionalParams = { requestOptions: {} }, -): Promise { - const result = await _op1Send(context, body, options); - return _op1Deserialize(result); -} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/index.ts index 424e29f195..f90182de6b 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/b/index.ts @@ -11,7 +11,7 @@ import { } from "@azure-rest/core-client"; import { BOp1OptionalParams } from "../../models/options.js"; -export function _op1Send( +export function _bOp1Send( context: Client, body: BA, options: BOp1OptionalParams = { requestOptions: {} }, @@ -24,7 +24,7 @@ export function _op1Send( }); } -export async function _op1Deserialize( +export async function _bOp1Deserialize( result: PathUncheckedResponse, ): Promise { const expectedStatuses = ["204"]; @@ -35,11 +35,11 @@ export async function _op1Deserialize( return; } -export async function op1( +export async function bOp1( context: Client, body: BA, options: BOp1OptionalParams = { requestOptions: {} }, ): Promise { - const result = await _op1Send(context, body, options); - return _op1Deserialize(result); + const result = await _bOp1Send(context, body, options); + return _bOp1Deserialize(result); } diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/c/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/c/index.ts new file mode 100644 index 0000000000..5b32c4017f --- /dev/null +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/c/index.ts @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { BA, BEA } from "../../models/models.js"; +import { FooContext as Client } from "../index.js"; +import { + StreamableMethod, + operationOptionsToRequestParameters, + PathUncheckedResponse, + createRestError, +} from "@azure-rest/core-client"; +import { COp1OptionalParams } from "../../models/options.js"; + +export function _cOp1Send( + context: Client, + body: BEA, + options: COp1OptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path("/b/e") + .post({ + ...operationOptionsToRequestParameters(options), + body: { prop3: body["prop3"] }, + }); +} + +export async function _cOp1Deserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["204"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return; +} + +export async function cOp1( + context: Client, + body: BEA, + options: COp1OptionalParams = { requestOptions: {} }, +): Promise { + const result = await _cOp1Send(context, body, options); + return _cOp1Deserialize(result); +} + +export function _cOp1Send( + context: Client, + body: BA, + options: COp1OptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path("/b/c") + .post({ + ...operationOptionsToRequestParameters(options), + body: { prop2: body["prop2"] }, + }); +} + +export async function _cOp1Deserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["204"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return; +} + +export async function cOp1( + context: Client, + body: BA, + options: COp1OptionalParams = { requestOptions: {} }, +): Promise { + const result = await _cOp1Send(context, body, options); + return _cOp1Deserialize(result); +} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/d/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/d/index.ts index db0448c804..1502a97f0b 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/d/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/d/index.ts @@ -11,7 +11,7 @@ import { } from "@azure-rest/core-client"; import { DOp1OptionalParams } from "../../models/options.js"; -export function _op1Send( +export function _dOp1Send( context: Client, body: A, options: DOp1OptionalParams = { requestOptions: {} }, @@ -24,7 +24,7 @@ export function _op1Send( }); } -export async function _op1Deserialize( +export async function _dOp1Deserialize( result: PathUncheckedResponse, ): Promise { const expectedStatuses = ["204"]; @@ -35,11 +35,11 @@ export async function _op1Deserialize( return; } -export async function op1( +export async function dOp1( context: Client, body: A, options: DOp1OptionalParams = { requestOptions: {} }, ): Promise { - const result = await _op1Send(context, body, options); - return _op1Deserialize(result); + const result = await _dOp1Send(context, body, options); + return _dOp1Deserialize(result); } diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/index.ts index e7070405bd..caf6b380e3 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/api/index.ts @@ -7,3 +7,6 @@ export { FooClientOptionalParams, } from "./fooContext.js"; export { op1 } from "./operations.js"; +export { bOp1 } from "./b/index.js"; +export { cOp1 } from "./c/index.js"; +export { dOp1 } from "./d/index.js"; diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/c/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/c/index.ts deleted file mode 100644 index 1bc96ac420..0000000000 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/c/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { FooContext } from "../../../api/fooContext.js"; -import { BA } from "../../../models/models.js"; -import { op1 } from "../../../api/b/c/index.js"; -import { BCOp1OptionalParams } from "../../../models/options.js"; - -/** Interface representing a BC operations. */ -export interface BCOperations { - op1: (body: BA, options?: BCOp1OptionalParams) => Promise; -} - -export function getBC(context: FooContext) { - return { - op1: (body: BA, options?: BCOp1OptionalParams) => - op1(context, body, options), - }; -} - -export function getBCOperations(context: FooContext): BCOperations { - return { - ...getBC(context), - }; -} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/c/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/c/index.ts deleted file mode 100644 index 3ef8b76f45..0000000000 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/c/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { FooContext } from "../../../../api/fooContext.js"; -import { BEA } from "../../../../models/models.js"; -import { op1 } from "../../../../api/b/e/c/index.js"; -import { BECOp1OptionalParams } from "../../../../models/options.js"; - -/** Interface representing a BEC operations. */ -export interface BECOperations { - op1: (body: BEA, options?: BECOp1OptionalParams) => Promise; -} - -export function getBEC(context: FooContext) { - return { - op1: (body: BEA, options?: BECOp1OptionalParams) => - op1(context, body, options), - }; -} - -export function getBECOperations(context: FooContext): BECOperations { - return { - ...getBEC(context), - }; -} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/index.ts deleted file mode 100644 index f621aa5325..0000000000 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/e/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { FooContext } from "../../../api/fooContext.js"; -import { BECOperations, getBECOperations } from "./c/index.js"; - -/** Interface representing a BE operations. */ -export interface BEOperations { - c: BECOperations; -} - -export function getBEOperations(context: FooContext): BEOperations { - return { - c: getBECOperations(context), - }; -} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/index.ts index a55bbcd711..2f00cc96e5 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/b/index.ts @@ -3,29 +3,23 @@ import { FooContext } from "../../api/fooContext.js"; import { BA } from "../../models/models.js"; -import { op1 } from "../../api/b/index.js"; +import { bOp1 } from "../../api/b/index.js"; import { BOp1OptionalParams } from "../../models/options.js"; -import { BCOperations, getBCOperations } from "./c/index.js"; -import { BEOperations, getBEOperations } from "./e/index.js"; /** Interface representing a B operations. */ export interface BOperations { op1: (body: BA, options?: BOp1OptionalParams) => Promise; - e: BEOperations; - c: BCOperations; } export function getB(context: FooContext) { return { op1: (body: BA, options?: BOp1OptionalParams) => - op1(context, body, options), + bOp1(context, body, options), }; } export function getBOperations(context: FooContext): BOperations { return { ...getB(context), - e: getBEOperations(context), - c: getBCOperations(context), }; } diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/c/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/c/index.ts new file mode 100644 index 0000000000..18b053c810 --- /dev/null +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/c/index.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { FooContext } from "../../api/fooContext.js"; +import { BA, BEA } from "../../models/models.js"; +import { cOp1 } from "../../api/c/index.js"; +import { COp1OptionalParams } from "../../models/options.js"; + +/** Interface representing a C operations. */ +export interface COperations { + op1: (body: BEA, options?: COp1OptionalParams) => Promise; + op1: (body: BA, options?: COp1OptionalParams) => Promise; +} + +export function getC(context: FooContext) { + return { + op1: (body: BEA, options?: COp1OptionalParams) => + cOp1(context, body, options), + op1: (body: BA, options?: COp1OptionalParams) => + cOp1(context, body, options), + }; +} + +export function getCOperations(context: FooContext): COperations { + return { + ...getC(context), + }; +} diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/d/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/d/index.ts index 8456e2c39b..622943ddd3 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/d/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/d/index.ts @@ -3,7 +3,7 @@ import { FooContext } from "../../api/fooContext.js"; import { A } from "../../models/models.js"; -import { op1 } from "../../api/d/index.js"; +import { dOp1 } from "../../api/d/index.js"; import { DOp1OptionalParams } from "../../models/options.js"; /** Interface representing a D operations. */ @@ -13,7 +13,8 @@ export interface DOperations { export function getD(context: FooContext) { return { - op1: (body: A, options?: DOp1OptionalParams) => op1(context, body, options), + op1: (body: A, options?: DOp1OptionalParams) => + dOp1(context, body, options), }; } diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/index.ts index 7a1b8128f5..09ac94c221 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/classic/index.ts @@ -2,7 +2,5 @@ // Licensed under the MIT License. export { BOperations } from "./b/index.js"; +export { COperations } from "./c/index.js"; export { DOperations } from "./d/index.js"; -export { BCOperations } from "./b/c/index.js"; -export { BEOperations } from "./b/e/index.js"; -export { BECOperations } from "./b/e/c/index.js"; diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/fooClient.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/fooClient.ts index 365dee6566..2bfd980602 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/fooClient.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/fooClient.ts @@ -5,6 +5,7 @@ import { Pipeline } from "@azure/core-rest-pipeline"; import { A } from "./models/models.js"; import { Op1OptionalParams } from "./models/options.js"; import { getBOperations, BOperations } from "./classic/b/index.js"; +import { getCOperations, COperations } from "./classic/c/index.js"; import { getDOperations, DOperations } from "./classic/d/index.js"; import { createFoo, @@ -31,10 +32,11 @@ export class FooClient { }); this.pipeline = this._client.pipeline; this.b = getBOperations(this._client); + this.c = getCOperations(this._client); this.d = getDOperations(this._client); } - op1( + _op1( body: A, options: Op1OptionalParams = { requestOptions: {} }, ): Promise { @@ -43,6 +45,8 @@ export class FooClient { /** The operation groups for B */ public readonly b: BOperations; + /** The operation groups for C */ + public readonly c: COperations; /** The operation groups for D */ public readonly d: DOperations; } diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/index.ts index fecc20e53d..71e340d4e1 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/index.ts @@ -8,14 +8,7 @@ export { BEA, Op1OptionalParams, BOp1OptionalParams, - BECOp1OptionalParams, - BCOp1OptionalParams, + COp1OptionalParams, DOp1OptionalParams, } from "./models/index.js"; -export { - BOperations, - DOperations, - BCOperations, - BEOperations, - BECOperations, -} from "./classic/index.js"; +export { BOperations, COperations, DOperations } from "./classic/index.js"; diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/index.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/index.ts index fc2269f93b..d81a322228 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/index.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/index.ts @@ -5,7 +5,6 @@ export { A, BA, BEA } from "./models.js"; export { Op1OptionalParams, BOp1OptionalParams, - BECOp1OptionalParams, - BCOp1OptionalParams, + COp1OptionalParams, DOp1OptionalParams, } from "./options.js"; diff --git a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/options.ts b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/options.ts index 7dfde86d85..6783ad1599 100644 --- a/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/options.ts +++ b/packages/typespec-test/test/hierarchy_generic/generated/typespec-ts/src/models/options.ts @@ -10,10 +10,10 @@ export interface Op1OptionalParams extends OperationOptions {} export interface BOp1OptionalParams extends OperationOptions {} /** Optional parameters. */ -export interface BECOp1OptionalParams extends OperationOptions {} +export interface COp1OptionalParams extends OperationOptions {} /** Optional parameters. */ -export interface BCOp1OptionalParams extends OperationOptions {} +export interface COp1OptionalParams extends OperationOptions {} /** Optional parameters. */ export interface DOp1OptionalParams extends OperationOptions {} diff --git a/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml b/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml index 008c5a7e19..59e3b0f235 100644 --- a/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml +++ b/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml @@ -1,10 +1,15 @@ emit: - "@azure-tools/typespec-ts" + - "@azure-tools/typespec-autorest" options: "@azure-tools/typespec-ts": azureSdkForJs: false isModularLibrary: true + generateMetadata: true + hierarchyClient: false "emitter-output-dir": "{project-root}/generated/typespec-ts" packageDetails: name: "@msinternal/hierarchy-generic" description: "OpenAI" + "@azure-tools/typespec-autorest": + "emitter-output-dir": "{project-root}/generated/openapi" From bb4208ae03b2bea467fdd94dd1c8338a3afcd6d9 Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" <80496810+v-jiaodi@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:59:19 +0800 Subject: [PATCH 2/2] update tspconfig --- packages/typespec-test/test/hierarchy_generic/tspconfig.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml b/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml index 59e3b0f235..f41885daed 100644 --- a/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml +++ b/packages/typespec-test/test/hierarchy_generic/tspconfig.yaml @@ -5,7 +5,7 @@ options: "@azure-tools/typespec-ts": azureSdkForJs: false isModularLibrary: true - generateMetadata: true + enableOperationGroup: true hierarchyClient: false "emitter-output-dir": "{project-root}/generated/typespec-ts" packageDetails: