@azure-tools/typespec-ts 0.50.4 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/src/modular/emitSamples.js +29 -8
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/utils/namespaceUtils.d.ts.map +1 -1
- package/dist/src/utils/namespaceUtils.js +2 -2
- package/dist/src/utils/namespaceUtils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -23
- package/src/modular/emitSamples.ts +20 -1
- package/src/utils/namespaceUtils.ts +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "An experimental TypeSpec emitter for TypeScript RLC",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@azure-rest/core-client": "^2.3.1",
|
|
21
|
-
"@typespec/http-specs": "0.1.0-alpha.
|
|
22
|
-
"@typespec/spector": "0.1.0-
|
|
23
|
-
"@typespec/spec-api": "0.1.0-dev.
|
|
24
|
-
"@typespec/tspd": "0.74.
|
|
25
|
-
"@azure-tools/azure-http-specs": "0.1.0-alpha.
|
|
26
|
-
"@azure-tools/typespec-autorest": "^0.
|
|
27
|
-
"@azure-tools/typespec-azure-core": "^0.
|
|
28
|
-
"@azure-tools/typespec-azure-resource-manager": "^0.
|
|
29
|
-
"@azure-tools/typespec-client-generator-core": "^0.
|
|
21
|
+
"@typespec/http-specs": "0.1.0-alpha.35-dev.1",
|
|
22
|
+
"@typespec/spector": "0.1.0-dev.0",
|
|
23
|
+
"@typespec/spec-api": "0.1.0-alpha.14-dev.1",
|
|
24
|
+
"@typespec/tspd": "0.74.1",
|
|
25
|
+
"@azure-tools/azure-http-specs": "0.1.0-alpha.39-dev.2",
|
|
26
|
+
"@azure-tools/typespec-autorest": "^0.66.0",
|
|
27
|
+
"@azure-tools/typespec-azure-core": "^0.66.0",
|
|
28
|
+
"@azure-tools/typespec-azure-resource-manager": "^0.66.0",
|
|
29
|
+
"@azure-tools/typespec-client-generator-core": "^0.66.2",
|
|
30
30
|
"@azure/abort-controller": "^2.1.2",
|
|
31
31
|
"@azure/core-auth": "^1.6.0",
|
|
32
32
|
"@azure/core-lro": "^3.1.0",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"@types/mocha": "^10.0.6",
|
|
41
41
|
"@typescript-eslint/eslint-plugin": "^8.28.0",
|
|
42
42
|
"@typescript-eslint/parser": "^8.28.0",
|
|
43
|
-
"@typespec/compiler": "^1.
|
|
44
|
-
"@typespec/http": "^1.
|
|
45
|
-
"@typespec/openapi": "^1.
|
|
46
|
-
"@typespec/rest": "^0.
|
|
43
|
+
"@typespec/compiler": "^1.10.0",
|
|
44
|
+
"@typespec/http": "^1.10.0",
|
|
45
|
+
"@typespec/openapi": "^1.10.0",
|
|
46
|
+
"@typespec/rest": "^0.80.0",
|
|
47
47
|
"@typespec/ts-http-runtime": "^0.1.0",
|
|
48
|
-
"@typespec/versioning": "^0.
|
|
48
|
+
"@typespec/versioning": "^0.80.0",
|
|
49
49
|
"chai": "^4.3.6",
|
|
50
50
|
"chalk": "^4.0.0",
|
|
51
51
|
"cross-env": "^7.0.3",
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
"js-yaml": "^4.1.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@azure-tools/typespec-azure-core": "^0.
|
|
68
|
-
"@azure-tools/typespec-client-generator-core": "^0.
|
|
69
|
-
"@typespec/compiler": "^1.
|
|
70
|
-
"@typespec/http": "^1.
|
|
71
|
-
"@typespec/rest": "^0.
|
|
72
|
-
"@typespec/versioning": "^0.
|
|
73
|
-
"@typespec/xml": "^0.
|
|
67
|
+
"@azure-tools/typespec-azure-core": "^0.66.0",
|
|
68
|
+
"@azure-tools/typespec-client-generator-core": "^0.66.2",
|
|
69
|
+
"@typespec/compiler": "^1.10.0",
|
|
70
|
+
"@typespec/http": "^1.10.0",
|
|
71
|
+
"@typespec/rest": "^0.80.0",
|
|
72
|
+
"@typespec/versioning": "^0.80.0",
|
|
73
|
+
"@typespec/xml": "^0.80.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@azure-tools/rlc-common": "^0.
|
|
76
|
+
"@azure-tools/rlc-common": "^0.51.0",
|
|
77
77
|
"fast-xml-parser": "^4.5.0",
|
|
78
78
|
"fs-extra": "^11.1.0",
|
|
79
79
|
"lodash": "^4.17.21",
|
|
@@ -577,11 +577,30 @@ function getParameterValue(
|
|
|
577
577
|
}
|
|
578
578
|
case "boolean":
|
|
579
579
|
case "number":
|
|
580
|
-
case "null":
|
|
581
580
|
case "unknown":
|
|
582
581
|
case "union":
|
|
583
582
|
retValue = `${JSON.stringify(value.value)}`;
|
|
584
583
|
break;
|
|
584
|
+
case "null": {
|
|
585
|
+
const ignoreNullableOnOptional =
|
|
586
|
+
context.rlcOptions?.ignoreNullableOnOptional ?? false;
|
|
587
|
+
if (ignoreNullableOnOptional) {
|
|
588
|
+
// When ignore-nullable-on-optional is true, the TypeScript type won't include
|
|
589
|
+
// | null for optional properties, so we convert null to a type-appropriate default
|
|
590
|
+
// to avoid type errors in the generated sample code.
|
|
591
|
+
const innerTypeKind = value.type.type.kind;
|
|
592
|
+
if (innerTypeKind === "array") {
|
|
593
|
+
retValue = "[]";
|
|
594
|
+
} else if (innerTypeKind === "model" || innerTypeKind === "dict") {
|
|
595
|
+
retValue = "{}";
|
|
596
|
+
} else {
|
|
597
|
+
retValue = "undefined";
|
|
598
|
+
}
|
|
599
|
+
} else {
|
|
600
|
+
retValue = `${JSON.stringify(value.value)}`;
|
|
601
|
+
}
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
585
604
|
case "dict":
|
|
586
605
|
case "model": {
|
|
587
606
|
const mapper = buildPropertyNameMapper(
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getAllModels,
|
|
3
|
+
UsageFlags
|
|
4
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
2
5
|
import {
|
|
3
6
|
isGlobalNamespace,
|
|
4
7
|
isService,
|
|
@@ -73,7 +76,7 @@ export function detectModelConflicts(dpgContext: SdkContext) {
|
|
|
73
76
|
const reported = new Set<string>();
|
|
74
77
|
let hasConflict = false;
|
|
75
78
|
for (const model of allModels) {
|
|
76
|
-
if (model.name === "") {
|
|
79
|
+
if (model.name === "" || model.usage === UsageFlags.ApiVersionEnum) {
|
|
77
80
|
continue;
|
|
78
81
|
}
|
|
79
82
|
if (nameSet.has(model.name) && !reported.has(model.name)) {
|