@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.
Files changed (269) hide show
  1. package/.rush/temp/operation/build/all.log +1 -0
  2. package/.rush/temp/operation/build/state.json +3 -0
  3. package/.rush/temp/package-deps_build.json +205 -190
  4. package/.rush/temp/shrinkwrap-deps.json +488 -471
  5. package/CHANGELOG.md +7 -0
  6. package/dist/src/index.d.ts.map +1 -1
  7. package/dist/src/index.js +2 -1
  8. package/dist/src/index.js.map +1 -1
  9. package/dist/src/modelUtils.d.ts +1 -1
  10. package/dist/src/modelUtils.d.ts.map +1 -1
  11. package/dist/src/modelUtils.js +79 -56
  12. package/dist/src/modelUtils.js.map +1 -1
  13. package/dist/src/operationUtil.d.ts +26 -0
  14. package/dist/src/operationUtil.d.ts.map +1 -1
  15. package/dist/src/operationUtil.js +76 -17
  16. package/dist/src/operationUtil.js.map +1 -1
  17. package/dist/src/transform/transform.d.ts.map +1 -1
  18. package/dist/src/transform/transform.js +9 -6
  19. package/dist/src/transform/transform.js.map +1 -1
  20. package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
  21. package/dist/src/transform/transformApiVersionInfo.js +3 -3
  22. package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
  23. package/dist/src/transform/transformHelperFunctionDetails.d.ts +6 -0
  24. package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -0
  25. package/dist/src/transform/{transformAnnotationDetails.js → transformHelperFunctionDetails.js} +2 -2
  26. package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -0
  27. package/dist/src/transform/transformParameters.d.ts.map +1 -1
  28. package/dist/src/transform/transformParameters.js +41 -33
  29. package/dist/src/transform/transformParameters.js.map +1 -1
  30. package/dist/src/transform/transformPaths.d.ts.map +1 -1
  31. package/dist/src/transform/transformPaths.js +20 -12
  32. package/dist/src/transform/transformPaths.js.map +1 -1
  33. package/dist/src/transform/transformResponses.d.ts.map +1 -1
  34. package/dist/src/transform/transformResponses.js +29 -8
  35. package/dist/src/transform/transformResponses.js.map +1 -1
  36. package/dist/src/transform/transformSchemas.js +1 -1
  37. package/dist/src/transform/transformSchemas.js.map +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +41 -38
  40. package/src/index.ts +2 -0
  41. package/src/modelUtils.ts +143 -47
  42. package/src/operationUtil.ts +111 -22
  43. package/src/transform/transform.ts +20 -5
  44. package/src/transform/transformApiVersionInfo.ts +18 -3
  45. package/src/transform/{transformAnnotationDetails.ts → transformHelperFunctionDetails.ts} +3 -3
  46. package/src/transform/transformParameters.ts +71 -20
  47. package/src/transform/transformPaths.ts +30 -15
  48. package/src/transform/transformResponses.ts +50 -6
  49. package/src/transform/transformSchemas.ts +1 -1
  50. package/test/commands/cadl-ranch-list.ts +25 -28
  51. package/test/commands/gen-cadl-ranch.ts +6 -2
  52. package/test/integration/arrayItemTypes.spec.ts +2 -2
  53. package/test/integration/azurecore.spec.ts +64 -24
  54. package/test/integration/collectionFormat.spec.ts +44 -0
  55. package/test/integration/dictionary.spec.ts +2 -2
  56. package/test/integration/extensibleEnums.spec.ts +8 -8
  57. package/test/integration/fixedEnums.spec.ts +7 -7
  58. package/test/integration/generated/arrays/itemTypes/src/arrayItemTypesClient.ts +5 -1
  59. package/test/integration/generated/arrays/itemTypes/src/clientDefinitions.ts +20 -20
  60. package/test/integration/generated/arrays/itemTypes/src/logger.ts +5 -0
  61. package/test/integration/generated/authentication/apiKey/package.json +1 -1
  62. package/test/integration/generated/authentication/apiKey/src/authApiKeyClient.ts +6 -2
  63. package/test/integration/generated/authentication/apiKey/src/logger.ts +5 -0
  64. package/test/integration/generated/authentication/oauth2/src/authOauth2Client.ts +6 -2
  65. package/test/integration/generated/authentication/oauth2/src/logger.ts +5 -0
  66. package/test/integration/generated/authentication/union/src/authUnionClient.ts +6 -2
  67. package/test/integration/generated/authentication/union/src/logger.ts +5 -0
  68. package/test/integration/generated/azure/core/package.json +1 -1
  69. package/test/integration/generated/azure/core/src/azureCoreClient.ts +5 -1
  70. package/test/integration/generated/azure/core/src/clientDefinitions.ts +22 -8
  71. package/test/integration/generated/azure/core/src/isUnexpected.ts +18 -7
  72. package/test/integration/generated/azure/core/src/logger.ts +5 -0
  73. package/test/integration/generated/azure/core/src/outputModels.ts +7 -0
  74. package/test/integration/generated/azure/core/src/paginateHelper.ts +55 -5
  75. package/test/integration/generated/azure/core/src/parameters.ts +1 -0
  76. package/test/integration/generated/azure/core/src/responses.ts +23 -1
  77. package/test/integration/generated/azure/core-traits/package.json +1 -1
  78. package/test/integration/generated/azure/core-traits/src/azureCoreTraitsClient.ts +5 -1
  79. package/test/integration/generated/azure/core-traits/src/clientDefinitions.ts +7 -25
  80. package/test/integration/generated/azure/core-traits/src/isUnexpected.ts +6 -19
  81. package/test/integration/generated/azure/core-traits/src/logger.ts +5 -0
  82. package/test/integration/generated/azure/core-traits/src/outputModels.ts +15 -0
  83. package/test/integration/generated/azure/core-traits/src/parameters.ts +4 -19
  84. package/test/integration/generated/azure/core-traits/src/responses.ts +6 -30
  85. package/test/integration/generated/dictionary/package.json +1 -1
  86. package/test/integration/generated/dictionary/src/clientDefinitions.ts +22 -22
  87. package/test/integration/generated/dictionary/src/dictClient.ts +5 -1
  88. package/test/integration/generated/dictionary/src/logger.ts +5 -0
  89. package/test/integration/generated/enums/extensible/README.md +3 -3
  90. package/test/integration/generated/enums/extensible/package.json +1 -1
  91. package/test/integration/generated/enums/extensible/src/clientDefinitions.ts +5 -5
  92. package/test/integration/generated/enums/extensible/src/index.ts +3 -3
  93. package/test/integration/generated/enums/extensible/src/logger.ts +5 -0
  94. package/test/integration/generated/enums/extensible/src/{enumsExtensible.ts → typeEnumExtensible.ts} +9 -5
  95. package/test/integration/generated/enums/fixed/README.md +3 -3
  96. package/test/integration/generated/enums/fixed/package.json +1 -1
  97. package/test/integration/generated/enums/fixed/src/clientDefinitions.ts +5 -5
  98. package/test/integration/generated/enums/fixed/src/index.ts +3 -3
  99. package/test/integration/generated/enums/fixed/src/logger.ts +5 -0
  100. package/test/integration/generated/enums/fixed/src/{enumsFixed.ts → typeEnumFixed.ts} +9 -5
  101. package/test/integration/generated/internal/src/clientDefinitions.ts +38 -12
  102. package/test/integration/generated/internal/src/index.ts +0 -1
  103. package/test/integration/generated/internal/src/internalClient.ts +5 -1
  104. package/test/integration/generated/internal/src/logger.ts +5 -0
  105. package/test/integration/generated/internal/src/outputModels.ts +9 -5
  106. package/test/integration/generated/internal/src/parameters.ts +32 -8
  107. package/test/integration/generated/internal/src/responses.ts +18 -5
  108. package/test/integration/generated/lro/lroCore/README.md +3 -3
  109. package/test/integration/generated/lro/lroCore/package.json +2 -2
  110. package/test/integration/generated/lro/lroCore/src/clientDefinitions.ts +8 -5
  111. package/test/integration/generated/lro/lroCore/src/index.ts +3 -3
  112. package/test/integration/generated/lro/lroCore/src/isUnexpected.ts +14 -7
  113. package/test/integration/generated/lro/lroCore/src/logger.ts +5 -0
  114. package/test/integration/generated/lro/lroCore/src/pollingHelper.ts +38 -0
  115. package/test/integration/generated/lro/lroCore/src/responses.ts +18 -0
  116. package/test/integration/generated/lro/lroCore/src/{azureLroCore.ts → specsAzureCoreLroStandard.ts} +9 -5
  117. package/test/integration/generated/lro/{lroBasic → lroRPC}/README.md +7 -7
  118. package/test/integration/generated/lro/{lroBasic → lroRPC}/api-extractor.json +1 -1
  119. package/test/integration/generated/lro/{lroBasic → lroRPC}/package.json +6 -6
  120. package/test/integration/generated/lro/lroRPC/src/clientDefinitions.ts +79 -0
  121. package/test/integration/generated/{resiliency/devDriven → lro/lroRPC}/src/index.ts +4 -4
  122. package/test/integration/generated/{resiliency/devDriven → lro/lroRPC}/src/isUnexpected.ts +57 -21
  123. package/test/integration/generated/lro/lroRPC/src/logger.ts +5 -0
  124. package/test/integration/generated/lro/lroRPC/src/models.ts +8 -0
  125. package/test/integration/generated/lro/lroRPC/src/outputModels.ts +40 -0
  126. package/test/integration/generated/lro/lroRPC/src/parameters.ts +20 -0
  127. package/test/integration/generated/lro/{lroBasic → lroRPC}/src/pollingHelper.ts +52 -0
  128. package/test/integration/generated/lro/lroRPC/src/responses.ts +124 -0
  129. package/test/integration/generated/lro/lroRPC/src/specsAzureCoreLroRpc.ts +35 -0
  130. package/test/integration/generated/lro/{lroBasic → lroRPC}/tspconfig.yaml +2 -2
  131. package/test/integration/generated/models/inheritance/README.md +3 -3
  132. package/test/integration/generated/models/inheritance/package.json +1 -1
  133. package/test/integration/generated/models/inheritance/src/clientDefinitions.ts +13 -11
  134. package/test/integration/generated/models/inheritance/src/index.ts +3 -3
  135. package/test/integration/generated/models/inheritance/src/logger.ts +5 -0
  136. package/test/integration/generated/models/inheritance/src/{modelsInheritance.ts → typeModelInheritance.ts} +9 -5
  137. package/test/integration/generated/models/propertyNullable/README.md +3 -3
  138. package/test/integration/generated/models/propertyNullable/package.json +1 -1
  139. package/test/integration/generated/models/propertyNullable/src/clientDefinitions.ts +43 -43
  140. package/test/integration/generated/models/propertyNullable/src/index.ts +3 -3
  141. package/test/integration/generated/models/propertyNullable/src/logger.ts +5 -0
  142. package/test/integration/generated/models/propertyNullable/src/parameters.ts +14 -12
  143. package/test/integration/generated/models/propertyNullable/src/responses.ts +4 -4
  144. package/test/integration/generated/models/propertyNullable/src/{modelsPropertyNullable.ts → typePropertyNullable.ts} +9 -5
  145. package/test/integration/generated/models/propertyOptional/README.md +3 -3
  146. package/test/integration/generated/models/propertyOptional/package.json +1 -1
  147. package/test/integration/generated/models/propertyOptional/src/clientDefinitions.ts +47 -47
  148. package/test/integration/generated/models/propertyOptional/src/index.ts +3 -3
  149. package/test/integration/generated/models/propertyOptional/src/logger.ts +5 -0
  150. package/test/integration/generated/models/propertyOptional/src/parameters.ts +7 -6
  151. package/test/integration/generated/models/propertyOptional/src/responses.ts +4 -4
  152. package/test/integration/generated/models/propertyOptional/src/{modelsPropertyOptional.ts → typePropertyOptional.ts} +9 -5
  153. package/test/integration/generated/models/propertyTypes/README.md +3 -3
  154. package/test/integration/generated/models/propertyTypes/package.json +1 -1
  155. package/test/integration/generated/models/propertyTypes/src/clientDefinitions.ts +123 -47
  156. package/test/integration/generated/models/propertyTypes/src/index.ts +3 -3
  157. package/test/integration/generated/models/propertyTypes/src/logger.ts +5 -0
  158. package/test/integration/generated/models/propertyTypes/src/models.ts +24 -0
  159. package/test/integration/generated/models/propertyTypes/src/outputModels.ts +24 -0
  160. package/test/integration/generated/models/propertyTypes/src/parameters.ts +48 -6
  161. package/test/integration/generated/models/propertyTypes/src/responses.ts +52 -4
  162. package/test/integration/generated/models/propertyTypes/src/{modelsPropertyTypes.ts → typePropertyValueTypes.ts} +9 -5
  163. package/test/integration/generated/models/usage/README.md +3 -3
  164. package/test/integration/generated/models/usage/package.json +1 -1
  165. package/test/integration/generated/models/usage/src/clientDefinitions.ts +7 -7
  166. package/test/integration/generated/models/usage/src/index.ts +3 -3
  167. package/test/integration/generated/models/usage/src/logger.ts +5 -0
  168. package/test/integration/generated/models/usage/src/{modelsUsage.ts → typeModelUsage.ts} +9 -5
  169. package/test/integration/generated/models/visibility/README.md +3 -3
  170. package/test/integration/generated/models/visibility/package.json +1 -1
  171. package/test/integration/generated/models/visibility/src/clientDefinitions.ts +3 -3
  172. package/test/integration/generated/models/visibility/src/index.ts +3 -3
  173. package/test/integration/generated/models/visibility/src/logger.ts +5 -0
  174. package/test/integration/generated/models/visibility/src/{modelsVisibilityAutomatic.ts → typeModelVisibility.ts} +9 -5
  175. package/test/integration/generated/parameters/collection-format/src/clientDefinitions.ts +24 -0
  176. package/test/integration/generated/parameters/collection-format/src/collectionFormatClient.ts +5 -1
  177. package/test/integration/generated/parameters/collection-format/src/logger.ts +5 -0
  178. package/test/integration/generated/parameters/collection-format/src/parameters.ts +33 -0
  179. package/test/integration/generated/parameters/collection-format/src/responses.ts +15 -0
  180. package/test/integration/generated/parameters/collection-format/src/serializeHelper.ts +12 -0
  181. package/test/integration/generated/parameters/spread/src/clientDefinitions.ts +61 -0
  182. package/test/integration/generated/{lro/lroBasic → parameters/spread}/src/index.ts +4 -5
  183. package/test/integration/generated/parameters/spread/src/logger.ts +5 -0
  184. package/test/integration/generated/{lro/lroBasic/src/outputModels.ts → parameters/spread/src/models.ts} +2 -3
  185. package/test/integration/generated/parameters/spread/src/parameters.ts +61 -0
  186. package/test/integration/generated/{lro/lroBasic/src/azureLro.ts → parameters/spread/src/parametersSpread.ts} +10 -6
  187. package/test/integration/generated/parameters/spread/src/responses.ts +25 -0
  188. package/test/integration/generated/{resiliency/devDriven → parameters/spread}/tspconfig.yaml +2 -4
  189. package/test/integration/generated/projection/src/clientDefinitions.ts +47 -21
  190. package/test/integration/generated/projection/src/logger.ts +5 -0
  191. package/test/integration/generated/projection/src/models.ts +18 -7
  192. package/test/integration/generated/projection/src/parameters.ts +32 -10
  193. package/test/integration/generated/projection/src/projectionClient.ts +5 -1
  194. package/test/integration/generated/projection/src/responses.ts +18 -3
  195. package/test/integration/generated/resiliency/srvDriven1/README.md +4 -4
  196. package/test/integration/generated/resiliency/srvDriven1/package.json +1 -1
  197. package/test/integration/generated/resiliency/srvDriven1/src/clientDefinitions.ts +25 -49
  198. package/test/integration/generated/resiliency/srvDriven1/src/index.ts +3 -5
  199. package/test/integration/generated/resiliency/srvDriven1/src/logger.ts +5 -0
  200. package/test/integration/generated/resiliency/srvDriven1/src/parameters.ts +11 -32
  201. package/test/integration/generated/resiliency/srvDriven1/src/responses.ts +9 -24
  202. package/test/integration/generated/resiliency/srvDriven1/src/serviceDrivenOldClient.ts +43 -0
  203. package/test/integration/generated/resiliency/srvDriven1/tspconfig.yaml +1 -0
  204. package/test/integration/generated/resiliency/srvDriven2/README.md +13 -4
  205. package/test/integration/generated/resiliency/srvDriven2/package.json +1 -1
  206. package/test/integration/generated/resiliency/srvDriven2/src/clientDefinitions.ts +32 -68
  207. package/test/integration/generated/resiliency/srvDriven2/src/index.ts +3 -5
  208. package/test/integration/generated/resiliency/srvDriven2/src/logger.ts +5 -0
  209. package/test/integration/generated/resiliency/srvDriven2/src/parameters.ts +19 -42
  210. package/test/integration/generated/resiliency/srvDriven2/src/responses.ts +10 -31
  211. package/test/integration/generated/resiliency/srvDriven2/src/serviceDrivenNewClient.ts +43 -0
  212. package/test/integration/generated/resiliency/srvDriven2/tspconfig.yaml +1 -0
  213. package/test/integration/generated/server/path/multiple/src/logger.ts +5 -0
  214. package/test/integration/generated/server/path/multiple/src/multipleParamInServerPathClient.ts +6 -2
  215. package/test/integration/generated/server/path/single/src/logger.ts +5 -0
  216. package/test/integration/generated/server/path/single/src/singleParamInServerPathClient.ts +6 -2
  217. package/test/integration/generated/specialWords/src/logger.ts +5 -0
  218. package/test/integration/generated/specialWords/src/specialWordsClient.ts +5 -1
  219. package/test/integration/generated/unions/src/clientDefinitions.ts +8 -8
  220. package/test/integration/generated/unions/src/logger.ts +5 -0
  221. package/test/integration/generated/unions/src/unionsClient.ts +5 -1
  222. package/test/integration/internal.spec.ts +45 -12
  223. package/test/integration/lroCore.spec.ts +89 -0
  224. package/test/integration/modelInheritance.spec.ts +13 -13
  225. package/test/integration/modelPropertyNullable.spec.ts +8 -8
  226. package/test/integration/modelPropertyOptional.spec.ts +32 -32
  227. package/test/integration/modelPropertyType.spec.ts +22 -6
  228. package/test/integration/modelUsage.spec.ts +7 -7
  229. package/test/integration/projection.spec.ts +62 -15
  230. package/test/integration/resiliencyDpgCustomization.spec.ts +133 -38
  231. package/test/integration/spreadParameters.spec.ts +82 -0
  232. package/test/integration/unions.spec.ts +4 -4
  233. package/test/unit/apiVersion.spec.ts +19 -7
  234. package/test/unit/clientFactoryGenerator.spec.ts +44 -16
  235. package/test/unit/modelsGenerator.spec.ts +212 -2
  236. package/test/unit/util/emitUtil.ts +13 -4
  237. package/test/unit/util/testUtil.ts +7 -2
  238. package/typespec-ts.build.log +0 -1
  239. package/dist/src/transform/transformAnnotationDetails.d.ts +0 -6
  240. package/dist/src/transform/transformAnnotationDetails.d.ts.map +0 -1
  241. package/dist/src/transform/transformAnnotationDetails.js.map +0 -1
  242. package/test/integration/generated/internal/src/models.ts +0 -8
  243. package/test/integration/generated/lro/lroBasic/src/clientDefinitions.ts +0 -37
  244. package/test/integration/generated/lro/lroBasic/src/parameters.ts +0 -8
  245. package/test/integration/generated/lro/lroBasic/src/responses.ts +0 -23
  246. package/test/integration/generated/resiliency/devDriven/.eslintrc.json +0 -11
  247. package/test/integration/generated/resiliency/devDriven/README.md +0 -56
  248. package/test/integration/generated/resiliency/devDriven/api-extractor.json +0 -18
  249. package/test/integration/generated/resiliency/devDriven/package.json +0 -81
  250. package/test/integration/generated/resiliency/devDriven/rollup.config.js +0 -118
  251. package/test/integration/generated/resiliency/devDriven/src/clientDefinitions.ts +0 -75
  252. package/test/integration/generated/resiliency/devDriven/src/models.ts +0 -8
  253. package/test/integration/generated/resiliency/devDriven/src/outputModels.ts +0 -25
  254. package/test/integration/generated/resiliency/devDriven/src/paginateHelper.ts +0 -154
  255. package/test/integration/generated/resiliency/devDriven/src/parameters.ts +0 -17
  256. package/test/integration/generated/resiliency/devDriven/src/resiliencyDevDriven.ts +0 -31
  257. package/test/integration/generated/resiliency/devDriven/src/responses.ts +0 -62
  258. package/test/integration/generated/resiliency/devDriven/tsconfig.json +0 -25
  259. package/test/integration/generated/resiliency/srvDriven1/src/models.ts +0 -6
  260. package/test/integration/generated/resiliency/srvDriven1/src/outputModels.ts +0 -6
  261. package/test/integration/generated/resiliency/srvDriven1/src/resiliencyServiceDriven1.ts +0 -31
  262. package/test/integration/generated/resiliency/srvDriven2/src/models.ts +0 -6
  263. package/test/integration/generated/resiliency/srvDriven2/src/outputModels.ts +0 -6
  264. package/test/integration/generated/resiliency/srvDriven2/src/resiliencyServiceDriven2.ts +0 -31
  265. package/test/integration/helloWorld.spec.ts +0 -20
  266. package/test/integration/lroBasic.spec.ts +0 -25
  267. /package/test/integration/generated/lro/{lroBasic → lroRPC}/.eslintrc.json +0 -0
  268. /package/test/integration/generated/lro/{lroBasic → lroRPC}/rollup.config.js +0 -0
  269. /package/test/integration/generated/lro/{lroBasic → lroRPC}/tsconfig.json +0 -0
@@ -1,20 +1,20 @@
1
- import ModelsUsageClientFactory, {
2
- ModelsUsageClient
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: ModelsUsageClient;
6
+ let client: TypeModelUsageClient;
7
7
  const body = {
8
8
  requiredProp: "example-value"
9
9
  };
10
10
 
11
11
  beforeEach(() => {
12
- client = ModelsUsageClientFactory({ allowInsecureConnection: true });
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("/models/usage/input").post({
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("/models/usage/output").get();
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("/models/usage/input-output")
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.path("/projection/json").post({
20
- body: {
21
- codegen: "DPG"
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.path("/projection/client").post({
33
- body: {
34
- builtfrom: "DPG"
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.path("/projection/language").post({
46
- body: {
47
- wasMadeFor: "customers"
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 ResiliencyDevDrivenClientFactory, {
3
- ResiliencyDevDrivenClient
4
- } from "./generated/resiliency/devDriven/src/index.js";
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 client: ResiliencyDevDrivenClient;
9
+ let client11: ServiceDrivenOldClient;
10
+ let client12: ServiceDrivenOldClient;
11
+ let client21: ServiceDrivenNewClient;
12
+ let client22: ServiceDrivenNewClient;
7
13
 
8
14
  beforeEach(() => {
9
- client = ResiliencyDevDrivenClientFactory({
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
- describe("dpg customization with raw model", () => {
15
- // comment out these test cases because the server is not ready
16
- // https://github.com/Azure/autorest.typescript/issues/1535
17
- xit("should get model", async () => {
18
- const result = await client
19
- .path("/resiliency/devdriven/customization/model/{mode}", "raw")
20
- .get();
21
- console.log(result);
22
- assert.equal(result.status, "200");
23
- assert.equal(result.body.received, "raw");
24
- });
25
-
26
- xit("should post model", async () => {
27
- const result = await client
28
- .path("/resiliency/devdriven/customization/model/{mode}", "raw")
29
- .post({ body: { hello: "world!" } });
30
- assert.equal(result.status, "200");
31
- assert.equal(result.body.received, "raw");
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
- describe("dpg customization with model model", () => {
36
- xit("should get model", async () => {
37
- const result = await client
38
- .path("/resiliency/devdriven/customization/model/{mode}", "model")
39
- .get();
40
- assert.equal(result.status, "200");
41
- assert.equal(result.body.received, "model");
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
- xit("should post model", async () => {
45
- const result = await client
46
- .path("/resiliency/devdriven/customization/model/{mode}", "model")
47
- .post({ body: { hello: "world!" } });
48
- assert.equal(result.status, "200");
49
- assert.equal(result.body.received, "model");
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("/unions/int").post({
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("/unions/int-array").post({
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("/unions/model1").post({
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("/unions/model2").post({
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 type: string, The endpoint to use.
138
- * @param options type: ClientOptions, the parameter for all optional parameters
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 type: string, The endpoint to use.
177
- * @param options type: testClientOptions, the parameter for all optional parameters
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 type: string, The endpoint to use.
212
- * @param apiVersion type: string, Api Version Possible values: 2022-05-15-preview
213
- * @param options type: ClientOptions, the parameter for all optional parameters
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;