@typespec/openapi3 1.17.0-dev.2 → 1.17.0-dev.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../../../src/cli/actions/convert/convert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../../../src/cli/actions/convert/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAanD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAAmC,EACnC,EAAE,mBAAmB,EAAE,SAAS,KAAqC,EAAE;IAEvE,MAAM,kBAAkB,GAAG,mBAAmB;QAC5C,CAAC,CAAC;YACE,aAAa,EAAE,CAAC,IAAwC,EAAQ,EAAE;gBAChE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC7B,OAAO;gBACT,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,wDAAwD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YACtF,CAAC;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,WAAW,CAAC,QAAgC,EAAE,kBAAkB,CAAC,CAAC;IAClG,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE;YACnC,UAAU,EAAE,GAAG;YACf,QAAQ,EAAE,CAAC;SACZ,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-helpers-3-1.d.ts","sourceRoot":"","sources":["../../src/openapi-helpers-3-1.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openapi-helpers-3-1.d.ts","sourceRoot":"","sources":["../../src/openapi-helpers-3-1.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAW,MAAM,YAAY,CAAC;AA2B5D,eAAO,MAAM,aAAa,EAAE,wBAAwB,CAAC,eAAe,CAyBnE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,cAAc,MAAM,KAAG,gBAKzD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,gBAAgB,KAAG,OAE5D,CAAC"}
|
|
@@ -1,14 +1,37 @@
|
|
|
1
|
+
import { ObjectBuilder } from "@typespec/asset-emitter";
|
|
2
|
+
import { getEncode, isNullType } from "@typespec/compiler";
|
|
1
3
|
import { applyEncoding as baseApplyEncoding } from "./encoding.js";
|
|
2
4
|
import { isScalarExtendsBytes } from "./util.js";
|
|
3
5
|
function getEncodingFieldName(typespecType) {
|
|
4
6
|
// In Open API 3.1, `contentEncoding` is used for encoded binary data instead of `format`.
|
|
5
|
-
const typeIsBytes = isScalarExtendsBytes(typespecType.kind === "ModelProperty" ? typespecType.type : typespecType);
|
|
7
|
+
const typeIsBytes = isScalarExtendsBytes(typespecType.kind === "ModelProperty" ? getNonNullType(typespecType.type) : typespecType);
|
|
6
8
|
if (typeIsBytes) {
|
|
7
9
|
return "contentEncoding";
|
|
8
10
|
}
|
|
9
11
|
return "format";
|
|
10
12
|
}
|
|
13
|
+
/** Returns `T` for a nullable union `T | null`, otherwise the type itself. */
|
|
14
|
+
function getNonNullType(type) {
|
|
15
|
+
if (type.kind !== "Union") {
|
|
16
|
+
return type;
|
|
17
|
+
}
|
|
18
|
+
const variants = [...type.variants.values()].filter((x) => !isNullType(x.type));
|
|
19
|
+
return variants.length === 1 ? variants[0].type : type;
|
|
20
|
+
}
|
|
21
|
+
function isNullSchema(schema) {
|
|
22
|
+
return "type" in schema && schema.type === "null";
|
|
23
|
+
}
|
|
11
24
|
export const applyEncoding = (program, typespecType, target, options) => {
|
|
25
|
+
// A nullable `T | null` is emitted as `anyOf: [T, { type: "null" }]` in Open API 3.1.
|
|
26
|
+
// The encoding describes `T` so it is applied to that member and not to the `anyOf` wrapper.
|
|
27
|
+
const anyOf = target.anyOf;
|
|
28
|
+
if (anyOf?.length === 2 && anyOf.some(isNullSchema) && getEncode(program, typespecType)) {
|
|
29
|
+
const result = new ObjectBuilder(target);
|
|
30
|
+
result.anyOf = anyOf.map((member) => isNullSchema(member)
|
|
31
|
+
? member
|
|
32
|
+
: baseApplyEncoding(program, typespecType, member, getEncodingFieldName, options));
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
12
35
|
return baseApplyEncoding(program, typespecType, target, getEncodingFieldName, options);
|
|
13
36
|
};
|
|
14
37
|
export const getRawBinarySchema = (contentType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-helpers-3-1.js","sourceRoot":"","sources":["../../src/openapi-helpers-3-1.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openapi-helpers-3-1.js","sourceRoot":"","sources":["../../src/openapi-helpers-3-1.ts"],"names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ACtF,6FAA6F;IAC7F,MAAM,KAAK,GAAI,MAA2B,CAAC,KAAK,CAAC;IACjD,IAAI,KAAK,EAAE,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC;QACxF,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAClC,YAAY,CAAC,MAAM,CAAC;YAClB,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,iBAAiB,CACf,OAAO,EACP,YAAY,EACZ,MAA0B,EAC1B,oBAAoB,EACpB,OAAO,CACR,CACN,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAoB,EAAoB,EAAE;IAC3E,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAwB,EAAW,EAAE;IACrE,OAAO,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACnC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/openapi3",
|
|
3
|
-
"version": "1.17.0-dev.
|
|
3
|
+
"version": "1.17.0-dev.3",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec library for emitting OpenAPI 3.0 and OpenAPI 3.1 from the TypeSpec REST protocol binding and converting OpenAPI3 to TypeSpec",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -46,13 +46,14 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@scalar/json-magic": "^0.13.2",
|
|
49
|
-
"@scalar/openapi-parser": "^0.
|
|
49
|
+
"@scalar/openapi-parser": "^0.29.1",
|
|
50
50
|
"@scalar/openapi-types": "^0.9.5",
|
|
51
|
+
"@scalar/types": "^0.19.0",
|
|
51
52
|
"@typespec/asset-emitter": "^0.79.2 || >= 0.79.3-dev.3",
|
|
52
53
|
"yaml": "^2.9.0"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"@typespec/compiler": "^1.16.0 || >= 1.17.0-dev.
|
|
56
|
+
"@typespec/compiler": "^1.16.0 || >= 1.17.0-dev.10",
|
|
56
57
|
"@typespec/events": "^0.86.0 || >= 0.87.0-dev.0",
|
|
57
58
|
"@typespec/http": "^1.16.0 || >= 1.17.0-dev.0",
|
|
58
59
|
"@typespec/json-schema": "^1.16.0 || >= 1.17.0-dev.3",
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
"devDependencies": {
|
|
85
86
|
"@types/node": "^26.3.0",
|
|
86
87
|
"@types/yargs": "^17.0.35",
|
|
87
|
-
"@typespec/compiler": "^1.16.0 || >= 1.17.0-dev.
|
|
88
|
+
"@typespec/compiler": "^1.16.0 || >= 1.17.0-dev.10",
|
|
88
89
|
"@typespec/events": "^0.86.0 || >= 0.87.0-dev.0",
|
|
89
90
|
"@typespec/http": "^1.16.0 || >= 1.17.0-dev.0",
|
|
90
91
|
"@typespec/json-schema": "^1.16.0 || >= 1.17.0-dev.3",
|
|
@@ -96,12 +97,12 @@
|
|
|
96
97
|
"@typespec/tspd": "^0.77.1 || >= 0.77.2-dev.1",
|
|
97
98
|
"@typespec/versioning": "^0.86.0 || >= 0.87.0-dev.1",
|
|
98
99
|
"@typespec/xml": "^0.86.0 || >= 0.87.0-dev.0",
|
|
99
|
-
"@vitest/coverage-v8": "^
|
|
100
|
-
"@vitest/ui": "^
|
|
100
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
101
|
+
"@vitest/ui": "^5.0.0",
|
|
101
102
|
"cross-env": "^10.1.0",
|
|
102
103
|
"rimraf": "^6.1.3",
|
|
103
104
|
"typescript": "~6.0.2",
|
|
104
|
-
"vitest": "^
|
|
105
|
+
"vitest": "^5.0.0"
|
|
105
106
|
},
|
|
106
107
|
"scripts": {
|
|
107
108
|
"clean": "rimraf ./dist ./temp",
|