@azure-tools/typespec-ts 0.38.3 → 0.38.4-alpha.20250307.2

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 (51) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +16 -16
  3. package/dist/src/index.d.ts.map +1 -1
  4. package/dist/src/index.js +10 -8
  5. package/dist/src/index.js.map +1 -1
  6. package/dist/src/lib.d.ts +71 -2
  7. package/dist/src/lib.d.ts.map +1 -1
  8. package/dist/src/lib.js +108 -1
  9. package/dist/src/lib.js.map +1 -1
  10. package/dist/src/modular/buildClientContext.js +1 -1
  11. package/dist/src/modular/buildClientContext.js.map +1 -1
  12. package/dist/src/modular/emitModels.d.ts +1 -1
  13. package/dist/src/modular/emitModels.d.ts.map +1 -1
  14. package/dist/src/modular/emitModels.js +25 -7
  15. package/dist/src/modular/emitModels.js.map +1 -1
  16. package/dist/src/modular/emitSamples.js +1 -1
  17. package/dist/src/modular/emitSamples.js.map +1 -1
  18. package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +1 -1
  19. package/dist/src/modular/helpers/classicalOperationHelpers.js +1 -1
  20. package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
  21. package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
  22. package/dist/src/modular/helpers/operationHelpers.js +44 -20
  23. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  24. package/dist/src/modular/static-helpers-metadata.d.ts +7 -0
  25. package/dist/src/modular/static-helpers-metadata.d.ts.map +1 -1
  26. package/dist/src/modular/static-helpers-metadata.js +7 -0
  27. package/dist/src/modular/static-helpers-metadata.js.map +1 -1
  28. package/dist/src/transform/transform.d.ts.map +1 -1
  29. package/dist/src/transform/transform.js +4 -0
  30. package/dist/src/transform/transform.js.map +1 -1
  31. package/dist/src/transform/transfromRLCOptions.d.ts +4 -0
  32. package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
  33. package/dist/src/transform/transfromRLCOptions.js +283 -29
  34. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  35. package/dist/src/utils/operationUtil.d.ts.map +1 -1
  36. package/dist/src/utils/operationUtil.js +2 -4
  37. package/dist/src/utils/operationUtil.js.map +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +23 -23
  40. package/src/index.ts +11 -4
  41. package/src/lib.ts +167 -2
  42. package/src/modular/buildClientContext.ts +5 -1
  43. package/src/modular/emitModels.ts +42 -10
  44. package/src/modular/emitSamples.ts +1 -1
  45. package/src/modular/helpers/classicalOperationHelpers.ts +5 -4
  46. package/src/modular/helpers/operationHelpers.ts +66 -30
  47. package/src/modular/static-helpers-metadata.ts +7 -0
  48. package/src/transform/transform.ts +4 -0
  49. package/src/transform/transfromRLCOptions.ts +340 -41
  50. package/src/utils/operationUtil.ts +2 -4
  51. package/static/static-helpers/urlTemplate.ts +196 -0
@@ -72,6 +72,13 @@ export const PollingHelpers = {
72
72
  }
73
73
  } as const;
74
74
 
75
+ export const UrlTemplateHelpers = {
76
+ parseTemplate: {
77
+ kind: "function",
78
+ name: "expandUrlTemplate",
79
+ location: "urlTemplate.ts"
80
+ }
81
+ } as const;
75
82
  export const MultipartHelpers = {
76
83
  FileContents: {
77
84
  kind: "typeAlias",
@@ -150,6 +150,10 @@ export function transformUrlInfo(
150
150
  importedModels.add,
151
151
  importedModels
152
152
  );
153
+ const normName = normalizeName(key, NameType.Parameter, true);
154
+ if (normName !== key && endpoint) {
155
+ endpoint = endpoint.replace(`{${key}}`, `{${normName}}`);
156
+ }
153
157
  urlParameters.push({
154
158
  oriName: key,
155
159
  name: normalizeName(key, NameType.Parameter, true),
@@ -22,6 +22,7 @@ import { getDefaultService } from "../utils/modelUtils.js";
22
22
  import { detectModelConflicts } from "../utils/namespaceUtils.js";
23
23
  import { getOperationName } from "../utils/operationUtil.js";
24
24
  import { getSupportedHttpAuth } from "../utils/credentialUtils.js";
25
+ import _ from "lodash";
25
26
 
26
27
  export function transformRLCOptions(
27
28
  emitterOptions: EmitterOptions,
@@ -35,40 +36,215 @@ export function transformRLCOptions(
35
36
  );
36
37
  if (
37
38
  !isAzurePackage({ options }) &&
39
+ emitterOptions["is-modular-library"] !== false &&
38
40
  emitterOptions.isModularLibrary !== false
39
41
  ) {
40
42
  options.isModularLibrary = true;
41
43
  }
42
- if (dpgContext.arm && emitterOptions.isModularLibrary !== false) {
44
+ if (
45
+ dpgContext.arm &&
46
+ emitterOptions["is-modular-library"] !== false &&
47
+ emitterOptions.isModularLibrary !== false
48
+ ) {
43
49
  options.isModularLibrary = true;
44
50
  }
45
51
  const batch = getRLCClients(dpgContext);
46
52
  options.batch = batch;
47
53
  return options;
48
54
  }
49
-
55
+ function reportAllCamelOptionDiagnostics(
56
+ program: Program,
57
+ emitterOptions: EmitterOptions
58
+ ) {
59
+ if (emitterOptions.includeShortcuts !== undefined) {
60
+ reportCamelOptionDiagnostic(program, {
61
+ kebabCaseOption: "include-shortcuts",
62
+ camelCaseOption: "includeShortcuts"
63
+ });
64
+ }
65
+ if (emitterOptions.packageDetails !== undefined) {
66
+ reportCamelOptionDiagnostic(program, {
67
+ kebabCaseOption: "package-details",
68
+ camelCaseOption: "packageDetails"
69
+ });
70
+ }
71
+ if (emitterOptions.moduleKind !== undefined) {
72
+ reportCamelOptionDiagnostic(program, {
73
+ kebabCaseOption: "module-kind",
74
+ camelCaseOption: "moduleKind"
75
+ });
76
+ }
77
+ if (emitterOptions.azureSdkForJs !== undefined) {
78
+ reportCamelOptionDiagnostic(program, {
79
+ kebabCaseOption: "azure-sdk-for-js",
80
+ camelCaseOption: "azureSdkForJs"
81
+ });
82
+ }
83
+ if (emitterOptions.generateMetadata !== undefined) {
84
+ reportCamelOptionDiagnostic(program, {
85
+ kebabCaseOption: "generate-metadata",
86
+ camelCaseOption: "generateMetadata"
87
+ });
88
+ }
89
+ if (emitterOptions.generateTest !== undefined) {
90
+ reportCamelOptionDiagnostic(program, {
91
+ kebabCaseOption: "generate-test",
92
+ camelCaseOption: "generateTest"
93
+ });
94
+ }
95
+ if (emitterOptions.generateSample !== undefined) {
96
+ reportCamelOptionDiagnostic(program, {
97
+ kebabCaseOption: "generate-sample",
98
+ camelCaseOption: "generateSample"
99
+ });
100
+ }
101
+ if (emitterOptions.addCredentials !== undefined) {
102
+ reportCamelOptionDiagnostic(program, {
103
+ kebabCaseOption: "add-credentials",
104
+ camelCaseOption: "addCredentials"
105
+ });
106
+ }
107
+ if (emitterOptions.credentialScopes !== undefined) {
108
+ reportCamelOptionDiagnostic(program, {
109
+ kebabCaseOption: "credential-scopes",
110
+ camelCaseOption: "credentialScopes"
111
+ });
112
+ }
113
+ if (emitterOptions.credentialKeyHeaderName !== undefined) {
114
+ reportCamelOptionDiagnostic(program, {
115
+ kebabCaseOption: "credential-key-header-name",
116
+ camelCaseOption: "credentialKeyHeaderName"
117
+ });
118
+ }
119
+ if (emitterOptions.customHttpAuthHeaderName !== undefined) {
120
+ reportCamelOptionDiagnostic(program, {
121
+ kebabCaseOption: "custom-http-auth-header-name",
122
+ camelCaseOption: "customHttpAuthHeaderName"
123
+ });
124
+ }
125
+ if (emitterOptions.customHttpAuthSharedKeyPrefix !== undefined) {
126
+ reportCamelOptionDiagnostic(program, {
127
+ kebabCaseOption: "custom-http-auth-shared-key-prefix",
128
+ camelCaseOption: "customHttpAuthSharedKeyPrefix"
129
+ });
130
+ }
131
+ if (emitterOptions.enableOperationGroup !== undefined) {
132
+ reportCamelOptionDiagnostic(program, {
133
+ kebabCaseOption: "enable-operation-group",
134
+ camelCaseOption: "enableOperationGroup"
135
+ });
136
+ }
137
+ if (emitterOptions.enableModelNamespace !== undefined) {
138
+ reportCamelOptionDiagnostic(program, {
139
+ kebabCaseOption: "enable-model-namespace",
140
+ camelCaseOption: "enableModelNamespace"
141
+ });
142
+ }
143
+ if (emitterOptions.hierarchyClient !== undefined) {
144
+ reportCamelOptionDiagnostic(program, {
145
+ kebabCaseOption: "hierarchy-client",
146
+ camelCaseOption: "hierarchyClient"
147
+ });
148
+ }
149
+ if (emitterOptions.clearOutputFolder !== undefined) {
150
+ reportCamelOptionDiagnostic(program, {
151
+ kebabCaseOption: "clear-output-folder",
152
+ camelCaseOption: "clearOutputFolder"
153
+ });
154
+ }
155
+ if (emitterOptions.multiClient !== undefined) {
156
+ reportCamelOptionDiagnostic(program, {
157
+ kebabCaseOption: "multi-client",
158
+ camelCaseOption: "multiClient"
159
+ });
160
+ }
161
+ if (emitterOptions.isTypeSpecTest !== undefined) {
162
+ reportCamelOptionDiagnostic(program, {
163
+ kebabCaseOption: "is-typespec-test",
164
+ camelCaseOption: "isTypeSpecTest"
165
+ });
166
+ }
167
+ if (emitterOptions.dependencyInfo !== undefined) {
168
+ reportCamelOptionDiagnostic(program, {
169
+ kebabCaseOption: "dependency-info",
170
+ camelCaseOption: "dependencyInfo"
171
+ });
172
+ }
173
+ if (emitterOptions.productDocLink !== undefined) {
174
+ reportCamelOptionDiagnostic(program, {
175
+ kebabCaseOption: "product-doc-link",
176
+ camelCaseOption: "productDocLink"
177
+ });
178
+ }
179
+ if (emitterOptions.isModularLibrary !== undefined) {
180
+ reportCamelOptionDiagnostic(program, {
181
+ kebabCaseOption: "is-modular-library",
182
+ camelCaseOption: "isModularLibrary"
183
+ });
184
+ }
185
+ if (emitterOptions.compatibilityMode !== undefined) {
186
+ reportCamelOptionDiagnostic(program, {
187
+ kebabCaseOption: "compatibility-mode",
188
+ camelCaseOption: "compatibilityMode"
189
+ });
190
+ }
191
+ if (emitterOptions.experimentalExtensibleEnums !== undefined) {
192
+ reportCamelOptionDiagnostic(program, {
193
+ kebabCaseOption: "experimental-extensible-enums",
194
+ camelCaseOption: "experimentalExtensibleEnums"
195
+ });
196
+ }
197
+ if (emitterOptions.ignorePropertyNameNormalize !== undefined) {
198
+ reportCamelOptionDiagnostic(program, {
199
+ kebabCaseOption: "ignore-property-name-normalize",
200
+ camelCaseOption: "ignorePropertyNameNormalize"
201
+ });
202
+ }
203
+ if (emitterOptions.compatibilityQueryMultiFormat !== undefined) {
204
+ reportCamelOptionDiagnostic(program, {
205
+ kebabCaseOption: "compatibility-query-multi-format",
206
+ camelCaseOption: "compatibilityQueryMultiFormat"
207
+ });
208
+ }
209
+ if (emitterOptions.typespecTitleMap !== undefined) {
210
+ reportCamelOptionDiagnostic(program, {
211
+ kebabCaseOption: "typespec-title-map",
212
+ camelCaseOption: "typespecTitleMap"
213
+ });
214
+ }
215
+ }
216
+ export function reportCamelOptionDiagnostic(
217
+ program: Program,
218
+ caseOption: {
219
+ kebabCaseOption: string;
220
+ camelCaseOption: string;
221
+ }
222
+ ) {
223
+ reportDiagnostic(program, {
224
+ code: "use-kebab-case-option",
225
+ format: {
226
+ kebabCaseOption: caseOption.kebabCaseOption,
227
+ camelCaseOption: caseOption.camelCaseOption
228
+ },
229
+ target: NoTarget
230
+ });
231
+ }
50
232
  function extractRLCOptions(
51
233
  dpgContext: SdkContext,
52
234
  emitterOptions: EmitterOptions,
53
235
  generationRootDir: string
54
236
  ): RLCOptions {
55
237
  const program = dpgContext.program;
238
+ reportAllCamelOptionDiagnostics(program, emitterOptions);
56
239
  const includeShortcuts = getIncludeShortcuts(emitterOptions);
57
240
  const packageDetails = getPackageDetails(program, emitterOptions);
58
241
  const flavor = getFlavor(emitterOptions, packageDetails);
59
242
  const moduleKind = getModuleKind(emitterOptions);
60
243
  const serviceInfo = getServiceInfo(program);
61
244
  const azureSdkForJs = getAzureSdkForJs(emitterOptions);
62
- const generateMetadata: undefined | boolean =
63
- getGenerateMetadata(emitterOptions);
64
- const generateTest: undefined | boolean = getGenerateTest(
65
- emitterOptions,
66
- flavor
67
- );
68
- const generateSample: undefined | boolean = getGenerateSample(
69
- dpgContext,
70
- emitterOptions
71
- );
245
+ const generateMetadata = getGenerateMetadata(emitterOptions);
246
+ const generateTest = getGenerateTest(emitterOptions, flavor);
247
+ const generateSample = getGenerateSample(dpgContext, emitterOptions);
72
248
  const credentialInfo = getCredentialInfo(program, emitterOptions);
73
249
  const azureOutputDirectory = getAzureOutputDirectory(generationRootDir);
74
250
  const enableOperationGroup = getEnableOperationGroup(
@@ -81,8 +257,35 @@ function extractRLCOptions(
81
257
  );
82
258
  const hierarchyClient = getHierarchyClient(emitterOptions);
83
259
  const clearOutputFolder = getClearOutputFolder(emitterOptions);
260
+ const multiClient =
261
+ emitterOptions["multi-client"] ?? emitterOptions.multiClient;
262
+ const isTypeSpecTest =
263
+ emitterOptions["is-typespec-test"] ?? emitterOptions.isTypeSpecTest;
264
+ const title = emitterOptions.title;
265
+ const dependencyInfo =
266
+ emitterOptions["dependency-info"] ?? emitterOptions.dependencyInfo;
267
+ const productDocLink =
268
+ emitterOptions["product-doc-link"] ?? emitterOptions.productDocLink;
269
+ const isModularLibrary =
270
+ emitterOptions["is-modular-library"] ?? emitterOptions.isModularLibrary;
271
+ const compatibilityMode =
272
+ emitterOptions["compatibility-mode"] ?? emitterOptions.compatibilityMode;
273
+ const experimentalExtensibleEnums =
274
+ emitterOptions["experimental-extensible-enums"] ??
275
+ emitterOptions.experimentalExtensibleEnums;
276
+ const ignorePropertyNameNormalize =
277
+ emitterOptions["ignore-property-name-normalize"] ??
278
+ emitterOptions.ignorePropertyNameNormalize;
279
+ const ignoreEnumMemberNameNormalize =
280
+ emitterOptions["ignore-enum-member-name-normalize"] ??
281
+ emitterOptions.ignoreEnumMemberNameNormalize;
282
+ const compatibilityQueryMultiFormat =
283
+ emitterOptions["compatibility-query-multi-format"] ??
284
+ emitterOptions.compatibilityQueryMultiFormat;
285
+ const typespecTitleMap =
286
+ emitterOptions["typespec-title-map"] ?? emitterOptions.typespecTitleMap;
287
+
84
288
  return {
85
- ...emitterOptions,
86
289
  ...credentialInfo,
87
290
  flavor,
88
291
  moduleKind,
@@ -99,7 +302,19 @@ function extractRLCOptions(
99
302
  enableModelNamespace,
100
303
  hierarchyClient,
101
304
  azureArm: dpgContext.arm,
102
- clearOutputFolder
305
+ clearOutputFolder,
306
+ multiClient,
307
+ isTypeSpecTest,
308
+ title,
309
+ dependencyInfo,
310
+ productDocLink,
311
+ isModularLibrary,
312
+ compatibilityMode,
313
+ experimentalExtensibleEnums,
314
+ ignorePropertyNameNormalize,
315
+ compatibilityQueryMultiFormat,
316
+ typespecTitleMap,
317
+ ignoreEnumMemberNameNormalize
103
318
  };
104
319
  }
105
320
 
@@ -174,6 +389,12 @@ function getEnableOperationGroup(
174
389
  dpgContext: SdkContext,
175
390
  emitterOptions: EmitterOptions
176
391
  ) {
392
+ if (
393
+ emitterOptions["enable-operation-group"] === true ||
394
+ emitterOptions["enable-operation-group"] === false
395
+ ) {
396
+ return emitterOptions["enable-operation-group"];
397
+ }
177
398
  if (
178
399
  emitterOptions.enableOperationGroup === true ||
179
400
  emitterOptions.enableOperationGroup === false
@@ -188,6 +409,12 @@ function getEnableModelNamespace(
188
409
  dpgContext: SdkContext,
189
410
  emitterOptions: EmitterOptions
190
411
  ) {
412
+ if (
413
+ emitterOptions["enable-model-namespace"] === true ||
414
+ emitterOptions["enable-model-namespace"] === false
415
+ ) {
416
+ return emitterOptions["enable-model-namespace"];
417
+ }
191
418
  if (
192
419
  emitterOptions.enableModelNamespace === true ||
193
420
  emitterOptions.enableModelNamespace === false
@@ -199,6 +426,12 @@ function getEnableModelNamespace(
199
426
  }
200
427
 
201
428
  function getHierarchyClient(emitterOptions: EmitterOptions) {
429
+ if (
430
+ emitterOptions["hierarchy-client"] === true ||
431
+ emitterOptions["hierarchy-client"] === false
432
+ ) {
433
+ return emitterOptions["hierarchy-client"];
434
+ }
202
435
  if (
203
436
  emitterOptions.hierarchyClient === true ||
204
437
  emitterOptions.hierarchyClient === false
@@ -210,7 +443,10 @@ function getHierarchyClient(emitterOptions: EmitterOptions) {
210
443
  }
211
444
 
212
445
  function getClearOutputFolder(emitterOptions: EmitterOptions) {
213
- if (emitterOptions.clearOutputFolder === true) {
446
+ if (
447
+ emitterOptions["clear-output-folder"] === true ||
448
+ emitterOptions.clearOutputFolder === true
449
+ ) {
214
450
  return true;
215
451
  }
216
452
  return false;
@@ -254,11 +490,14 @@ function detectIfNameConflicts(dpgContext: SdkContext) {
254
490
  }
255
491
 
256
492
  function getIncludeShortcuts(emitterOptions: EmitterOptions) {
257
- return Boolean(emitterOptions.includeShortcuts);
493
+ return (
494
+ Boolean(emitterOptions["include-shortcuts"]) ||
495
+ Boolean(emitterOptions.includeShortcuts)
496
+ );
258
497
  }
259
498
 
260
499
  function getModuleKind(emitterOptions: EmitterOptions) {
261
- return emitterOptions.moduleKind ?? "esm";
500
+ return emitterOptions["module-kind"] ?? emitterOptions.moduleKind ?? "esm";
262
501
  }
263
502
 
264
503
  function getFlavor(
@@ -290,11 +529,43 @@ function getFlavor(
290
529
  return undefined;
291
530
  }
292
531
  }
293
-
294
- function getPackageDetails(
532
+ function buildPackageDetails(
533
+ program: Program,
534
+ emitterOptions: EmitterOptions
535
+ ): PackageDetails {
536
+ const defaultDetail = {
537
+ name: "@msinternal/unamedpackage",
538
+ nameWithoutScope: "unamedpackage",
539
+ version: "1.0.0-beta.1"
540
+ };
541
+ const packageDetails: PackageDetails = {
542
+ ...emitterOptions["package-details"],
543
+ name:
544
+ emitterOptions["package-details"]?.name ??
545
+ normalizeName(
546
+ emitterOptions?.title ?? getDefaultService(program)?.title ?? "",
547
+ NameType.Class
548
+ ),
549
+ version: emitterOptions["package-details"]?.version ?? "1.0.0-beta.1"
550
+ };
551
+ if (emitterOptions["package-details"]?.name) {
552
+ const nameParts = emitterOptions["package-details"]?.name.split("/");
553
+ if (nameParts.length === 2) {
554
+ packageDetails.nameWithoutScope = nameParts[1];
555
+ packageDetails.scopeName = nameParts[0]?.replace("@", "");
556
+ }
557
+ }
558
+ return packageDetails ?? defaultDetail;
559
+ }
560
+ function _buildPackageDetails(
295
561
  program: Program,
296
562
  emitterOptions: EmitterOptions
297
563
  ): PackageDetails {
564
+ const defaultDetail = {
565
+ name: "@msinternal/unamedpackage",
566
+ nameWithoutScope: "unamedpackage",
567
+ version: "1.0.0-beta.1"
568
+ };
298
569
  const packageDetails: PackageDetails = {
299
570
  ...emitterOptions.packageDetails,
300
571
  name:
@@ -312,13 +583,16 @@ function getPackageDetails(
312
583
  packageDetails.scopeName = nameParts[0]?.replace("@", "");
313
584
  }
314
585
  }
315
- return (
316
- packageDetails ?? {
317
- name: "@msinternal/unamedpackage",
318
- nameWithoutScope: "unamedpackage",
319
- version: "1.0.0-beta.1"
320
- }
321
- );
586
+ return packageDetails ?? defaultDetail;
587
+ }
588
+ function getPackageDetails(
589
+ program: Program,
590
+ emitterOptions: EmitterOptions
591
+ ): PackageDetails {
592
+ if (emitterOptions["package-details"] !== undefined) {
593
+ return buildPackageDetails(program, emitterOptions);
594
+ }
595
+ return _buildPackageDetails(program, emitterOptions);
322
596
  }
323
597
 
324
598
  function getServiceInfo(program: Program): ServiceInfo {
@@ -332,20 +606,28 @@ function getServiceInfo(program: Program): ServiceInfo {
332
606
  function getAzureSdkForJs(emitterOptions: EmitterOptions) {
333
607
  return emitterOptions.flavor !== "azure"
334
608
  ? false
335
- : emitterOptions.azureSdkForJs === undefined ||
336
- emitterOptions.azureSdkForJs === null
609
+ : (emitterOptions["azure-sdk-for-js"] === undefined ||
610
+ emitterOptions["azure-sdk-for-js"] === null) &&
611
+ (emitterOptions.azureSdkForJs === undefined ||
612
+ emitterOptions.azureSdkForJs === null)
337
613
  ? true
338
- : Boolean(emitterOptions.azureSdkForJs);
614
+ : Boolean(emitterOptions["azure-sdk-for-js"]) ||
615
+ Boolean(emitterOptions.azureSdkForJs);
339
616
  }
340
617
 
341
618
  function getGenerateMetadata(emitterOptions: EmitterOptions) {
342
619
  if (
343
- emitterOptions.generateMetadata === undefined ||
344
- emitterOptions.generateMetadata === null
620
+ (emitterOptions["generate-metadata"] === undefined ||
621
+ emitterOptions["generate-metadata"] === null) &&
622
+ (emitterOptions.generateMetadata === undefined ||
623
+ emitterOptions.generateMetadata === null)
345
624
  ) {
346
625
  return undefined;
347
626
  }
348
- return Boolean(emitterOptions.generateMetadata);
627
+ return (
628
+ Boolean(emitterOptions["generate-metadata"]) ||
629
+ Boolean(emitterOptions.generateMetadata)
630
+ );
349
631
  }
350
632
 
351
633
  /**
@@ -356,18 +638,25 @@ function getGenerateMetadata(emitterOptions: EmitterOptions) {
356
638
  function getGenerateTest(emitterOptions: EmitterOptions, flavor?: "azure") {
357
639
  if (
358
640
  flavor !== "azure" &&
641
+ (emitterOptions["generate-test"] === undefined ||
642
+ emitterOptions["generate-test"] === null) &&
359
643
  (emitterOptions.generateTest === undefined ||
360
644
  emitterOptions.generateTest === null)
361
645
  ) {
362
646
  return undefined;
363
647
  } else if (
364
648
  flavor === "azure" &&
649
+ (emitterOptions["generate-test"] === undefined ||
650
+ emitterOptions["generate-test"] === null) &&
365
651
  (emitterOptions.generateTest === undefined ||
366
652
  emitterOptions.generateTest === null)
367
653
  ) {
368
654
  return true;
369
655
  }
370
- return Boolean(emitterOptions.generateTest);
656
+ return (
657
+ Boolean(emitterOptions["generate-test"]) ||
658
+ Boolean(emitterOptions.generateTest)
659
+ );
371
660
  }
372
661
 
373
662
  /**
@@ -383,12 +672,17 @@ function getGenerateSample(
383
672
  return true;
384
673
  }
385
674
  if (
386
- emitterOptions.generateSample === undefined ||
387
- emitterOptions.generateSample === null
675
+ (emitterOptions["generate-sample"] === undefined ||
676
+ emitterOptions["generate-sample"] === null) &&
677
+ (emitterOptions.generateSample === undefined ||
678
+ emitterOptions.generateSample === null)
388
679
  ) {
389
680
  return undefined;
390
681
  }
391
- return Boolean(emitterOptions.generateSample);
682
+ return (
683
+ Boolean(emitterOptions["generate-sample"]) ||
684
+ Boolean(emitterOptions.generateSample)
685
+ );
392
686
  }
393
687
 
394
688
  export function getCredentialInfo(
@@ -397,27 +691,32 @@ export function getCredentialInfo(
397
691
  ) {
398
692
  const securityInfo = processAuth(program);
399
693
  const addCredentials =
694
+ emitterOptions["add-credentials"] === false ||
400
695
  emitterOptions.addCredentials === false
401
696
  ? false
402
697
  : securityInfo
403
698
  ? securityInfo.addCredentials
404
- : emitterOptions.addCredentials;
699
+ : (emitterOptions["add-credentials"] ?? emitterOptions.addCredentials);
405
700
  const credentialScopes =
406
701
  securityInfo && securityInfo.credentialScopes
407
702
  ? securityInfo.credentialScopes
408
- : emitterOptions.credentialScopes;
703
+ : (emitterOptions["credential-scopes"] ??
704
+ emitterOptions.credentialScopes);
409
705
  const credentialKeyHeaderName =
410
706
  securityInfo && securityInfo.credentialKeyHeaderName
411
707
  ? securityInfo.credentialKeyHeaderName
412
- : emitterOptions.credentialKeyHeaderName;
708
+ : (emitterOptions["credential-key-header-name"] ??
709
+ emitterOptions.credentialKeyHeaderName);
413
710
  const customHttpAuthHeaderName =
414
711
  securityInfo && securityInfo.customHttpAuthHeaderName
415
712
  ? securityInfo.customHttpAuthHeaderName
416
- : emitterOptions.customHttpAuthHeaderName;
713
+ : (emitterOptions["custom-http-auth-header-name"] ??
714
+ emitterOptions.customHttpAuthHeaderName);
417
715
  const customHttpAuthSharedKeyPrefix =
418
716
  securityInfo && securityInfo.customHttpAuthSharedKeyPrefix
419
717
  ? securityInfo.customHttpAuthSharedKeyPrefix
420
- : emitterOptions.customHttpAuthSharedKeyPrefix;
718
+ : (emitterOptions["custom-http-auth-shared-key-prefix"] ??
719
+ emitterOptions.customHttpAuthSharedKeyPrefix);
421
720
  return {
422
721
  addCredentials,
423
722
  credentialScopes,
@@ -421,7 +421,7 @@ export function hasCollectionFormatInfo(
421
421
  paramFormat: string
422
422
  ) {
423
423
  return (
424
- getHasMultiCollection(paramType, paramFormat) ||
424
+ getHasMultiCollection(paramType, paramFormat, false) ||
425
425
  getHasSsvCollection(paramType, paramFormat) ||
426
426
  getHasTsvCollection(paramType, paramFormat) ||
427
427
  getHasCsvCollection(paramType, paramFormat) ||
@@ -490,9 +490,7 @@ export function getCollectionFormatHelper(
490
490
  paramType: string,
491
491
  paramFormat: string
492
492
  ) {
493
- // const detail = getSpecialSerializeInfo(paramType, paramFormat);
494
- // return detail.descriptions.length > 0 ? detail.descriptions[0] : undefined;
495
- if (getHasMultiCollection(paramType, paramFormat)) {
493
+ if (getHasMultiCollection(paramType, paramFormat, false)) {
496
494
  return resolveReference(SerializationHelpers.buildMultiCollection);
497
495
  }
498
496