@azure-tools/typespec-ts 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/operation/build/all.log +1 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/package-deps_build.json +205 -190
- package/.rush/temp/shrinkwrap-deps.json +488 -471
- package/CHANGELOG.md +7 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/modelUtils.d.ts +1 -1
- package/dist/src/modelUtils.d.ts.map +1 -1
- package/dist/src/modelUtils.js +79 -56
- package/dist/src/modelUtils.js.map +1 -1
- package/dist/src/operationUtil.d.ts +26 -0
- package/dist/src/operationUtil.d.ts.map +1 -1
- package/dist/src/operationUtil.js +76 -17
- package/dist/src/operationUtil.js.map +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +9 -6
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +3 -3
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts +6 -0
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -0
- package/dist/src/transform/{transformAnnotationDetails.js → transformHelperFunctionDetails.js} +2 -2
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -0
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +41 -33
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +20 -12
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +29 -8
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.js +1 -1
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -38
- package/src/index.ts +2 -0
- package/src/modelUtils.ts +143 -47
- package/src/operationUtil.ts +111 -22
- package/src/transform/transform.ts +20 -5
- package/src/transform/transformApiVersionInfo.ts +18 -3
- package/src/transform/{transformAnnotationDetails.ts → transformHelperFunctionDetails.ts} +3 -3
- package/src/transform/transformParameters.ts +71 -20
- package/src/transform/transformPaths.ts +30 -15
- package/src/transform/transformResponses.ts +50 -6
- package/src/transform/transformSchemas.ts +1 -1
- package/test/commands/cadl-ranch-list.ts +25 -28
- package/test/commands/gen-cadl-ranch.ts +6 -2
- package/test/integration/arrayItemTypes.spec.ts +2 -2
- package/test/integration/azurecore.spec.ts +64 -24
- package/test/integration/collectionFormat.spec.ts +44 -0
- package/test/integration/dictionary.spec.ts +2 -2
- package/test/integration/extensibleEnums.spec.ts +8 -8
- package/test/integration/fixedEnums.spec.ts +7 -7
- package/test/integration/generated/arrays/itemTypes/src/arrayItemTypesClient.ts +5 -1
- package/test/integration/generated/arrays/itemTypes/src/clientDefinitions.ts +20 -20
- package/test/integration/generated/arrays/itemTypes/src/logger.ts +5 -0
- package/test/integration/generated/authentication/apiKey/package.json +1 -1
- package/test/integration/generated/authentication/apiKey/src/authApiKeyClient.ts +6 -2
- package/test/integration/generated/authentication/apiKey/src/logger.ts +5 -0
- package/test/integration/generated/authentication/oauth2/src/authOauth2Client.ts +6 -2
- package/test/integration/generated/authentication/oauth2/src/logger.ts +5 -0
- package/test/integration/generated/authentication/union/src/authUnionClient.ts +6 -2
- package/test/integration/generated/authentication/union/src/logger.ts +5 -0
- package/test/integration/generated/azure/core/package.json +1 -1
- package/test/integration/generated/azure/core/src/azureCoreClient.ts +5 -1
- package/test/integration/generated/azure/core/src/clientDefinitions.ts +22 -8
- package/test/integration/generated/azure/core/src/isUnexpected.ts +18 -7
- package/test/integration/generated/azure/core/src/logger.ts +5 -0
- package/test/integration/generated/azure/core/src/outputModels.ts +7 -0
- package/test/integration/generated/azure/core/src/paginateHelper.ts +55 -5
- package/test/integration/generated/azure/core/src/parameters.ts +1 -0
- package/test/integration/generated/azure/core/src/responses.ts +23 -1
- package/test/integration/generated/azure/core-traits/package.json +1 -1
- package/test/integration/generated/azure/core-traits/src/azureCoreTraitsClient.ts +5 -1
- package/test/integration/generated/azure/core-traits/src/clientDefinitions.ts +7 -25
- package/test/integration/generated/azure/core-traits/src/isUnexpected.ts +6 -19
- package/test/integration/generated/azure/core-traits/src/logger.ts +5 -0
- package/test/integration/generated/azure/core-traits/src/outputModels.ts +15 -0
- package/test/integration/generated/azure/core-traits/src/parameters.ts +4 -19
- package/test/integration/generated/azure/core-traits/src/responses.ts +6 -30
- package/test/integration/generated/dictionary/package.json +1 -1
- package/test/integration/generated/dictionary/src/clientDefinitions.ts +22 -22
- package/test/integration/generated/dictionary/src/dictClient.ts +5 -1
- package/test/integration/generated/dictionary/src/logger.ts +5 -0
- package/test/integration/generated/enums/extensible/README.md +3 -3
- package/test/integration/generated/enums/extensible/package.json +1 -1
- package/test/integration/generated/enums/extensible/src/clientDefinitions.ts +5 -5
- package/test/integration/generated/enums/extensible/src/index.ts +3 -3
- package/test/integration/generated/enums/extensible/src/logger.ts +5 -0
- package/test/integration/generated/enums/extensible/src/{enumsExtensible.ts → typeEnumExtensible.ts} +9 -5
- package/test/integration/generated/enums/fixed/README.md +3 -3
- package/test/integration/generated/enums/fixed/package.json +1 -1
- package/test/integration/generated/enums/fixed/src/clientDefinitions.ts +5 -5
- package/test/integration/generated/enums/fixed/src/index.ts +3 -3
- package/test/integration/generated/enums/fixed/src/logger.ts +5 -0
- package/test/integration/generated/enums/fixed/src/{enumsFixed.ts → typeEnumFixed.ts} +9 -5
- package/test/integration/generated/internal/src/clientDefinitions.ts +38 -12
- package/test/integration/generated/internal/src/index.ts +0 -1
- package/test/integration/generated/internal/src/internalClient.ts +5 -1
- package/test/integration/generated/internal/src/logger.ts +5 -0
- package/test/integration/generated/internal/src/outputModels.ts +9 -5
- package/test/integration/generated/internal/src/parameters.ts +32 -8
- package/test/integration/generated/internal/src/responses.ts +18 -5
- package/test/integration/generated/lro/lroCore/README.md +3 -3
- package/test/integration/generated/lro/lroCore/package.json +2 -2
- package/test/integration/generated/lro/lroCore/src/clientDefinitions.ts +8 -5
- package/test/integration/generated/lro/lroCore/src/index.ts +3 -3
- package/test/integration/generated/lro/lroCore/src/isUnexpected.ts +14 -7
- package/test/integration/generated/lro/lroCore/src/logger.ts +5 -0
- package/test/integration/generated/lro/lroCore/src/pollingHelper.ts +38 -0
- package/test/integration/generated/lro/lroCore/src/responses.ts +18 -0
- package/test/integration/generated/lro/lroCore/src/{azureLroCore.ts → specsAzureCoreLroStandard.ts} +9 -5
- package/test/integration/generated/lro/{lroBasic → lroRPC}/README.md +7 -7
- package/test/integration/generated/lro/{lroBasic → lroRPC}/api-extractor.json +1 -1
- package/test/integration/generated/lro/{lroBasic → lroRPC}/package.json +6 -6
- package/test/integration/generated/lro/lroRPC/src/clientDefinitions.ts +79 -0
- package/test/integration/generated/{resiliency/devDriven → lro/lroRPC}/src/index.ts +4 -4
- package/test/integration/generated/{resiliency/devDriven → lro/lroRPC}/src/isUnexpected.ts +57 -21
- package/test/integration/generated/lro/lroRPC/src/logger.ts +5 -0
- package/test/integration/generated/lro/lroRPC/src/models.ts +8 -0
- package/test/integration/generated/lro/lroRPC/src/outputModels.ts +40 -0
- package/test/integration/generated/lro/lroRPC/src/parameters.ts +20 -0
- package/test/integration/generated/lro/{lroBasic → lroRPC}/src/pollingHelper.ts +52 -0
- package/test/integration/generated/lro/lroRPC/src/responses.ts +124 -0
- package/test/integration/generated/lro/lroRPC/src/specsAzureCoreLroRpc.ts +35 -0
- package/test/integration/generated/lro/{lroBasic → lroRPC}/tspconfig.yaml +2 -2
- package/test/integration/generated/models/inheritance/README.md +3 -3
- package/test/integration/generated/models/inheritance/package.json +1 -1
- package/test/integration/generated/models/inheritance/src/clientDefinitions.ts +13 -11
- package/test/integration/generated/models/inheritance/src/index.ts +3 -3
- package/test/integration/generated/models/inheritance/src/logger.ts +5 -0
- package/test/integration/generated/models/inheritance/src/{modelsInheritance.ts → typeModelInheritance.ts} +9 -5
- package/test/integration/generated/models/propertyNullable/README.md +3 -3
- package/test/integration/generated/models/propertyNullable/package.json +1 -1
- package/test/integration/generated/models/propertyNullable/src/clientDefinitions.ts +43 -43
- package/test/integration/generated/models/propertyNullable/src/index.ts +3 -3
- package/test/integration/generated/models/propertyNullable/src/logger.ts +5 -0
- package/test/integration/generated/models/propertyNullable/src/parameters.ts +14 -12
- package/test/integration/generated/models/propertyNullable/src/responses.ts +4 -4
- package/test/integration/generated/models/propertyNullable/src/{modelsPropertyNullable.ts → typePropertyNullable.ts} +9 -5
- package/test/integration/generated/models/propertyOptional/README.md +3 -3
- package/test/integration/generated/models/propertyOptional/package.json +1 -1
- package/test/integration/generated/models/propertyOptional/src/clientDefinitions.ts +47 -47
- package/test/integration/generated/models/propertyOptional/src/index.ts +3 -3
- package/test/integration/generated/models/propertyOptional/src/logger.ts +5 -0
- package/test/integration/generated/models/propertyOptional/src/parameters.ts +7 -6
- package/test/integration/generated/models/propertyOptional/src/responses.ts +4 -4
- package/test/integration/generated/models/propertyOptional/src/{modelsPropertyOptional.ts → typePropertyOptional.ts} +9 -5
- package/test/integration/generated/models/propertyTypes/README.md +3 -3
- package/test/integration/generated/models/propertyTypes/package.json +1 -1
- package/test/integration/generated/models/propertyTypes/src/clientDefinitions.ts +123 -47
- package/test/integration/generated/models/propertyTypes/src/index.ts +3 -3
- package/test/integration/generated/models/propertyTypes/src/logger.ts +5 -0
- package/test/integration/generated/models/propertyTypes/src/models.ts +24 -0
- package/test/integration/generated/models/propertyTypes/src/outputModels.ts +24 -0
- package/test/integration/generated/models/propertyTypes/src/parameters.ts +48 -6
- package/test/integration/generated/models/propertyTypes/src/responses.ts +52 -4
- package/test/integration/generated/models/propertyTypes/src/{modelsPropertyTypes.ts → typePropertyValueTypes.ts} +9 -5
- package/test/integration/generated/models/usage/README.md +3 -3
- package/test/integration/generated/models/usage/package.json +1 -1
- package/test/integration/generated/models/usage/src/clientDefinitions.ts +7 -7
- package/test/integration/generated/models/usage/src/index.ts +3 -3
- package/test/integration/generated/models/usage/src/logger.ts +5 -0
- package/test/integration/generated/models/usage/src/{modelsUsage.ts → typeModelUsage.ts} +9 -5
- package/test/integration/generated/models/visibility/README.md +3 -3
- package/test/integration/generated/models/visibility/package.json +1 -1
- package/test/integration/generated/models/visibility/src/clientDefinitions.ts +3 -3
- package/test/integration/generated/models/visibility/src/index.ts +3 -3
- package/test/integration/generated/models/visibility/src/logger.ts +5 -0
- package/test/integration/generated/models/visibility/src/{modelsVisibilityAutomatic.ts → typeModelVisibility.ts} +9 -5
- package/test/integration/generated/parameters/collection-format/src/clientDefinitions.ts +24 -0
- package/test/integration/generated/parameters/collection-format/src/collectionFormatClient.ts +5 -1
- package/test/integration/generated/parameters/collection-format/src/logger.ts +5 -0
- package/test/integration/generated/parameters/collection-format/src/parameters.ts +33 -0
- package/test/integration/generated/parameters/collection-format/src/responses.ts +15 -0
- package/test/integration/generated/parameters/collection-format/src/serializeHelper.ts +12 -0
- package/test/integration/generated/parameters/spread/src/clientDefinitions.ts +61 -0
- package/test/integration/generated/{lro/lroBasic → parameters/spread}/src/index.ts +4 -5
- package/test/integration/generated/parameters/spread/src/logger.ts +5 -0
- package/test/integration/generated/{lro/lroBasic/src/outputModels.ts → parameters/spread/src/models.ts} +2 -3
- package/test/integration/generated/parameters/spread/src/parameters.ts +61 -0
- package/test/integration/generated/{lro/lroBasic/src/azureLro.ts → parameters/spread/src/parametersSpread.ts} +10 -6
- package/test/integration/generated/parameters/spread/src/responses.ts +25 -0
- package/test/integration/generated/{resiliency/devDriven → parameters/spread}/tspconfig.yaml +2 -4
- package/test/integration/generated/projection/src/clientDefinitions.ts +47 -21
- package/test/integration/generated/projection/src/logger.ts +5 -0
- package/test/integration/generated/projection/src/models.ts +18 -7
- package/test/integration/generated/projection/src/parameters.ts +32 -10
- package/test/integration/generated/projection/src/projectionClient.ts +5 -1
- package/test/integration/generated/projection/src/responses.ts +18 -3
- package/test/integration/generated/resiliency/srvDriven1/README.md +4 -4
- package/test/integration/generated/resiliency/srvDriven1/package.json +1 -1
- package/test/integration/generated/resiliency/srvDriven1/src/clientDefinitions.ts +25 -49
- package/test/integration/generated/resiliency/srvDriven1/src/index.ts +3 -5
- package/test/integration/generated/resiliency/srvDriven1/src/logger.ts +5 -0
- package/test/integration/generated/resiliency/srvDriven1/src/parameters.ts +11 -32
- package/test/integration/generated/resiliency/srvDriven1/src/responses.ts +9 -24
- package/test/integration/generated/resiliency/srvDriven1/src/serviceDrivenOldClient.ts +43 -0
- package/test/integration/generated/resiliency/srvDriven1/tspconfig.yaml +1 -0
- package/test/integration/generated/resiliency/srvDriven2/README.md +13 -4
- package/test/integration/generated/resiliency/srvDriven2/package.json +1 -1
- package/test/integration/generated/resiliency/srvDriven2/src/clientDefinitions.ts +32 -68
- package/test/integration/generated/resiliency/srvDriven2/src/index.ts +3 -5
- package/test/integration/generated/resiliency/srvDriven2/src/logger.ts +5 -0
- package/test/integration/generated/resiliency/srvDriven2/src/parameters.ts +19 -42
- package/test/integration/generated/resiliency/srvDriven2/src/responses.ts +10 -31
- package/test/integration/generated/resiliency/srvDriven2/src/serviceDrivenNewClient.ts +43 -0
- package/test/integration/generated/resiliency/srvDriven2/tspconfig.yaml +1 -0
- package/test/integration/generated/server/path/multiple/src/logger.ts +5 -0
- package/test/integration/generated/server/path/multiple/src/multipleParamInServerPathClient.ts +6 -2
- package/test/integration/generated/server/path/single/src/logger.ts +5 -0
- package/test/integration/generated/server/path/single/src/singleParamInServerPathClient.ts +6 -2
- package/test/integration/generated/specialWords/src/logger.ts +5 -0
- package/test/integration/generated/specialWords/src/specialWordsClient.ts +5 -1
- package/test/integration/generated/unions/src/clientDefinitions.ts +8 -8
- package/test/integration/generated/unions/src/logger.ts +5 -0
- package/test/integration/generated/unions/src/unionsClient.ts +5 -1
- package/test/integration/internal.spec.ts +45 -12
- package/test/integration/lroCore.spec.ts +89 -0
- package/test/integration/modelInheritance.spec.ts +13 -13
- package/test/integration/modelPropertyNullable.spec.ts +8 -8
- package/test/integration/modelPropertyOptional.spec.ts +32 -32
- package/test/integration/modelPropertyType.spec.ts +22 -6
- package/test/integration/modelUsage.spec.ts +7 -7
- package/test/integration/projection.spec.ts +62 -15
- package/test/integration/resiliencyDpgCustomization.spec.ts +133 -38
- package/test/integration/spreadParameters.spec.ts +82 -0
- package/test/integration/unions.spec.ts +4 -4
- package/test/unit/apiVersion.spec.ts +19 -7
- package/test/unit/clientFactoryGenerator.spec.ts +44 -16
- package/test/unit/modelsGenerator.spec.ts +212 -2
- package/test/unit/util/emitUtil.ts +13 -4
- package/test/unit/util/testUtil.ts +7 -2
- package/typespec-ts.build.log +0 -1
- package/dist/src/transform/transformAnnotationDetails.d.ts +0 -6
- package/dist/src/transform/transformAnnotationDetails.d.ts.map +0 -1
- package/dist/src/transform/transformAnnotationDetails.js.map +0 -1
- package/test/integration/generated/internal/src/models.ts +0 -8
- package/test/integration/generated/lro/lroBasic/src/clientDefinitions.ts +0 -37
- package/test/integration/generated/lro/lroBasic/src/parameters.ts +0 -8
- package/test/integration/generated/lro/lroBasic/src/responses.ts +0 -23
- package/test/integration/generated/resiliency/devDriven/.eslintrc.json +0 -11
- package/test/integration/generated/resiliency/devDriven/README.md +0 -56
- package/test/integration/generated/resiliency/devDriven/api-extractor.json +0 -18
- package/test/integration/generated/resiliency/devDriven/package.json +0 -81
- package/test/integration/generated/resiliency/devDriven/rollup.config.js +0 -118
- package/test/integration/generated/resiliency/devDriven/src/clientDefinitions.ts +0 -75
- package/test/integration/generated/resiliency/devDriven/src/models.ts +0 -8
- package/test/integration/generated/resiliency/devDriven/src/outputModels.ts +0 -25
- package/test/integration/generated/resiliency/devDriven/src/paginateHelper.ts +0 -154
- package/test/integration/generated/resiliency/devDriven/src/parameters.ts +0 -17
- package/test/integration/generated/resiliency/devDriven/src/resiliencyDevDriven.ts +0 -31
- package/test/integration/generated/resiliency/devDriven/src/responses.ts +0 -62
- package/test/integration/generated/resiliency/devDriven/tsconfig.json +0 -25
- package/test/integration/generated/resiliency/srvDriven1/src/models.ts +0 -6
- package/test/integration/generated/resiliency/srvDriven1/src/outputModels.ts +0 -6
- package/test/integration/generated/resiliency/srvDriven1/src/resiliencyServiceDriven1.ts +0 -31
- package/test/integration/generated/resiliency/srvDriven2/src/models.ts +0 -6
- package/test/integration/generated/resiliency/srvDriven2/src/outputModels.ts +0 -6
- package/test/integration/generated/resiliency/srvDriven2/src/resiliencyServiceDriven2.ts +0 -31
- package/test/integration/helloWorld.spec.ts +0 -20
- package/test/integration/lroBasic.spec.ts +0 -25
- /package/test/integration/generated/lro/{lroBasic → lroRPC}/.eslintrc.json +0 -0
- /package/test/integration/generated/lro/{lroBasic → lroRPC}/rollup.config.js +0 -0
- /package/test/integration/generated/lro/{lroBasic → lroRPC}/tsconfig.json +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import TypeModelUsageClientFactory, {
|
|
2
|
+
TypeModelUsageClient
|
|
3
3
|
} from "./generated/models/usage/src/index.js";
|
|
4
4
|
import { assert } from "chai";
|
|
5
5
|
describe("ModelsUsageClient Rest Client", () => {
|
|
6
|
-
let client:
|
|
6
|
+
let client: TypeModelUsageClient;
|
|
7
7
|
const body = {
|
|
8
8
|
requiredProp: "example-value"
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
|
-
client =
|
|
12
|
+
client = TypeModelUsageClientFactory({ allowInsecureConnection: true });
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
it("should post input model correctly", async () => {
|
|
16
16
|
try {
|
|
17
|
-
const result = await client.path("/
|
|
17
|
+
const result = await client.path("/type/model/usage/input").post({
|
|
18
18
|
body
|
|
19
19
|
});
|
|
20
20
|
assert.strictEqual(result.status, "204");
|
|
@@ -25,7 +25,7 @@ describe("ModelsUsageClient Rest Client", () => {
|
|
|
25
25
|
|
|
26
26
|
it("should get output model correctly", async () => {
|
|
27
27
|
try {
|
|
28
|
-
const result = await client.path("/
|
|
28
|
+
const result = await client.path("/type/model/usage/output").get();
|
|
29
29
|
assert.strictEqual(result.status, "200");
|
|
30
30
|
assert.deepEqual(result.body, body);
|
|
31
31
|
} catch (err) {
|
|
@@ -36,7 +36,7 @@ describe("ModelsUsageClient Rest Client", () => {
|
|
|
36
36
|
it("should get output model correctly", async () => {
|
|
37
37
|
try {
|
|
38
38
|
const result = await client
|
|
39
|
-
.path("/
|
|
39
|
+
.path("/type/model/usage/input-output")
|
|
40
40
|
.post({ body });
|
|
41
41
|
assert.strictEqual(result.status, "200");
|
|
42
42
|
assert.deepEqual(result.body, body);
|
|
@@ -16,11 +16,13 @@ describe("Projected Name Rest Client", () => {
|
|
|
16
16
|
|
|
17
17
|
it("should respect json projection", async () => {
|
|
18
18
|
try {
|
|
19
|
-
const result = await client
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const result = await client
|
|
20
|
+
.path("/projection/projected-name/property/json")
|
|
21
|
+
.post({
|
|
22
|
+
body: {
|
|
23
|
+
wireName: true
|
|
24
|
+
}
|
|
25
|
+
});
|
|
24
26
|
assert.strictEqual(result.status, "204");
|
|
25
27
|
} catch (err) {
|
|
26
28
|
assert.fail(err as string);
|
|
@@ -29,11 +31,13 @@ describe("Projected Name Rest Client", () => {
|
|
|
29
31
|
|
|
30
32
|
it("should not respect client projection", async () => {
|
|
31
33
|
try {
|
|
32
|
-
const result = await client
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const result = await client
|
|
35
|
+
.path("/projection/projected-name/property/client")
|
|
36
|
+
.post({
|
|
37
|
+
body: {
|
|
38
|
+
defaultName: true
|
|
39
|
+
}
|
|
40
|
+
});
|
|
37
41
|
assert.strictEqual(result.status, "204");
|
|
38
42
|
} catch (err) {
|
|
39
43
|
assert.fail(err as string);
|
|
@@ -42,11 +46,54 @@ describe("Projected Name Rest Client", () => {
|
|
|
42
46
|
|
|
43
47
|
it("should not respect language projection", async () => {
|
|
44
48
|
try {
|
|
45
|
-
const result = await client
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
const result = await client
|
|
50
|
+
.path("/projection/projected-name/property/language")
|
|
51
|
+
.post({
|
|
52
|
+
body: {
|
|
53
|
+
defaultName: true
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
assert.strictEqual(result.status, "204");
|
|
57
|
+
} catch (err) {
|
|
58
|
+
assert.fail(err as string);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should not respect language projection", async () => {
|
|
63
|
+
try {
|
|
64
|
+
const result = await client
|
|
65
|
+
.path("/projection/projected-name/property/json-and-client")
|
|
66
|
+
.post({
|
|
67
|
+
body: {
|
|
68
|
+
wireName: true
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
assert.strictEqual(result.status, "204");
|
|
72
|
+
} catch (err) {
|
|
73
|
+
assert.fail(err as string);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should not respect operation projection", async () => {
|
|
78
|
+
try {
|
|
79
|
+
const result = await client
|
|
80
|
+
.path("/projection/projected-name/operation")
|
|
81
|
+
.post();
|
|
82
|
+
assert.strictEqual(result.status, "204");
|
|
83
|
+
} catch (err) {
|
|
84
|
+
assert.fail(err as string);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should not respect operation projection", async () => {
|
|
89
|
+
try {
|
|
90
|
+
const result = await client
|
|
91
|
+
.path("/projection/projected-name/parameter")
|
|
92
|
+
.post({
|
|
93
|
+
queryParameters: {
|
|
94
|
+
"default-name": "true"
|
|
95
|
+
}
|
|
96
|
+
});
|
|
50
97
|
assert.strictEqual(result.status, "204");
|
|
51
98
|
} catch (err) {
|
|
52
99
|
assert.fail(err as string);
|
|
@@ -1,52 +1,147 @@
|
|
|
1
1
|
import { assert } from "chai";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
} from "./generated/resiliency/
|
|
2
|
+
import ServiceDrivenOldClientFactory, {
|
|
3
|
+
ServiceDrivenOldClient
|
|
4
|
+
} from "./generated/resiliency/srvDriven1/src/index.js";
|
|
5
|
+
import ServiceDrivenNewClientFactory, {
|
|
6
|
+
ServiceDrivenNewClient
|
|
7
|
+
} from "./generated/resiliency/srvDriven2/src/index.js";
|
|
5
8
|
describe("ResiliencyDevDrivenClient Rest Client", () => {
|
|
6
|
-
let
|
|
9
|
+
let client11: ServiceDrivenOldClient;
|
|
10
|
+
let client12: ServiceDrivenOldClient;
|
|
11
|
+
let client21: ServiceDrivenNewClient;
|
|
12
|
+
let client22: ServiceDrivenNewClient;
|
|
7
13
|
|
|
8
14
|
beforeEach(() => {
|
|
9
|
-
|
|
10
|
-
allowInsecureConnection: true
|
|
15
|
+
client11 = ServiceDrivenOldClientFactory("v1", {
|
|
16
|
+
allowInsecureConnection: true,
|
|
17
|
+
apiVersion: "v1"
|
|
18
|
+
});
|
|
19
|
+
client12 = ServiceDrivenOldClientFactory("v2", {
|
|
20
|
+
allowInsecureConnection: true,
|
|
21
|
+
apiVersion: "v1"
|
|
22
|
+
});
|
|
23
|
+
client21 = ServiceDrivenNewClientFactory("v2", {
|
|
24
|
+
allowInsecureConnection: true,
|
|
25
|
+
apiVersion: "v1"
|
|
26
|
+
});
|
|
27
|
+
client22 = ServiceDrivenNewClientFactory("v2", {
|
|
28
|
+
allowInsecureConnection: true,
|
|
29
|
+
apiVersion: "v2"
|
|
11
30
|
});
|
|
12
31
|
});
|
|
13
32
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
|
|
34
|
+
describe("resiliency with service driven", () => {
|
|
35
|
+
it("should work with none parameter", async () => {
|
|
36
|
+
const result11 = await client11
|
|
37
|
+
.path("/add-optional-param/from-none")
|
|
38
|
+
.head();
|
|
39
|
+
|
|
40
|
+
assert.equal(result11.status, "204");
|
|
41
|
+
const result12 = await client12
|
|
42
|
+
.path("/add-optional-param/from-none")
|
|
43
|
+
.head();
|
|
44
|
+
|
|
45
|
+
assert.equal(result12.status, "204");
|
|
46
|
+
const result21 = await client21.path("/add-optional-param/from-none").head({
|
|
47
|
+
queryParameters: {
|
|
48
|
+
"new-parameter": "new"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
assert.equal(result21.status, "204");
|
|
53
|
+
const result22 = await client22.path("/add-optional-param/from-none").head({
|
|
54
|
+
queryParameters: {
|
|
55
|
+
"new-parameter": "new"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
assert.equal(result22.status, "204");
|
|
32
60
|
});
|
|
33
|
-
});
|
|
34
61
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
it("should work with one optional parameter", async () => {
|
|
63
|
+
const result11 = await client11
|
|
64
|
+
.path("/add-optional-param/from-one-optional")
|
|
65
|
+
.get({
|
|
66
|
+
queryParameters: {
|
|
67
|
+
parameter: "optional"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
assert.equal(result11.status, "204");
|
|
71
|
+
const result12 = await client12
|
|
72
|
+
.path("/add-optional-param/from-one-optional")
|
|
73
|
+
.get({
|
|
74
|
+
queryParameters: {
|
|
75
|
+
parameter: "optional"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
assert.equal(result12.status, "204");
|
|
79
|
+
const result21 = await client21
|
|
80
|
+
.path("/add-optional-param/from-one-optional")
|
|
81
|
+
.get({
|
|
82
|
+
queryParameters: {
|
|
83
|
+
parameter: "optional",
|
|
84
|
+
"new-parameter": "new"
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
assert.equal(result21.status, "204");
|
|
88
|
+
const result22 = await client22
|
|
89
|
+
.path("/add-optional-param/from-one-optional")
|
|
90
|
+
.get({
|
|
91
|
+
queryParameters: {
|
|
92
|
+
parameter: "optional",
|
|
93
|
+
"new-parameter": "new"
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
assert.equal(result22.status, "204");
|
|
42
97
|
});
|
|
43
98
|
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
.path("/
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
99
|
+
it("should work with one required parameter", async () => {
|
|
100
|
+
const result11 = await client11
|
|
101
|
+
.path("/add-optional-param/from-one-required")
|
|
102
|
+
.get({
|
|
103
|
+
queryParameters: {
|
|
104
|
+
parameter: "required"
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
assert.equal(result11.status, "204");
|
|
108
|
+
const result12 = await client12
|
|
109
|
+
.path("/add-optional-param/from-one-required")
|
|
110
|
+
.get({
|
|
111
|
+
queryParameters: {
|
|
112
|
+
parameter: "required"
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
assert.equal(result12.status, "204");
|
|
116
|
+
const result21 = await client21
|
|
117
|
+
.path("/add-optional-param/from-one-required")
|
|
118
|
+
.get({
|
|
119
|
+
queryParameters: {
|
|
120
|
+
parameter: "required",
|
|
121
|
+
"new-parameter": "new"
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
assert.equal(result21.status, "204");
|
|
125
|
+
const result22 = await client22
|
|
126
|
+
.path("/add-optional-param/from-one-required")
|
|
127
|
+
.get({
|
|
128
|
+
queryParameters: {
|
|
129
|
+
parameter: "required",
|
|
130
|
+
"new-parameter": "new"
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
assert.equal(result22.status, "204");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("should work with add operation", async () => {
|
|
138
|
+
const client122 = ServiceDrivenOldClientFactory("v2", {
|
|
139
|
+
allowInsecureConnection: true,
|
|
140
|
+
apiVersion: "v2"
|
|
50
141
|
});
|
|
142
|
+
const result122 = await client122.pathUnchecked("/add-operation").delete();
|
|
143
|
+
assert.equal(result122.status, "204");
|
|
144
|
+
const result22 = await client22.path("/add-operation").delete()
|
|
145
|
+
assert.equal(result22.status, "204");
|
|
51
146
|
});
|
|
52
147
|
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import ParametersSpreadClientFactory, {
|
|
2
|
+
ParametersSpreadClient
|
|
3
|
+
} from "./generated/parameters/spread/src/index.js";
|
|
4
|
+
import { assert } from "chai";
|
|
5
|
+
describe("HelloClient Rest Client", () => {
|
|
6
|
+
let client: ParametersSpreadClient;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
client = ParametersSpreadClientFactory({ allowInsecureConnection: true });
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should spread named model", async () => {
|
|
13
|
+
try {
|
|
14
|
+
const result = await client
|
|
15
|
+
.path("/parameters/spread/model/request-body")
|
|
16
|
+
.put({
|
|
17
|
+
body: {
|
|
18
|
+
name: "foo"
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
assert.strictEqual(result.status, "204");
|
|
22
|
+
} catch (err) {
|
|
23
|
+
assert.fail(err as string);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should spread alias with only body param", async () => {
|
|
28
|
+
try {
|
|
29
|
+
const result = await client
|
|
30
|
+
.path("/parameters/spread/alias/request-body")
|
|
31
|
+
.put({
|
|
32
|
+
body: {
|
|
33
|
+
name: "foo"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
assert.strictEqual(result.status, "204");
|
|
37
|
+
} catch (err) {
|
|
38
|
+
assert.fail(err as string);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should spread alias with mixed params", async () => {
|
|
43
|
+
try {
|
|
44
|
+
const result = await client
|
|
45
|
+
.path("/parameters/spread/alias/request-parameter/{id}", "1")
|
|
46
|
+
.put({
|
|
47
|
+
body: {
|
|
48
|
+
name: "foo"
|
|
49
|
+
},
|
|
50
|
+
headers: {
|
|
51
|
+
"x-ms-test-header": "bar"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
assert.strictEqual(result.status, "204");
|
|
55
|
+
} catch (err) {
|
|
56
|
+
assert.fail(err as string);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should spread alias with more than 5 params", async () => {
|
|
61
|
+
try {
|
|
62
|
+
const result = await client
|
|
63
|
+
.path("/parameters/spread/alias/multiple-parameters/{id}", "1")
|
|
64
|
+
.put({
|
|
65
|
+
body: {
|
|
66
|
+
prop1: "foo1",
|
|
67
|
+
prop2: "foo2",
|
|
68
|
+
prop3: "foo3",
|
|
69
|
+
prop4: "foo4",
|
|
70
|
+
prop5: "foo5",
|
|
71
|
+
prop6: "foo6"
|
|
72
|
+
},
|
|
73
|
+
headers: {
|
|
74
|
+
"x-ms-test-header": "bar"
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
assert.strictEqual(result.status, "204");
|
|
78
|
+
} catch (err) {
|
|
79
|
+
assert.fail(err as string);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -11,7 +11,7 @@ describe("UnionsClient Rest Client", () => {
|
|
|
11
11
|
|
|
12
12
|
it("should post input simple number union", async () => {
|
|
13
13
|
try {
|
|
14
|
-
const result = await client.path("/
|
|
14
|
+
const result = await client.path("/type/union/int").post({
|
|
15
15
|
body: {
|
|
16
16
|
simpleUnion: 1
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ describe("UnionsClient Rest Client", () => {
|
|
|
24
24
|
|
|
25
25
|
it("should post simple number array union", async () => {
|
|
26
26
|
try {
|
|
27
|
-
const result = await client.path("/
|
|
27
|
+
const result = await client.path("/type/union/int-array").post({
|
|
28
28
|
body: {
|
|
29
29
|
simpleUnion: [1, 2]
|
|
30
30
|
}
|
|
@@ -37,7 +37,7 @@ describe("UnionsClient Rest Client", () => {
|
|
|
37
37
|
|
|
38
38
|
it("should post named union model1", async () => {
|
|
39
39
|
try {
|
|
40
|
-
const result = await client.path("/
|
|
40
|
+
const result = await client.path("/type/union/model1").post({
|
|
41
41
|
body: {
|
|
42
42
|
namedUnion: {
|
|
43
43
|
name: "model1",
|
|
@@ -53,7 +53,7 @@ describe("UnionsClient Rest Client", () => {
|
|
|
53
53
|
|
|
54
54
|
it("should post named union model2", async () => {
|
|
55
55
|
try {
|
|
56
|
-
const result = await client.path("/
|
|
56
|
+
const result = await client.path("/type/union/model2").post({
|
|
57
57
|
body: {
|
|
58
58
|
namedUnion: {
|
|
59
59
|
name: "model2",
|
|
@@ -130,12 +130,13 @@ const buildDefaultReturn = (hasDefault: boolean) => {
|
|
|
130
130
|
: `options.apiVersion = options.apiVersion ?? "2022-05-15-preview";`;
|
|
131
131
|
return `
|
|
132
132
|
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
133
|
+
import { logger } from "./logger";
|
|
133
134
|
import { testClient } from "./clientDefinitions";
|
|
134
135
|
|
|
135
136
|
/**
|
|
136
137
|
* Initialize a new instance of \`testClient\`
|
|
137
|
-
* @param endpoint
|
|
138
|
-
* @param options
|
|
138
|
+
* @param endpoint - The endpoint to use.
|
|
139
|
+
* @param options - the parameter for all optional parameters
|
|
139
140
|
*/
|
|
140
141
|
export default function createClient(
|
|
141
142
|
endpoint: string,
|
|
@@ -154,6 +155,9 @@ const buildDefaultReturn = (hasDefault: boolean) => {
|
|
|
154
155
|
userAgentOptions: {
|
|
155
156
|
userAgentPrefix,
|
|
156
157
|
},
|
|
158
|
+
loggingOptions: {
|
|
159
|
+
logger: options.loggingOptions?.logger ?? logger.info
|
|
160
|
+
},
|
|
157
161
|
};
|
|
158
162
|
|
|
159
163
|
const client = getClient(baseUrl, options) as testClient;
|
|
@@ -165,6 +169,7 @@ const buildDefaultReturn = (hasDefault: boolean) => {
|
|
|
165
169
|
const buildPathReturn_WithDefault = () => {
|
|
166
170
|
return `
|
|
167
171
|
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
172
|
+
import { logger } from "./logger";
|
|
168
173
|
import { testClient } from "./clientDefinitions";
|
|
169
174
|
|
|
170
175
|
export interface testClientOptions extends ClientOptions {
|
|
@@ -173,8 +178,8 @@ const buildPathReturn_WithDefault = () => {
|
|
|
173
178
|
|
|
174
179
|
/**
|
|
175
180
|
* Initialize a new instance of \`testClient\`
|
|
176
|
-
* @param endpoint
|
|
177
|
-
* @param options
|
|
181
|
+
* @param endpoint - The endpoint to use.
|
|
182
|
+
* @param options - the parameter for all optional parameters
|
|
178
183
|
*/
|
|
179
184
|
export default function createClient(
|
|
180
185
|
endpoint: string,
|
|
@@ -193,6 +198,9 @@ const buildPathReturn_WithDefault = () => {
|
|
|
193
198
|
userAgentOptions: {
|
|
194
199
|
userAgentPrefix,
|
|
195
200
|
},
|
|
201
|
+
loggingOptions: {
|
|
202
|
+
logger: options.loggingOptions?.logger ?? logger.info
|
|
203
|
+
},
|
|
196
204
|
};
|
|
197
205
|
|
|
198
206
|
const client = getClient(baseUrl, options) as testClient;
|
|
@@ -204,13 +212,14 @@ const buildPathReturn_WithDefault = () => {
|
|
|
204
212
|
const buildPathReturn_WithoutDefault = () => {
|
|
205
213
|
return `
|
|
206
214
|
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
215
|
+
import { logger } from "./logger";
|
|
207
216
|
import { testClient } from "./clientDefinitions";
|
|
208
217
|
|
|
209
218
|
/**
|
|
210
219
|
* Initialize a new instance of \`testClient\`
|
|
211
|
-
* @param endpoint
|
|
212
|
-
* @param apiVersion
|
|
213
|
-
* @param options
|
|
220
|
+
* @param endpoint - The endpoint to use.
|
|
221
|
+
* @param apiVersion - Api Version Possible values: 2022-05-15-preview
|
|
222
|
+
* @param options - the parameter for all optional parameters
|
|
214
223
|
*/
|
|
215
224
|
export default function createClient(
|
|
216
225
|
endpoint: string,
|
|
@@ -229,6 +238,9 @@ const buildPathReturn_WithoutDefault = () => {
|
|
|
229
238
|
userAgentOptions: {
|
|
230
239
|
userAgentPrefix,
|
|
231
240
|
},
|
|
241
|
+
loggingOptions: {
|
|
242
|
+
logger: options.loggingOptions?.logger ?? logger.info
|
|
243
|
+
},
|
|
232
244
|
};
|
|
233
245
|
|
|
234
246
|
const client = getClient(baseUrl, options) as testClient;
|