@azure-tools/typespec-ts 0.11.0 → 0.12.0-alpha.20230501.1
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/package-deps_build.json +265 -152
- package/.rush/temp/shrinkwrap-deps.json +58 -54
- package/CHANGELOG.md +4 -0
- package/CONTRIBUTING.md +5 -2
- package/README.md +3 -3
- package/dist/src/casingUtils.d.ts +4 -0
- package/dist/src/casingUtils.d.ts.map +1 -0
- package/dist/src/casingUtils.js +39 -0
- package/dist/src/casingUtils.js.map +1 -0
- package/dist/src/emitUtil.js +7 -1
- package/dist/src/emitUtil.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +41 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +2 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/modelUtils.d.ts +22 -1
- package/dist/src/modelUtils.d.ts.map +1 -1
- package/dist/src/modelUtils.js +105 -13
- package/dist/src/modelUtils.js.map +1 -1
- package/dist/src/modular/buildApiIndex.d.ts +3 -0
- package/dist/src/modular/buildApiIndex.d.ts.map +1 -0
- package/dist/src/modular/buildApiIndex.js +12 -0
- package/dist/src/modular/buildApiIndex.js.map +1 -0
- package/dist/src/modular/buildClassicalClient.d.ts +4 -0
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -0
- package/dist/src/modular/buildClassicalClient.js +112 -0
- package/dist/src/modular/buildClassicalClient.js.map +1 -0
- package/dist/src/modular/buildClientContext.d.ts +7 -0
- package/dist/src/modular/buildClientContext.d.ts.map +1 -0
- package/dist/src/modular/buildClientContext.js +72 -0
- package/dist/src/modular/buildClientContext.js.map +1 -0
- package/dist/src/modular/buildCodeModel.d.ts +14 -0
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -0
- package/dist/src/modular/buildCodeModel.js +1110 -0
- package/dist/src/modular/buildCodeModel.js.map +1 -0
- package/dist/src/modular/buildOperations.d.ts +13 -0
- package/dist/src/modular/buildOperations.d.ts.map +1 -0
- package/dist/src/modular/buildOperations.js +70 -0
- package/dist/src/modular/buildOperations.js.map +1 -0
- package/dist/src/modular/buildProjectFiles.d.ts +5 -0
- package/dist/src/modular/buildProjectFiles.d.ts.map +1 -0
- package/dist/src/modular/buildProjectFiles.js +182 -0
- package/dist/src/modular/buildProjectFiles.js.map +1 -0
- package/dist/src/modular/buildRootIndex.d.ts +4 -0
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -0
- package/dist/src/modular/buildRootIndex.js +66 -0
- package/dist/src/modular/buildRootIndex.js.map +1 -0
- package/dist/src/modular/buildSharedTypes.d.ts +6 -0
- package/dist/src/modular/buildSharedTypes.d.ts.map +1 -0
- package/dist/src/modular/buildSharedTypes.js +33 -0
- package/dist/src/modular/buildSharedTypes.js.map +1 -0
- package/dist/src/modular/emitModels.d.ts +7 -0
- package/dist/src/modular/emitModels.d.ts.map +1 -0
- package/dist/src/modular/emitModels.js +63 -0
- package/dist/src/modular/emitModels.js.map +1 -0
- package/dist/src/modular/helpers/clientHelpers.d.ts +4 -0
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/clientHelpers.js +31 -0
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -0
- package/dist/src/modular/helpers/credentialHelpers.d.ts +7 -0
- package/dist/src/modular/helpers/credentialHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/credentialHelpers.js +32 -0
- package/dist/src/modular/helpers/credentialHelpers.js.map +1 -0
- package/dist/src/modular/helpers/namingHelpers.d.ts +3 -0
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/namingHelpers.js +4 -0
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -0
- package/dist/src/modular/helpers/operationHelpers.d.ts +8 -0
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/operationHelpers.js +274 -0
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -0
- package/dist/src/modular/helpers/parameterHelpers.d.ts +3 -0
- package/dist/src/modular/helpers/parameterHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/parameterHelpers.js +16 -0
- package/dist/src/modular/helpers/parameterHelpers.js.map +1 -0
- package/dist/src/modular/helpers/typeHelpers.d.ts +16 -0
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/typeHelpers.js +92 -0
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -0
- package/dist/src/modular/interfaces.d.ts +10 -0
- package/dist/src/modular/interfaces.d.ts.map +1 -0
- package/dist/src/modular/interfaces.js +2 -0
- package/dist/src/modular/interfaces.js.map +1 -0
- package/dist/src/modular/modularCodeModel.d.ts +121 -0
- package/dist/src/modular/modularCodeModel.d.ts.map +1 -0
- package/dist/src/modular/modularCodeModel.js +2 -0
- package/dist/src/modular/modularCodeModel.js.map +1 -0
- package/dist/src/operationUtil.d.ts +30 -4
- package/dist/src/operationUtil.d.ts.map +1 -1
- package/dist/src/operationUtil.js +77 -18
- package/dist/src/operationUtil.js.map +1 -1
- package/dist/src/transform/transform.d.ts +4 -6
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +17 -58
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts +5 -0
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -0
- package/dist/src/transform/transformApiVersionInfo.js +64 -0
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -0
- 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 +2 -2
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +20 -7
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts +2 -2
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +15 -7
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts +2 -2
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +23 -2
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.d.ts +2 -2
- package/dist/src/transform/transformSchemas.d.ts.map +1 -1
- package/dist/src/transform/transformSchemas.js +10 -22
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts +2 -2
- package/dist/src/transform/transfromRLCOptions.js +1 -1
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -19
- package/src/casingUtils.ts +48 -0
- package/src/emitUtil.ts +9 -4
- package/src/index.ts +53 -10
- package/src/lib.ts +2 -1
- package/src/modelUtils.ts +137 -14
- package/src/modular/buildApiIndex.ts +13 -0
- package/src/modular/buildClassicalClient.ts +147 -0
- package/src/modular/buildClientContext.ts +104 -0
- package/src/modular/buildCodeModel.ts +1449 -0
- package/src/modular/buildOperations.ts +95 -0
- package/src/modular/buildProjectFiles.ts +219 -0
- package/src/modular/buildRootIndex.ts +94 -0
- package/src/modular/buildSharedTypes.ts +40 -0
- package/src/modular/emitModels.ts +72 -0
- package/src/modular/helpers/clientHelpers.ts +38 -0
- package/src/modular/helpers/credentialHelpers.ts +40 -0
- package/src/modular/helpers/namingHelpers.ts +5 -0
- package/src/modular/helpers/operationHelpers.ts +418 -0
- package/src/modular/helpers/parameterHelpers.ts +17 -0
- package/src/modular/helpers/typeHelpers.ts +106 -0
- package/src/modular/interfaces.ts +10 -0
- package/src/modular/modularCodeModel.ts +151 -0
- package/src/modular/static/karma.conf.cjs +120 -0
- package/src/modular/static/rollup.test.config.js +67 -0
- package/src/modular/static/scripts/renameOutput.mjs +17 -0
- package/src/operationUtil.ts +119 -31
- package/src/transform/transform.ts +33 -96
- package/src/transform/transformApiVersionInfo.ts +108 -0
- package/src/transform/{transformAnnotationDetails.ts → transformHelperFunctionDetails.ts} +11 -11
- package/src/transform/transformParameters.ts +30 -14
- package/src/transform/transformPaths.ts +29 -19
- package/src/transform/transformResponses.ts +50 -8
- package/src/transform/transformSchemas.ts +20 -28
- package/src/transform/transfromRLCOptions.ts +3 -3
- package/test/commands/cadl-ranch-list.ts +53 -20
- package/test/commands/gen-cadl-ranch.ts +6 -2
- package/test/commands/run.ts +3 -13
- package/test/integration/arrayItemTypes.spec.ts +6 -3
- package/test/integration/azurecore.spec.ts +130 -0
- package/test/integration/collectionFormat.spec.ts +118 -0
- package/test/integration/dictionary.spec.ts +6 -2
- package/test/integration/extensibleEnums.spec.ts +8 -8
- package/test/integration/fixedEnums.spec.ts +7 -7
- package/test/integration/generated/arrays/itemTypes/src/clientDefinitions.ts +33 -18
- package/test/integration/generated/arrays/itemTypes/src/parameters.ts +8 -0
- package/test/integration/generated/arrays/itemTypes/src/responses.ts +11 -0
- package/test/integration/generated/arrays/itemTypes/tspconfig.yaml +5 -2
- package/test/integration/generated/authentication/apiKey/package.json +2 -2
- package/test/integration/generated/authentication/apiKey/tspconfig.yaml +5 -2
- package/test/integration/generated/authentication/oauth2/tspconfig.yaml +5 -2
- package/test/integration/generated/authentication/union/tspconfig.yaml +5 -2
- package/test/integration/generated/{resiliency/devDriven → azure/core}/README.md +7 -7
- package/test/integration/generated/{lro/lroBasic → azure/core}/api-extractor.json +1 -1
- package/test/integration/generated/{resiliency/devDriven → azure/core}/package.json +6 -6
- package/test/integration/generated/azure/core/src/azureCoreClient.ts +31 -0
- package/test/integration/generated/azure/core/src/clientDefinitions.ts +108 -0
- package/test/integration/generated/{resiliency/devDriven → azure/core}/src/index.ts +4 -3
- package/test/integration/generated/azure/core/src/isUnexpected.ts +178 -0
- package/test/integration/generated/azure/core/src/models.ts +18 -0
- package/test/integration/generated/azure/core/src/outputModels.ts +32 -0
- package/test/integration/generated/{resiliency/devDriven → azure/core}/src/paginateHelper.ts +55 -5
- package/test/integration/generated/azure/core/src/parameters.ts +68 -0
- package/test/integration/generated/azure/core/src/responses.ts +158 -0
- package/test/integration/generated/azure/core/src/serializeHelper.ts +16 -0
- package/test/integration/generated/azure/core/tspconfig.yaml +15 -0
- package/test/integration/generated/azure/core-traits/README.md +56 -0
- package/test/integration/generated/azure/core-traits/api-extractor.json +18 -0
- package/test/integration/generated/azure/core-traits/package.json +80 -0
- package/test/integration/generated/azure/core-traits/src/azureCoreTraitsClient.ts +31 -0
- package/test/integration/generated/azure/core-traits/src/clientDefinitions.ts +22 -0
- package/test/integration/generated/azure/core-traits/src/index.ts +13 -0
- package/test/integration/generated/{resiliency/devDriven → azure/core-traits}/src/isUnexpected.ts +6 -26
- package/test/integration/generated/azure/core-traits/src/outputModels.ts +10 -0
- package/test/integration/generated/azure/core-traits/src/parameters.ts +26 -0
- package/test/integration/generated/azure/core-traits/src/responses.ts +32 -0
- package/test/integration/generated/azure/core-traits/tspconfig.yaml +15 -0
- package/test/integration/generated/dictionary/package.json +2 -2
- package/test/integration/generated/dictionary/src/clientDefinitions.ts +35 -20
- package/test/integration/generated/dictionary/src/parameters.ts +8 -0
- package/test/integration/generated/dictionary/src/responses.ts +11 -0
- package/test/integration/generated/dictionary/tspconfig.yaml +5 -2
- package/test/integration/generated/enums/extensible/README.md +3 -3
- package/test/integration/generated/enums/extensible/package.json +2 -2
- 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/{enumsExtensible.ts → typeEnumExtensible.ts} +4 -4
- package/test/integration/generated/enums/extensible/tspconfig.yaml +5 -2
- package/test/integration/generated/enums/fixed/README.md +3 -3
- package/test/integration/generated/enums/fixed/package.json +2 -2
- 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/{enumsFixed.ts → typeEnumFixed.ts} +4 -4
- package/test/integration/generated/enums/fixed/tspconfig.yaml +5 -2
- package/test/integration/generated/hello/package.json +2 -2
- package/test/integration/generated/hello/tspconfig.yaml +5 -2
- package/test/integration/generated/internal/src/clientDefinitions.ts +27 -0
- package/test/integration/generated/internal/src/index.ts +13 -0
- package/test/integration/generated/{lro/lroBasic/src/azureLro.ts → internal/src/internalClient.ts} +5 -5
- package/test/integration/generated/internal/src/models.ts +8 -0
- package/test/integration/generated/internal/src/outputModels.ts +13 -0
- package/test/integration/generated/internal/src/parameters.ts +21 -0
- package/test/integration/generated/internal/src/responses.ts +20 -0
- package/test/integration/generated/internal/tspconfig.yaml +14 -0
- package/test/integration/generated/lro/lroCore/.eslintrc.json +11 -0
- package/test/integration/generated/lro/lroCore/README.md +56 -0
- package/test/integration/generated/{resiliency/devDriven → lro/lroCore}/api-extractor.json +1 -1
- package/test/integration/generated/lro/{lroBasic → lroCore}/package.json +6 -6
- package/test/integration/generated/lro/lroCore/rollup.config.js +118 -0
- package/test/integration/generated/lro/lroCore/src/clientDefinitions.ts +54 -0
- package/test/integration/generated/lro/lroCore/src/index.ts +15 -0
- package/test/integration/generated/lro/lroCore/src/isUnexpected.ts +135 -0
- package/test/integration/generated/lro/lroCore/src/models.ts +8 -0
- package/test/integration/generated/lro/lroCore/src/outputModels.ts +50 -0
- package/test/integration/generated/lro/lroCore/src/parameters.ts +25 -0
- package/test/integration/generated/lro/{lroBasic → lroCore}/src/pollingHelper.ts +38 -0
- package/test/integration/generated/lro/lroCore/src/responses.ts +109 -0
- package/test/integration/generated/lro/lroCore/src/specsAzureCoreLroStandard.ts +31 -0
- package/test/integration/generated/lro/lroCore/tsconfig.json +25 -0
- package/test/integration/generated/lro/lroCore/tspconfig.yaml +14 -0
- package/test/integration/generated/lro/lroRPC/.eslintrc.json +11 -0
- package/test/integration/generated/lro/{lroBasic → lroRPC}/README.md +7 -7
- package/test/integration/generated/lro/lroRPC/api-extractor.json +18 -0
- package/test/integration/generated/lro/lroRPC/package.json +82 -0
- package/test/integration/generated/lro/lroRPC/rollup.config.js +118 -0
- package/test/integration/generated/lro/lroRPC/src/clientDefinitions.ts +79 -0
- package/test/integration/generated/lro/lroRPC/src/index.ts +15 -0
- package/test/integration/generated/lro/lroRPC/src/isUnexpected.ts +153 -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/lroRPC/src/pollingHelper.ts +127 -0
- package/test/integration/generated/lro/lroRPC/src/responses.ts +124 -0
- package/test/integration/generated/lro/lroRPC/src/specsAzureCoreLroRpc.ts +31 -0
- package/test/integration/generated/lro/lroRPC/tsconfig.json +25 -0
- package/test/integration/generated/lro/lroRPC/tspconfig.yaml +14 -0
- package/test/integration/generated/models/inheritance/README.md +3 -3
- package/test/integration/generated/models/inheritance/package.json +2 -2
- 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/{modelsInheritance.ts → typeModelInheritance.ts} +4 -4
- package/test/integration/generated/models/inheritance/tspconfig.yaml +5 -2
- package/test/integration/generated/models/propertyNullable/.eslintrc.json +11 -0
- package/test/integration/generated/models/propertyNullable/README.md +56 -0
- package/test/integration/generated/models/propertyNullable/api-extractor.json +18 -0
- package/test/integration/generated/models/propertyNullable/package.json +80 -0
- package/test/integration/generated/models/propertyNullable/rollup.config.js +118 -0
- package/test/integration/generated/models/propertyNullable/src/clientDefinitions.ts +227 -0
- package/test/integration/generated/models/propertyNullable/src/index.ts +13 -0
- package/test/integration/generated/models/propertyNullable/src/models.ts +56 -0
- package/test/integration/generated/models/propertyNullable/src/outputModels.ts +56 -0
- package/test/integration/generated/models/propertyNullable/src/parameters.ts +197 -0
- package/test/integration/generated/models/propertyNullable/src/responses.ts +144 -0
- package/test/integration/generated/{resiliency/devDriven/src/resiliencyDevDriven.ts → models/propertyNullable/src/typePropertyNullable.ts} +5 -5
- package/test/integration/generated/models/propertyNullable/tsconfig.json +25 -0
- package/test/integration/generated/models/propertyNullable/tspconfig.yaml +14 -0
- package/test/integration/generated/models/propertyOptional/README.md +3 -3
- package/test/integration/generated/models/propertyOptional/package.json +2 -2
- 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/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} +4 -4
- package/test/integration/generated/models/propertyOptional/tspconfig.yaml +5 -2
- package/test/integration/generated/models/propertyTypes/README.md +3 -3
- package/test/integration/generated/models/propertyTypes/package.json +2 -2
- package/test/integration/generated/models/propertyTypes/src/clientDefinitions.ts +55 -47
- package/test/integration/generated/models/propertyTypes/src/index.ts +3 -3
- package/test/integration/generated/models/propertyTypes/src/parameters.ts +8 -6
- package/test/integration/generated/models/propertyTypes/src/responses.ts +4 -4
- package/test/integration/generated/models/propertyTypes/src/{modelsPropertyTypes.ts → typePropertyValueTypes.ts} +4 -4
- package/test/integration/generated/models/propertyTypes/tspconfig.yaml +5 -2
- package/test/integration/generated/models/usage/README.md +3 -3
- package/test/integration/generated/models/usage/package.json +2 -2
- 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/{modelsUsage.ts → typeModelUsage.ts} +4 -4
- package/test/integration/generated/models/usage/tspconfig.yaml +5 -2
- package/test/integration/generated/models/visibility/README.md +3 -3
- package/test/integration/generated/models/visibility/package.json +2 -2
- 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/{modelsVisibilityAutomatic.ts → typeModelVisibility.ts} +4 -4
- package/test/integration/generated/models/visibility/tspconfig.yaml +5 -2
- package/test/integration/generated/parameters/collection-format/src/clientDefinitions.ts +63 -0
- package/test/integration/generated/parameters/collection-format/src/collectionFormatClient.ts +31 -0
- package/test/integration/generated/parameters/collection-format/src/index.ts +12 -0
- package/test/integration/generated/parameters/collection-format/src/parameters.ts +71 -0
- package/test/integration/generated/parameters/collection-format/src/responses.ts +34 -0
- package/test/integration/generated/parameters/collection-format/src/serializeHelper.ts +28 -0
- package/test/integration/generated/parameters/collection-format/tspconfig.yaml +14 -0
- package/test/integration/generated/parameters/spread/src/clientDefinitions.ts +61 -0
- package/test/integration/generated/{lro/lroBasic → parameters/spread}/src/index.ts +4 -4
- package/test/integration/generated/parameters/spread/src/models.ts +7 -0
- package/test/integration/generated/parameters/spread/src/parameters.ts +61 -0
- package/test/integration/generated/parameters/spread/src/parametersSpread.ts +31 -0
- package/test/integration/generated/parameters/spread/src/responses.ts +25 -0
- package/test/integration/generated/parameters/spread/tspconfig.yaml +12 -0
- package/test/integration/generated/projection/src/clientDefinitions.ts +71 -0
- package/test/integration/generated/projection/src/index.ts +12 -0
- package/test/integration/generated/projection/src/models.ts +22 -0
- package/test/integration/generated/projection/src/parameters.ts +48 -0
- package/test/integration/generated/projection/src/projectionClient.ts +31 -0
- package/test/integration/generated/projection/src/responses.ts +34 -0
- package/test/integration/generated/projection/tspconfig.yaml +14 -0
- package/test/integration/generated/resiliency/srvDriven1/README.md +4 -4
- package/test/integration/generated/resiliency/srvDriven1/package.json +2 -2
- 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/parameters.ts +11 -32
- package/test/integration/generated/resiliency/srvDriven1/src/responses.ts +9 -24
- package/test/integration/generated/resiliency/srvDriven1/src/serviceDrivenOldClient.ts +39 -0
- package/test/integration/generated/resiliency/srvDriven1/tspconfig.yaml +6 -2
- package/test/integration/generated/resiliency/srvDriven2/README.md +13 -4
- package/test/integration/generated/resiliency/srvDriven2/package.json +2 -2
- 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/parameters.ts +19 -42
- package/test/integration/generated/resiliency/srvDriven2/src/responses.ts +10 -31
- package/test/integration/generated/resiliency/srvDriven2/src/serviceDrivenNewClient.ts +39 -0
- package/test/integration/generated/resiliency/srvDriven2/tspconfig.yaml +6 -2
- package/test/integration/generated/server/path/multiple/src/clientDefinitions.ts +35 -0
- package/test/integration/generated/server/path/multiple/src/index.ts +11 -0
- package/test/integration/generated/server/path/multiple/src/multipleParamInServerPathClient.ts +39 -0
- package/test/integration/generated/server/path/multiple/src/parameters.ts +7 -0
- package/test/integration/generated/server/path/multiple/src/responses.ts +14 -0
- package/test/integration/generated/server/path/multiple/tspconfig.yaml +14 -0
- package/test/integration/generated/server/path/single/src/clientDefinitions.ts +19 -0
- package/test/integration/generated/server/path/single/src/index.ts +11 -0
- package/test/integration/generated/server/path/single/src/parameters.ts +6 -0
- package/test/integration/generated/server/path/single/src/responses.ts +9 -0
- package/test/integration/generated/server/path/single/src/singleParamInServerPathClient.ts +34 -0
- package/test/integration/generated/server/path/single/tspconfig.yaml +14 -0
- package/test/integration/generated/specialWords/tspconfig.yaml +5 -2
- package/test/integration/generated/unions/src/clientDefinitions.ts +8 -8
- package/test/integration/generated/unions/tspconfig.yaml +5 -2
- package/test/integration/internal.spec.ts +43 -0
- package/test/integration/lroCore.spec.ts +89 -0
- package/test/integration/modelInheritance.spec.ts +13 -13
- package/test/integration/modelPropertyNullable.spec.ts +115 -0
- package/test/integration/modelPropertyOptional.spec.ts +32 -32
- package/test/integration/modelPropertyType.spec.ts +6 -6
- package/test/integration/modelUsage.spec.ts +7 -7
- package/test/integration/projection.spec.ts +102 -0
- package/test/integration/resiliencyDpgCustomization.spec.ts +69 -35
- package/test/integration/server.spec.ts +59 -0
- package/test/integration/spreadParameters.spec.ts +82 -0
- package/test/integration/unions.spec.ts +4 -4
- package/test/unit/apiVersion.spec.ts +388 -0
- package/test/unit/clientFactoryGenerator.spec.ts +0 -131
- package/test/unit/modelsGenerator.spec.ts +2 -2
- package/test/unit/parametersGenerator.spec.ts +1 -1
- package/test/unit/responsesGenerator.spec.ts +1 -1
- package/test/unit/util/emitUtil.ts +6 -5
- package/test/unit/util/testUtil.ts +3 -3
- 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/dist/src/transform/transformApiVersionParam.d.ts +0 -5
- package/dist/src/transform/transformApiVersionParam.d.ts.map +0 -1
- package/dist/src/transform/transformApiVersionParam.js +0 -76
- package/dist/src/transform/transformApiVersionParam.js.map +0 -1
- package/src/transform/transformApiVersionParam.ts +0 -104
- 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 -22
- package/test/integration/generated/lro/lroBasic/tspconfig.yaml +0 -11
- 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/parameters.ts +0 -17
- package/test/integration/generated/resiliency/devDriven/src/responses.ts +0 -62
- package/test/integration/generated/resiliency/devDriven/tspconfig.yaml +0 -11
- 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/{resiliency/devDriven → azure/core}/.eslintrc.json +0 -0
- /package/test/integration/generated/{resiliency/devDriven → azure/core}/rollup.config.js +0 -0
- /package/test/integration/generated/{resiliency/devDriven → azure/core}/tsconfig.json +0 -0
- /package/test/integration/generated/{lro/lroBasic → azure/core-traits}/.eslintrc.json +0 -0
- /package/test/integration/generated/{lro/lroBasic → azure/core-traits}/rollup.config.js +0 -0
- /package/test/integration/generated/{lro/lroBasic → azure/core-traits}/tsconfig.json +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
"
|
|
1
|
+
emit:
|
|
2
|
+
- "@azure-tools/typespec-ts"
|
|
3
|
+
options:
|
|
4
|
+
"@azure-tools/typespec-ts":
|
|
5
|
+
"emitter-output-dir": "{project-root}"
|
|
3
6
|
generateMetadata: true
|
|
4
7
|
generateTest: false
|
|
5
8
|
addCredentials: false
|
|
6
9
|
azureSdkForJs: false
|
|
7
10
|
isCadlTest: true
|
|
11
|
+
title: ServiceDrivenNewClient
|
|
8
12
|
packageDetails:
|
|
9
13
|
name: "@msinternal/srv-driven-2"
|
|
10
14
|
description: "Srv Driven 2 Test Service"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
NoOperationParamsParameters,
|
|
6
|
+
WithOperationPathParamParameters,
|
|
7
|
+
} from "./parameters";
|
|
8
|
+
import {
|
|
9
|
+
NoOperationParams204Response,
|
|
10
|
+
WithOperationPathParam204Response,
|
|
11
|
+
} from "./responses";
|
|
12
|
+
import { Client, StreamableMethod } from "@azure-rest/core-client";
|
|
13
|
+
|
|
14
|
+
export interface NoOperationParams {
|
|
15
|
+
get(
|
|
16
|
+
options?: NoOperationParamsParameters
|
|
17
|
+
): StreamableMethod<NoOperationParams204Response>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface WithOperationPathParam {
|
|
21
|
+
get(
|
|
22
|
+
options?: WithOperationPathParamParameters
|
|
23
|
+
): StreamableMethod<WithOperationPathParam204Response>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Routes {
|
|
27
|
+
/** Resource for '/' has methods for the following verbs: get */
|
|
28
|
+
(path: "/"): NoOperationParams;
|
|
29
|
+
/** Resource for '/\{keyword\}' has methods for the following verbs: get */
|
|
30
|
+
(path: "/{keyword}", keyword: string): WithOperationPathParam;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type MultipleParamInServerPathClient = Client & {
|
|
34
|
+
path: Routes;
|
|
35
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import MultipleParamInServerPathClient from "./multipleParamInServerPathClient";
|
|
5
|
+
|
|
6
|
+
export * from "./multipleParamInServerPathClient";
|
|
7
|
+
export * from "./parameters";
|
|
8
|
+
export * from "./responses";
|
|
9
|
+
export * from "./clientDefinitions";
|
|
10
|
+
|
|
11
|
+
export default MultipleParamInServerPathClient;
|
package/test/integration/generated/server/path/multiple/src/multipleParamInServerPathClient.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
5
|
+
import { MultipleParamInServerPathClient } from "./clientDefinitions";
|
|
6
|
+
|
|
7
|
+
export interface MultipleParamInServerPathClientOptions extends ClientOptions {
|
|
8
|
+
apiVersion?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Initialize a new instance of `MultipleParamInServerPathClient`
|
|
13
|
+
* @param endpoint type: string, Pass in http://localhost:3000 for endpoint.
|
|
14
|
+
* @param options type: MultipleParamInServerPathClientOptions, the parameter for all optional parameters
|
|
15
|
+
*/
|
|
16
|
+
export default function createClient(
|
|
17
|
+
endpoint: string,
|
|
18
|
+
options: MultipleParamInServerPathClientOptions = {}
|
|
19
|
+
): MultipleParamInServerPathClient {
|
|
20
|
+
const apiVersion = options.apiVersion ?? "v1.0";
|
|
21
|
+
const baseUrl =
|
|
22
|
+
options.baseUrl ?? `${endpoint}/server/path/multiple/${apiVersion}`;
|
|
23
|
+
|
|
24
|
+
const userAgentInfo = `azsdk-js-multipleparam-rest/1.0.0-beta.1`;
|
|
25
|
+
const userAgentPrefix =
|
|
26
|
+
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
27
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
28
|
+
: `${userAgentInfo}`;
|
|
29
|
+
options = {
|
|
30
|
+
...options,
|
|
31
|
+
userAgentOptions: {
|
|
32
|
+
userAgentPrefix,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const client = getClient(baseUrl, options) as MultipleParamInServerPathClient;
|
|
37
|
+
|
|
38
|
+
return client;
|
|
39
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import { RequestParameters } from "@azure-rest/core-client";
|
|
5
|
+
|
|
6
|
+
export type NoOperationParamsParameters = RequestParameters;
|
|
7
|
+
export type WithOperationPathParamParameters = RequestParameters;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import { HttpResponse } from "@azure-rest/core-client";
|
|
5
|
+
|
|
6
|
+
/** There is no content to send for this request, but the headers may be useful. */
|
|
7
|
+
export interface NoOperationParams204Response extends HttpResponse {
|
|
8
|
+
status: "204";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** There is no content to send for this request, but the headers may be useful. */
|
|
12
|
+
export interface WithOperationPathParam204Response extends HttpResponse {
|
|
13
|
+
status: "204";
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
emit:
|
|
2
|
+
- "@azure-tools/typespec-ts"
|
|
3
|
+
options:
|
|
4
|
+
"@azure-tools/typespec-ts":
|
|
5
|
+
"emitter-output-dir": "{project-root}"
|
|
6
|
+
generateMetadata: false
|
|
7
|
+
generateTest: false
|
|
8
|
+
addCredentials: false
|
|
9
|
+
azureSdkForJs: false
|
|
10
|
+
isCadlTest: true
|
|
11
|
+
title: MultipleParamInServerPathClient
|
|
12
|
+
packageDetails:
|
|
13
|
+
name: "@msinternal/multipleparam"
|
|
14
|
+
description: "MultipleParameter Test Service"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import { MyOpParameters } from "./parameters";
|
|
5
|
+
import { MyOp200Response } from "./responses";
|
|
6
|
+
import { Client, StreamableMethod } from "@azure-rest/core-client";
|
|
7
|
+
|
|
8
|
+
export interface MyOp {
|
|
9
|
+
head(options?: MyOpParameters): StreamableMethod<MyOp200Response>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Routes {
|
|
13
|
+
/** Resource for '/server/path/single/myOp' has methods for the following verbs: head */
|
|
14
|
+
(path: "/server/path/single/myOp"): MyOp;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type SingleParamInServerPathClient = Client & {
|
|
18
|
+
path: Routes;
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import SingleParamInServerPathClient from "./singleParamInServerPathClient";
|
|
5
|
+
|
|
6
|
+
export * from "./singleParamInServerPathClient";
|
|
7
|
+
export * from "./parameters";
|
|
8
|
+
export * from "./responses";
|
|
9
|
+
export * from "./clientDefinitions";
|
|
10
|
+
|
|
11
|
+
export default SingleParamInServerPathClient;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
5
|
+
import { SingleParamInServerPathClient } from "./clientDefinitions";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Initialize a new instance of `SingleParamInServerPathClient`
|
|
9
|
+
* @param endpoint type: string, Need to be set as 'http://localhost:3000' in client.
|
|
10
|
+
* @param options type: ClientOptions, the parameter for all optional parameters
|
|
11
|
+
*/
|
|
12
|
+
export default function createClient(
|
|
13
|
+
endpoint: string,
|
|
14
|
+
options: ClientOptions = {}
|
|
15
|
+
): SingleParamInServerPathClient {
|
|
16
|
+
const baseUrl = options.baseUrl ?? `${endpoint}`;
|
|
17
|
+
options.apiVersion = options.apiVersion ?? "1.0.0";
|
|
18
|
+
|
|
19
|
+
const userAgentInfo = `azsdk-js-singleparam-rest/1.0.0-beta.1`;
|
|
20
|
+
const userAgentPrefix =
|
|
21
|
+
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
22
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
23
|
+
: `${userAgentInfo}`;
|
|
24
|
+
options = {
|
|
25
|
+
...options,
|
|
26
|
+
userAgentOptions: {
|
|
27
|
+
userAgentPrefix,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const client = getClient(baseUrl, options) as SingleParamInServerPathClient;
|
|
32
|
+
|
|
33
|
+
return client;
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
emit:
|
|
2
|
+
- "@azure-tools/typespec-ts"
|
|
3
|
+
options:
|
|
4
|
+
"@azure-tools/typespec-ts":
|
|
5
|
+
"emitter-output-dir": "{project-root}"
|
|
6
|
+
generateMetadata: false
|
|
7
|
+
generateTest: false
|
|
8
|
+
addCredentials: false
|
|
9
|
+
azureSdkForJs: false
|
|
10
|
+
isCadlTest: true
|
|
11
|
+
title: SingleParamInServerPathClient
|
|
12
|
+
packageDetails:
|
|
13
|
+
name: "@msinternal/singleparam"
|
|
14
|
+
description: "SingleParameter Test Service"
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
"
|
|
1
|
+
emit:
|
|
2
|
+
- "@azure-tools/typespec-ts"
|
|
3
|
+
options:
|
|
4
|
+
"@azure-tools/typespec-ts":
|
|
5
|
+
"emitter-output-dir": "{project-root}"
|
|
3
6
|
generateMetadata: false
|
|
4
7
|
generateTest: false
|
|
5
8
|
addCredentials: false
|
|
@@ -38,14 +38,14 @@ export interface SendSecondNamedUnionValue {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export interface Routes {
|
|
41
|
-
/** Resource for '/
|
|
42
|
-
(path: "/
|
|
43
|
-
/** Resource for '/
|
|
44
|
-
(path: "/
|
|
45
|
-
/** Resource for '/
|
|
46
|
-
(path: "/
|
|
47
|
-
/** Resource for '/
|
|
48
|
-
(path: "/
|
|
41
|
+
/** Resource for '/type/union/int' has methods for the following verbs: post */
|
|
42
|
+
(path: "/type/union/int"): SendInt;
|
|
43
|
+
/** Resource for '/type/union/int-array' has methods for the following verbs: post */
|
|
44
|
+
(path: "/type/union/int-array"): SendIntArray;
|
|
45
|
+
/** Resource for '/type/union/model1' has methods for the following verbs: post */
|
|
46
|
+
(path: "/type/union/model1"): SendFirstNamedUnionValue;
|
|
47
|
+
/** Resource for '/type/union/model2' has methods for the following verbs: post */
|
|
48
|
+
(path: "/type/union/model2"): SendSecondNamedUnionValue;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export type UnionsClient = Client & {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
"
|
|
1
|
+
emit:
|
|
2
|
+
- "@azure-tools/typespec-ts"
|
|
3
|
+
options:
|
|
4
|
+
"@azure-tools/typespec-ts":
|
|
5
|
+
"emitter-output-dir": "{project-root}"
|
|
3
6
|
generateMetadata: false
|
|
4
7
|
generateTest: false
|
|
5
8
|
addCredentials: false
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import InternalClientFactory, {
|
|
3
|
+
InternalClient
|
|
4
|
+
} from "./generated/internal/src/index.js";
|
|
5
|
+
describe("Internal Rest Client", () => {
|
|
6
|
+
let client: InternalClient;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
client = InternalClientFactory({
|
|
10
|
+
allowInsecureConnection: true,
|
|
11
|
+
retryOptions: {
|
|
12
|
+
maxRetries: 0
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should get internal", async () => {
|
|
18
|
+
try {
|
|
19
|
+
const result = await client.path("/azure/client-generator-core/internal/getInternal").get({
|
|
20
|
+
queryParameters: {
|
|
21
|
+
name: "get internal"
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
assert.strictEqual(result.status, "200");
|
|
25
|
+
} catch (err) {
|
|
26
|
+
assert.fail(err as string);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should post internal", async () => {
|
|
31
|
+
try {
|
|
32
|
+
const result = await client.path("/azure/client-generator-core/internal/postInternal").post({
|
|
33
|
+
body: {
|
|
34
|
+
id: 1 as any,
|
|
35
|
+
name: "post internal name"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
assert.strictEqual(result.status, "200");
|
|
39
|
+
} catch (err) {
|
|
40
|
+
assert.fail(err as string);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import SpecsAzureCoreLroStandardClientFactory, {
|
|
2
|
+
SpecsAzureCoreLroStandardClient,
|
|
3
|
+
getLongRunningPoller,
|
|
4
|
+
isUnexpected
|
|
5
|
+
} from "./generated/lro/lroCore/src/index.js";
|
|
6
|
+
import { assert } from "chai";
|
|
7
|
+
describe("AzureLroCoreClient Rest Client", () => {
|
|
8
|
+
let client: SpecsAzureCoreLroStandardClient;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
client = SpecsAzureCoreLroStandardClientFactory({
|
|
12
|
+
allowInsecureConnection: true
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should put LRO response", async () => {
|
|
17
|
+
try {
|
|
18
|
+
const initalResponse = await client
|
|
19
|
+
.path("/azure/core/lro/standard/users/{name}", "madge")
|
|
20
|
+
.put({
|
|
21
|
+
body: {
|
|
22
|
+
role: "contributor"
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const poller = await getLongRunningPoller(client, initalResponse);
|
|
26
|
+
const result = await poller.pollUntilDone();
|
|
27
|
+
assert.equal(result.status, "200");
|
|
28
|
+
assert.strictEqual(initalResponse.status, "201");
|
|
29
|
+
if (isUnexpected(result)) {
|
|
30
|
+
throw Error("Unexpected status code");
|
|
31
|
+
}
|
|
32
|
+
assert.equal(result.status, "200");
|
|
33
|
+
if (result.status === "200") {
|
|
34
|
+
assert.equal(result.body.name, "madge");
|
|
35
|
+
}
|
|
36
|
+
} catch (err) {
|
|
37
|
+
assert.fail(err as string);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should delete LRO response", async () => {
|
|
42
|
+
try {
|
|
43
|
+
const initalResponse = await client
|
|
44
|
+
.path("/azure/core/lro/standard/users/{name}", "madge")
|
|
45
|
+
.delete({
|
|
46
|
+
body: {
|
|
47
|
+
role: "contributor"
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const poller = await getLongRunningPoller(client, initalResponse);
|
|
51
|
+
const result = await poller.pollUntilDone();
|
|
52
|
+
assert.equal(result.status, "200");
|
|
53
|
+
assert.strictEqual(initalResponse.status, "202");
|
|
54
|
+
if (isUnexpected(result)) {
|
|
55
|
+
throw Error("Unexpected status code");
|
|
56
|
+
}
|
|
57
|
+
if (result.status === "200") {
|
|
58
|
+
assert.equal(result.body.status, "Succeeded");
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {
|
|
61
|
+
assert.fail(err as string);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should export LRO response", async () => {
|
|
66
|
+
try {
|
|
67
|
+
const initalResponse = await client
|
|
68
|
+
.path("/azure/core/lro/standard/users/{name}:export", "madge")
|
|
69
|
+
.post({
|
|
70
|
+
queryParameters: {
|
|
71
|
+
format: "json"
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const poller = await getLongRunningPoller(client, initalResponse);
|
|
75
|
+
const result = await poller.pollUntilDone();
|
|
76
|
+
assert.equal(result.status, "200");
|
|
77
|
+
assert.strictEqual(initalResponse.status, "202");
|
|
78
|
+
if (isUnexpected(result)) {
|
|
79
|
+
throw Error("Unexpected status code");
|
|
80
|
+
}
|
|
81
|
+
assert.equal(result.status, "200", "final status code");
|
|
82
|
+
if (result.status === "200") {
|
|
83
|
+
assert.equal(result.body.result?.name, "madge");
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
assert.fail(err as string);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import TypeModelInheritanceClientFactory, {
|
|
2
|
+
TypeModelInheritanceClient,
|
|
3
3
|
Salmon,
|
|
4
4
|
SharkOutput
|
|
5
5
|
} from "./generated/models/inheritance/src/index.js";
|
|
6
6
|
import { assert } from "chai";
|
|
7
7
|
|
|
8
8
|
describe("ModelsInheritance Rest Client", () => {
|
|
9
|
-
let client:
|
|
9
|
+
let client: TypeModelInheritanceClient;
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
|
-
client =
|
|
12
|
+
client = TypeModelInheritanceClientFactory({
|
|
13
13
|
allowInsecureConnection: true
|
|
14
14
|
});
|
|
15
15
|
});
|
|
@@ -17,7 +17,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
17
17
|
const validBody = { name: "abc", age: 32, smart: true };
|
|
18
18
|
it("should get valid", async () => {
|
|
19
19
|
try {
|
|
20
|
-
const result = await client.path("/
|
|
20
|
+
const result = await client.path("/type/model/inheritance/valid").get();
|
|
21
21
|
assert.strictEqual(result.status, "200");
|
|
22
22
|
assert.strictEqual(result.body.age, 32);
|
|
23
23
|
assert.strictEqual(result.body.name, "abc");
|
|
@@ -29,7 +29,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
29
29
|
|
|
30
30
|
it("should put valid", async () => {
|
|
31
31
|
try {
|
|
32
|
-
const result = await client.path("/
|
|
32
|
+
const result = await client.path("/type/model/inheritance/valid").put({
|
|
33
33
|
body: validBody
|
|
34
34
|
});
|
|
35
35
|
assert.strictEqual(result.status, "200");
|
|
@@ -43,7 +43,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
43
43
|
|
|
44
44
|
it("should post valid", async () => {
|
|
45
45
|
try {
|
|
46
|
-
const result = await client.path("/
|
|
46
|
+
const result = await client.path("/type/model/inheritance/valid").post({
|
|
47
47
|
body: validBody
|
|
48
48
|
});
|
|
49
49
|
assert.strictEqual(result.status, "200");
|
|
@@ -55,7 +55,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
55
55
|
it("should get polymorphic body", async () => {
|
|
56
56
|
try {
|
|
57
57
|
const result = await client
|
|
58
|
-
.path("/
|
|
58
|
+
.path("/type/model/inheritance/discriminated/model")
|
|
59
59
|
.get();
|
|
60
60
|
assert.strictEqual(result.status, "200");
|
|
61
61
|
assert.strictEqual(result.body.age, 1);
|
|
@@ -69,7 +69,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
69
69
|
it("should put polymorphic body", async () => {
|
|
70
70
|
try {
|
|
71
71
|
const result = await client
|
|
72
|
-
.path("/
|
|
72
|
+
.path("/type/model/inheritance/discriminated/model")
|
|
73
73
|
.put({
|
|
74
74
|
body: {
|
|
75
75
|
age: 1,
|
|
@@ -143,7 +143,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
143
143
|
it("should get recursive body", async () => {
|
|
144
144
|
try {
|
|
145
145
|
const result = await client
|
|
146
|
-
.path("/
|
|
146
|
+
.path("/type/model/inheritance/discriminated/recursivemodel")
|
|
147
147
|
.get();
|
|
148
148
|
assert.strictEqual(result.status, "200");
|
|
149
149
|
assert.strictEqual(JSON.stringify(result.body), JSON.stringify(validRecursiveBody));
|
|
@@ -155,7 +155,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
155
155
|
it("should put recursive body", async () => {
|
|
156
156
|
try {
|
|
157
157
|
const result = await client
|
|
158
|
-
.path("/
|
|
158
|
+
.path("/type/model/inheritance/discriminated/recursivemodel")
|
|
159
159
|
.put({
|
|
160
160
|
body: validRecursiveBody as Salmon
|
|
161
161
|
});
|
|
@@ -168,7 +168,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
168
168
|
it("should get missing discriminator body", async () => {
|
|
169
169
|
try {
|
|
170
170
|
const result = await client
|
|
171
|
-
.path("/
|
|
171
|
+
.path("/type/model/inheritance/discriminated/missingdiscriminator")
|
|
172
172
|
.get();
|
|
173
173
|
assert.strictEqual(result.status, "200");
|
|
174
174
|
assert.strictEqual(result.body.age, 1);
|
|
@@ -180,7 +180,7 @@ describe("ModelsInheritance Rest Client", () => {
|
|
|
180
180
|
it("should get wrong discriminator body", async () => {
|
|
181
181
|
try {
|
|
182
182
|
const result = await client
|
|
183
|
-
.path("/
|
|
183
|
+
.path("/type/model/inheritance/discriminated/wrongdiscriminator")
|
|
184
184
|
.get();
|
|
185
185
|
assert.strictEqual(result.status, "200");
|
|
186
186
|
assert.strictEqual(result.body.age, 1);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import TypePropertyNullableClientFactory, {
|
|
3
|
+
TypePropertyNullableClient
|
|
4
|
+
} from "./generated/models/propertyNullable/src/index.js";
|
|
5
|
+
import { matrix } from "../util/matrix.js";
|
|
6
|
+
|
|
7
|
+
interface TypeDetail {
|
|
8
|
+
type: string;
|
|
9
|
+
defaultValue: any;
|
|
10
|
+
convertedToFn?: (_: any) => any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const testedTypes: TypeDetail[] = [
|
|
14
|
+
{
|
|
15
|
+
type: "string",
|
|
16
|
+
defaultValue: "hello"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "bytes",
|
|
20
|
+
defaultValue: "aGVsbG8sIHdvcmxkIQ=="
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "datetime",
|
|
24
|
+
defaultValue: "2022-08-26T18:38:00Z"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "duration",
|
|
28
|
+
defaultValue: "P123DT22H14M12.011S"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "collections/bytes",
|
|
32
|
+
defaultValue: ["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "collections/model",
|
|
36
|
+
defaultValue: [{ property: "hello" }, { property: "world" }]
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
describe("ModelsPropertyNullableClient Rest Client", () => {
|
|
40
|
+
let client: TypePropertyNullableClient;
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
client = TypePropertyNullableClientFactory({
|
|
44
|
+
allowInsecureConnection: true
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
matrix([testedTypes], async (params: TypeDetail) => {
|
|
49
|
+
it(`should get a null value for nullable ${params.type}`, async () => {
|
|
50
|
+
try {
|
|
51
|
+
const result = await client
|
|
52
|
+
.path(`/type/property/nullable/${params.type}/null` as any)
|
|
53
|
+
.get();
|
|
54
|
+
assert.strictEqual(result.status, "200");
|
|
55
|
+
assert.strictEqual(result.body.nullableProperty, null);
|
|
56
|
+
assert.deepEqual(result.body.requiredProperty, "foo");
|
|
57
|
+
} catch (err) {
|
|
58
|
+
assert.fail(err as string);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it(`should get a non-null value for nullable ${params.type}`, async () => {
|
|
63
|
+
try {
|
|
64
|
+
const result = await client
|
|
65
|
+
.path(`/type/property/nullable/${params.type}/non-null` as any)
|
|
66
|
+
.get();
|
|
67
|
+
assert.strictEqual(result.status, "200");
|
|
68
|
+
assert.deepEqual(result.body.nullableProperty, params.defaultValue);
|
|
69
|
+
assert.deepEqual(result.body.requiredProperty, "foo");
|
|
70
|
+
} catch (err) {
|
|
71
|
+
assert.fail(err as string);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it(`should patch a null value for nullable ${params.type}`, async () => {
|
|
76
|
+
try {
|
|
77
|
+
const result = await client
|
|
78
|
+
.path(`/type/property/nullable/${params.type}/null` as any)
|
|
79
|
+
.patch({
|
|
80
|
+
contentType: "application/merge-patch+json",
|
|
81
|
+
body: {
|
|
82
|
+
requiredProperty: "foo",
|
|
83
|
+
nullableProperty: null
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
assert.strictEqual(result.status, "204");
|
|
87
|
+
} catch (err) {
|
|
88
|
+
assert.fail(err as string);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it(`should patch a non-null value for nullable ${params.type}`, async () => {
|
|
93
|
+
try {
|
|
94
|
+
let property;
|
|
95
|
+
if (params.convertedToFn) {
|
|
96
|
+
property = params.convertedToFn(params.defaultValue);
|
|
97
|
+
} else {
|
|
98
|
+
property = params.defaultValue;
|
|
99
|
+
}
|
|
100
|
+
const result = await client
|
|
101
|
+
.path(`/type/property/nullable/${params.type}/non-null` as any)
|
|
102
|
+
.patch({
|
|
103
|
+
contentType: "application/merge-patch+json",
|
|
104
|
+
body: {
|
|
105
|
+
requiredProperty: "foo",
|
|
106
|
+
nullableProperty: property || null
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
assert.strictEqual(result.status, "204");
|
|
110
|
+
} catch (err) {
|
|
111
|
+
assert.fail(err as string);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|