@kubb/adapter-oas 5.0.0-beta.56 → 5.0.0-beta.58
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/dist/index.cjs +56 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -52
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/adapter.ts +2 -2
- package/src/discriminator.ts +2 -2
- package/src/parser.ts +44 -44
- package/src/stream.ts +5 -4
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { access, readFile } from "node:fs/promises";
|
|
|
5
5
|
import { compileErrors, validate } from "@readme/openapi-parser";
|
|
6
6
|
import { parse } from "yaml";
|
|
7
7
|
import { bundle } from "api-ref-bundler";
|
|
8
|
-
import { childName, enumPropName, extractRefName, findDiscriminator } from "@kubb/ast/utils";
|
|
8
|
+
import { childName, containsCircularRef, enumPropName, extractRefName, findCircularSchemas, findDiscriminator } from "@kubb/ast/utils";
|
|
9
9
|
import { collect, narrowSchema } from "@kubb/ast";
|
|
10
10
|
//#region src/constants.ts
|
|
11
11
|
/**
|
|
@@ -1495,7 +1495,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1495
1495
|
}
|
|
1496
1496
|
resolvedSchema = resolvedRefCache.get(refPath) ?? null;
|
|
1497
1497
|
}
|
|
1498
|
-
return ast.createSchema({
|
|
1498
|
+
return ast.factory.createSchema({
|
|
1499
1499
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1500
1500
|
type: "ref",
|
|
1501
1501
|
name: extractRefName(schema.$ref),
|
|
@@ -1516,7 +1516,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1516
1516
|
const { kind: _kind, ...memberNodeProps } = memberNode;
|
|
1517
1517
|
const mergedNullable = nullable || memberNode.nullable || void 0;
|
|
1518
1518
|
const mergedDefault = schema.default === null && mergedNullable ? void 0 : schema.default ?? memberNode.default;
|
|
1519
|
-
return ast.createSchema({
|
|
1519
|
+
return ast.factory.createSchema({
|
|
1520
1520
|
...memberNodeProps,
|
|
1521
1521
|
name,
|
|
1522
1522
|
title: schema.title ?? memberNode.title,
|
|
@@ -1580,11 +1580,11 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1580
1580
|
const { allOf: _allOf, ...schemaWithoutAllOf } = schema;
|
|
1581
1581
|
allOfMembers.push(parseSchema({ schema: schemaWithoutAllOf }, rawOptions));
|
|
1582
1582
|
}
|
|
1583
|
-
for (const { propertyName, value } of filteredDiscriminantValues) allOfMembers.push(ast.createDiscriminantNode({
|
|
1583
|
+
for (const { propertyName, value } of filteredDiscriminantValues) allOfMembers.push(ast.factory.createDiscriminantNode({
|
|
1584
1584
|
propertyName,
|
|
1585
1585
|
value
|
|
1586
1586
|
}));
|
|
1587
|
-
return ast.createSchema({
|
|
1587
|
+
return ast.factory.createSchema({
|
|
1588
1588
|
type: "intersection",
|
|
1589
1589
|
members: [...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(0, syntheticStart)), ...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(syntheticStart))],
|
|
1590
1590
|
...buildSchemaNode(schema, name, nullable, defaultValue)
|
|
@@ -1597,7 +1597,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1597
1597
|
function pickDiscriminatorPropertyNode(node, propertyName) {
|
|
1598
1598
|
const discriminatorProperty = ast.narrowSchema(node, "object")?.properties?.find((property) => property.name === propertyName);
|
|
1599
1599
|
if (!discriminatorProperty) return null;
|
|
1600
|
-
return ast.createSchema({
|
|
1600
|
+
return ast.factory.createSchema({
|
|
1601
1601
|
type: "object",
|
|
1602
1602
|
primitive: "object",
|
|
1603
1603
|
properties: [discriminatorProperty]
|
|
@@ -1632,27 +1632,27 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1632
1632
|
propertyName: discriminator.propertyName,
|
|
1633
1633
|
values: [discriminatorValue]
|
|
1634
1634
|
}), discriminator.propertyName) : void 0;
|
|
1635
|
-
return ast.createSchema({
|
|
1635
|
+
return ast.factory.createSchema({
|
|
1636
1636
|
type: "intersection",
|
|
1637
|
-
members: [memberNode, narrowedDiscriminatorNode ?? ast.createDiscriminantNode({
|
|
1637
|
+
members: [memberNode, narrowedDiscriminatorNode ?? ast.factory.createDiscriminantNode({
|
|
1638
1638
|
propertyName: discriminator.propertyName,
|
|
1639
1639
|
value: discriminatorValue
|
|
1640
1640
|
})]
|
|
1641
1641
|
});
|
|
1642
1642
|
});
|
|
1643
|
-
const unionNode = ast.createSchema({
|
|
1643
|
+
const unionNode = ast.factory.createSchema({
|
|
1644
1644
|
type: "union",
|
|
1645
1645
|
...unionBase,
|
|
1646
1646
|
members
|
|
1647
1647
|
});
|
|
1648
1648
|
if (!sharedPropertiesNode) return unionNode;
|
|
1649
|
-
return ast.createSchema({
|
|
1649
|
+
return ast.factory.createSchema({
|
|
1650
1650
|
type: "intersection",
|
|
1651
1651
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1652
1652
|
members: [unionNode, sharedPropertiesNode]
|
|
1653
1653
|
});
|
|
1654
1654
|
}
|
|
1655
|
-
return ast.createSchema({
|
|
1655
|
+
return ast.factory.createSchema({
|
|
1656
1656
|
type: "union",
|
|
1657
1657
|
...unionBase,
|
|
1658
1658
|
members: ast.simplifyUnion(unionMembers.map((s) => parseSchema({
|
|
@@ -1666,7 +1666,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1666
1666
|
*/
|
|
1667
1667
|
function convertConst({ schema, name, nullable, defaultValue }) {
|
|
1668
1668
|
const constValue = schema.const;
|
|
1669
|
-
if (constValue === null) return ast.createSchema({
|
|
1669
|
+
if (constValue === null) return ast.factory.createSchema({
|
|
1670
1670
|
type: "null",
|
|
1671
1671
|
primitive: "null",
|
|
1672
1672
|
name,
|
|
@@ -1676,7 +1676,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1676
1676
|
format: schema.format
|
|
1677
1677
|
});
|
|
1678
1678
|
const constPrimitive = getPrimitiveType(typeof constValue === "number" ? "number" : typeof constValue === "boolean" ? "boolean" : "string");
|
|
1679
|
-
return ast.createSchema({
|
|
1679
|
+
return ast.factory.createSchema({
|
|
1680
1680
|
type: "enum",
|
|
1681
1681
|
primitive: constPrimitive,
|
|
1682
1682
|
enumValues: [constValue],
|
|
@@ -1689,7 +1689,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1689
1689
|
*/
|
|
1690
1690
|
function convertFormat({ schema, name, nullable, defaultValue, options }) {
|
|
1691
1691
|
const base = buildSchemaNode(schema, name, nullable, defaultValue);
|
|
1692
|
-
if (schema.format === "int64") return ast.createSchema({
|
|
1692
|
+
if (schema.format === "int64") return ast.factory.createSchema({
|
|
1693
1693
|
type: options.integerType === "bigint" ? "bigint" : "integer",
|
|
1694
1694
|
primitive: "integer",
|
|
1695
1695
|
...base,
|
|
@@ -1701,14 +1701,14 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1701
1701
|
if (schema.format === "date-time" || schema.format === "date" || schema.format === "time") {
|
|
1702
1702
|
const dateType = getDateType(options, schema.format);
|
|
1703
1703
|
if (!dateType) return null;
|
|
1704
|
-
if (dateType.type === "datetime") return ast.createSchema({
|
|
1704
|
+
if (dateType.type === "datetime") return ast.factory.createSchema({
|
|
1705
1705
|
...base,
|
|
1706
1706
|
primitive: "string",
|
|
1707
1707
|
type: "datetime",
|
|
1708
1708
|
offset: dateType.offset,
|
|
1709
1709
|
local: dateType.local
|
|
1710
1710
|
});
|
|
1711
|
-
return ast.createSchema({
|
|
1711
|
+
return ast.factory.createSchema({
|
|
1712
1712
|
...base,
|
|
1713
1713
|
primitive: "string",
|
|
1714
1714
|
type: dateType.type,
|
|
@@ -1718,36 +1718,36 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1718
1718
|
const specialType = getSchemaType(schema.format);
|
|
1719
1719
|
if (!specialType) return null;
|
|
1720
1720
|
const specialPrimitive = specialType === "number" || specialType === "integer" || specialType === "bigint" ? specialType : "string";
|
|
1721
|
-
if (specialType === "number" || specialType === "integer" || specialType === "bigint") return ast.createSchema({
|
|
1721
|
+
if (specialType === "number" || specialType === "integer" || specialType === "bigint") return ast.factory.createSchema({
|
|
1722
1722
|
...base,
|
|
1723
1723
|
primitive: specialPrimitive,
|
|
1724
1724
|
type: specialType
|
|
1725
1725
|
});
|
|
1726
|
-
if (specialType === "url") return ast.createSchema({
|
|
1726
|
+
if (specialType === "url") return ast.factory.createSchema({
|
|
1727
1727
|
...base,
|
|
1728
1728
|
primitive: "string",
|
|
1729
1729
|
type: "url",
|
|
1730
1730
|
min: schema.minLength,
|
|
1731
1731
|
max: schema.maxLength
|
|
1732
1732
|
});
|
|
1733
|
-
if (specialType === "ipv4") return ast.createSchema({
|
|
1733
|
+
if (specialType === "ipv4") return ast.factory.createSchema({
|
|
1734
1734
|
...base,
|
|
1735
1735
|
primitive: "string",
|
|
1736
1736
|
type: "ipv4"
|
|
1737
1737
|
});
|
|
1738
|
-
if (specialType === "ipv6") return ast.createSchema({
|
|
1738
|
+
if (specialType === "ipv6") return ast.factory.createSchema({
|
|
1739
1739
|
...base,
|
|
1740
1740
|
primitive: "string",
|
|
1741
1741
|
type: "ipv6"
|
|
1742
1742
|
});
|
|
1743
|
-
if (specialType === "uuid" || specialType === "email") return ast.createSchema({
|
|
1743
|
+
if (specialType === "uuid" || specialType === "email") return ast.factory.createSchema({
|
|
1744
1744
|
...base,
|
|
1745
1745
|
primitive: "string",
|
|
1746
1746
|
type: specialType,
|
|
1747
1747
|
min: schema.minLength,
|
|
1748
1748
|
max: schema.maxLength
|
|
1749
1749
|
});
|
|
1750
|
-
return ast.createSchema({
|
|
1750
|
+
return ast.factory.createSchema({
|
|
1751
1751
|
...base,
|
|
1752
1752
|
primitive: specialPrimitive,
|
|
1753
1753
|
type: specialType
|
|
@@ -1763,7 +1763,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1763
1763
|
}, rawOptions);
|
|
1764
1764
|
const nullInEnum = schema.enum.includes(null);
|
|
1765
1765
|
const filteredValues = nullInEnum ? schema.enum.filter((v) => v !== null) : schema.enum;
|
|
1766
|
-
if (nullInEnum && filteredValues.length === 0) return ast.createSchema({
|
|
1766
|
+
if (nullInEnum && filteredValues.length === 0) return ast.factory.createSchema({
|
|
1767
1767
|
type: "null",
|
|
1768
1768
|
primitive: "null",
|
|
1769
1769
|
name,
|
|
@@ -1795,7 +1795,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1795
1795
|
const rawEnumNames = extensionKey ? schema[extensionKey] : void 0;
|
|
1796
1796
|
const uniqueValues = [...new Set(filteredValues)];
|
|
1797
1797
|
const seenNames = /* @__PURE__ */ new Set();
|
|
1798
|
-
return ast.createSchema({
|
|
1798
|
+
return ast.factory.createSchema({
|
|
1799
1799
|
...enumBase,
|
|
1800
1800
|
primitive: enumPrimitiveType,
|
|
1801
1801
|
namedEnumValues: uniqueValues.map((value, index) => ({
|
|
@@ -1809,7 +1809,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1809
1809
|
})
|
|
1810
1810
|
});
|
|
1811
1811
|
}
|
|
1812
|
-
return ast.createSchema({
|
|
1812
|
+
return ast.factory.createSchema({
|
|
1813
1813
|
...enumBase,
|
|
1814
1814
|
enumValues: [...new Set(filteredValues)]
|
|
1815
1815
|
});
|
|
@@ -1838,7 +1838,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1838
1838
|
}
|
|
1839
1839
|
return node;
|
|
1840
1840
|
})();
|
|
1841
|
-
return ast.createProperty({
|
|
1841
|
+
return ast.factory.createProperty({
|
|
1842
1842
|
name: propName,
|
|
1843
1843
|
schema: {
|
|
1844
1844
|
...schemaNode,
|
|
@@ -1852,11 +1852,11 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1852
1852
|
if (additionalProperties === true) return true;
|
|
1853
1853
|
if (additionalProperties === false) return false;
|
|
1854
1854
|
if (additionalProperties && Object.keys(additionalProperties).length > 0) return parseSchema({ schema: additionalProperties }, rawOptions);
|
|
1855
|
-
if (additionalProperties) return ast.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
1855
|
+
if (additionalProperties) return ast.factory.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
1856
1856
|
})();
|
|
1857
1857
|
const rawPatternProperties = "patternProperties" in schema ? schema.patternProperties : void 0;
|
|
1858
|
-
const patternProperties = rawPatternProperties ? Object.fromEntries(Object.entries(rawPatternProperties).map(([pattern, patternSchema]) => [pattern, patternSchema === true || typeof patternSchema === "object" && Object.keys(patternSchema).length === 0 ? ast.createSchema({ type: typeOptionMap.get(options.unknownType) }) : parseSchema({ schema: patternSchema }, rawOptions)])) : void 0;
|
|
1859
|
-
const objectNode = ast.createSchema({
|
|
1858
|
+
const patternProperties = rawPatternProperties ? Object.fromEntries(Object.entries(rawPatternProperties).map(([pattern, patternSchema]) => [pattern, patternSchema === true || typeof patternSchema === "object" && Object.keys(patternSchema).length === 0 ? ast.factory.createSchema({ type: typeOptionMap.get(options.unknownType) }) : parseSchema({ schema: patternSchema }, rawOptions)])) : void 0;
|
|
1859
|
+
const objectNode = ast.factory.createSchema({
|
|
1860
1860
|
type: "object",
|
|
1861
1861
|
primitive: "object",
|
|
1862
1862
|
properties,
|
|
@@ -1884,8 +1884,8 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1884
1884
|
*/
|
|
1885
1885
|
function convertTuple({ schema, name, nullable, defaultValue, rawOptions }) {
|
|
1886
1886
|
const tupleItems = (schema.prefixItems ?? []).map((item) => parseSchema({ schema: item }, rawOptions));
|
|
1887
|
-
const rest = schema.items ? parseSchema({ schema: schema.items }, rawOptions) : ast.createSchema({ type: "any" });
|
|
1888
|
-
return ast.createSchema({
|
|
1887
|
+
const rest = schema.items ? parseSchema({ schema: schema.items }, rawOptions) : ast.factory.createSchema({ type: "any" });
|
|
1888
|
+
return ast.factory.createSchema({
|
|
1889
1889
|
type: "tuple",
|
|
1890
1890
|
primitive: "array",
|
|
1891
1891
|
items: tupleItems,
|
|
@@ -1905,7 +1905,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1905
1905
|
schema: rawItems,
|
|
1906
1906
|
name: itemName
|
|
1907
1907
|
}, rawOptions)] : [];
|
|
1908
|
-
return ast.createSchema({
|
|
1908
|
+
return ast.factory.createSchema({
|
|
1909
1909
|
type: "array",
|
|
1910
1910
|
primitive: "array",
|
|
1911
1911
|
items,
|
|
@@ -1919,7 +1919,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1919
1919
|
* Converts a `type: 'string'` schema into a `StringSchemaNode`.
|
|
1920
1920
|
*/
|
|
1921
1921
|
function convertString({ schema, name, nullable, defaultValue }) {
|
|
1922
|
-
return ast.createSchema({
|
|
1922
|
+
return ast.factory.createSchema({
|
|
1923
1923
|
type: "string",
|
|
1924
1924
|
primitive: "string",
|
|
1925
1925
|
min: schema.minLength,
|
|
@@ -1932,7 +1932,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1932
1932
|
* Converts a `type: 'number'` or `type: 'integer'` schema.
|
|
1933
1933
|
*/
|
|
1934
1934
|
function convertNumeric({ schema, name, nullable, defaultValue }, type) {
|
|
1935
|
-
return ast.createSchema({
|
|
1935
|
+
return ast.factory.createSchema({
|
|
1936
1936
|
type,
|
|
1937
1937
|
primitive: type,
|
|
1938
1938
|
min: schema.minimum,
|
|
@@ -1947,7 +1947,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1947
1947
|
* Converts a `type: 'boolean'` schema.
|
|
1948
1948
|
*/
|
|
1949
1949
|
function convertBoolean({ schema, name, nullable, defaultValue }) {
|
|
1950
|
-
return ast.createSchema({
|
|
1950
|
+
return ast.factory.createSchema({
|
|
1951
1951
|
type: "boolean",
|
|
1952
1952
|
primitive: "boolean",
|
|
1953
1953
|
...buildSchemaNode(schema, name, nullable, defaultValue)
|
|
@@ -1957,7 +1957,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1957
1957
|
* Converts an explicit `type: 'null'` schema.
|
|
1958
1958
|
*/
|
|
1959
1959
|
function convertNull({ schema, name, nullable }) {
|
|
1960
|
-
return ast.createSchema({
|
|
1960
|
+
return ast.factory.createSchema({
|
|
1961
1961
|
type: "null",
|
|
1962
1962
|
primitive: "null",
|
|
1963
1963
|
name,
|
|
@@ -1973,7 +1973,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1973
1973
|
* into a `blob` node.
|
|
1974
1974
|
*/
|
|
1975
1975
|
function convertBlob({ schema, name, nullable, defaultValue }) {
|
|
1976
|
-
return ast.createSchema({
|
|
1976
|
+
return ast.factory.createSchema({
|
|
1977
1977
|
type: "blob",
|
|
1978
1978
|
primitive: "string",
|
|
1979
1979
|
...buildSchemaNode(schema, name, nullable, defaultValue)
|
|
@@ -1990,7 +1990,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1990
1990
|
const nonNullTypes = types.filter((t) => t !== "null");
|
|
1991
1991
|
if (nonNullTypes.length <= 1) return null;
|
|
1992
1992
|
const arrayNullable = types.includes("null") || nullable || void 0;
|
|
1993
|
-
return ast.createSchema({
|
|
1993
|
+
return ast.factory.createSchema({
|
|
1994
1994
|
type: "union",
|
|
1995
1995
|
members: nonNullTypes.map((t) => parseSchema({
|
|
1996
1996
|
schema: {
|
|
@@ -2133,7 +2133,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2133
2133
|
if (node) return node;
|
|
2134
2134
|
}
|
|
2135
2135
|
const emptyType = typeOptionMap.get(options.emptySchemaType);
|
|
2136
|
-
return ast.createSchema({
|
|
2136
|
+
return ast.factory.createSchema({
|
|
2137
2137
|
type: emptyType,
|
|
2138
2138
|
name,
|
|
2139
2139
|
title: schema.title,
|
|
@@ -2151,8 +2151,8 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2151
2151
|
const schema = param["schema"] ? parseSchema({
|
|
2152
2152
|
schema: param["schema"],
|
|
2153
2153
|
name: schemaName
|
|
2154
|
-
}, options) : ast.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
2155
|
-
return ast.createParameter({
|
|
2154
|
+
}, options) : ast.factory.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
2155
|
+
return ast.factory.createParameter({
|
|
2156
2156
|
name: paramName,
|
|
2157
2157
|
in: param["in"],
|
|
2158
2158
|
schema: {
|
|
@@ -2239,7 +2239,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2239
2239
|
schema: raw && Object.keys(raw).length > 0 ? parseSchema({
|
|
2240
2240
|
schema: raw,
|
|
2241
2241
|
name: responseName
|
|
2242
|
-
}, options) : ast.createSchema({ type: typeOptionMap.get(options.emptySchemaType) }),
|
|
2242
|
+
}, options) : ast.factory.createSchema({ type: typeOptionMap.get(options.emptySchemaType) }),
|
|
2243
2243
|
keysToOmit: collectPropertyKeysByFlag(raw, "writeOnly")
|
|
2244
2244
|
};
|
|
2245
2245
|
};
|
|
@@ -2254,7 +2254,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2254
2254
|
}) || "application/json",
|
|
2255
2255
|
...parseEntrySchema(ctx.contentType)
|
|
2256
2256
|
});
|
|
2257
|
-
return ast.createResponse({
|
|
2257
|
+
return ast.factory.createResponse({
|
|
2258
2258
|
statusCode,
|
|
2259
2259
|
description,
|
|
2260
2260
|
content
|
|
@@ -2268,7 +2268,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2268
2268
|
const fallback = pathItemDoc?.[key];
|
|
2269
2269
|
return typeof fallback === "string" ? fallback : void 0;
|
|
2270
2270
|
};
|
|
2271
|
-
return ast.createOperation({
|
|
2271
|
+
return ast.factory.createOperation({
|
|
2272
2272
|
operationId,
|
|
2273
2273
|
protocol: "http",
|
|
2274
2274
|
method: operation.method.toUpperCase(),
|
|
@@ -2350,11 +2350,11 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
2350
2350
|
const objectNode = ast.narrowSchema(node, "object");
|
|
2351
2351
|
if (!objectNode) return node;
|
|
2352
2352
|
const { propertyName, enumValues } = entry;
|
|
2353
|
-
const enumSchema = ast.createSchema({
|
|
2353
|
+
const enumSchema = ast.factory.createSchema({
|
|
2354
2354
|
type: "enum",
|
|
2355
2355
|
enumValues
|
|
2356
2356
|
});
|
|
2357
|
-
const newProp = ast.createProperty({
|
|
2357
|
+
const newProp = ast.factory.createProperty({
|
|
2358
2358
|
name: propertyName,
|
|
2359
2359
|
required: true,
|
|
2360
2360
|
schema: enumSchema
|
|
@@ -2439,7 +2439,7 @@ function createDedupePlan({ schemaNodes, operationNodes, schemaNames, circularNa
|
|
|
2439
2439
|
if (node.type === "enum") return true;
|
|
2440
2440
|
if (node.type !== "object") return false;
|
|
2441
2441
|
if (node.name && circularSchemas.has(node.name)) return false;
|
|
2442
|
-
return !
|
|
2442
|
+
return !containsCircularRef(node, { circularSchemas });
|
|
2443
2443
|
},
|
|
2444
2444
|
nameFor: (node) => {
|
|
2445
2445
|
const base = node.name;
|
|
@@ -2513,7 +2513,7 @@ function preScan({ schemas, parseSchema, parseOperation, document, parserOptions
|
|
|
2513
2513
|
if (ast.narrowSchema(node, ast.schemaTypes.enum) && node.name) enumNames.push(node.name);
|
|
2514
2514
|
if (discriminator === "inherit" && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) discriminatorParentNodes.push(node);
|
|
2515
2515
|
}
|
|
2516
|
-
const circularNames = [...
|
|
2516
|
+
const circularNames = [...findCircularSchemas(allNodes)];
|
|
2517
2517
|
const discriminatorChildMap = discriminatorParentNodes.length > 0 ? buildDiscriminatorChildMap(discriminatorParentNodes) : null;
|
|
2518
2518
|
let dedupePlan = null;
|
|
2519
2519
|
if (dedupe) {
|
|
@@ -2561,7 +2561,7 @@ function createInputStream({ schemas, parseSchema, parseOperation, document, par
|
|
|
2561
2561
|
const rewriteTopLevelSchema = (node) => {
|
|
2562
2562
|
if (!dedupePlan) return node;
|
|
2563
2563
|
const canonical = dedupePlan.canonicalBySignature.get(ast.signatureOf(node));
|
|
2564
|
-
if (canonical && canonical.name !== node.name) return ast.createSchema({
|
|
2564
|
+
if (canonical && canonical.name !== node.name) return ast.factory.createSchema({
|
|
2565
2565
|
type: "ref",
|
|
2566
2566
|
name: node.name ?? null,
|
|
2567
2567
|
ref: canonical.ref,
|
|
@@ -2602,7 +2602,12 @@ function createInputStream({ schemas, parseSchema, parseOperation, document, par
|
|
|
2602
2602
|
}
|
|
2603
2603
|
})();
|
|
2604
2604
|
} };
|
|
2605
|
-
return ast.
|
|
2605
|
+
return ast.factory.createInput({
|
|
2606
|
+
stream: true,
|
|
2607
|
+
schemas: schemasIterable,
|
|
2608
|
+
operations: operationsIterable,
|
|
2609
|
+
meta
|
|
2610
|
+
});
|
|
2606
2611
|
}
|
|
2607
2612
|
//#endregion
|
|
2608
2613
|
//#region src/adapter.ts
|
|
@@ -2761,7 +2766,7 @@ const adapterOas = createAdapter((options) => {
|
|
|
2761
2766
|
const rawName = extractRefName(schemaRef.ref);
|
|
2762
2767
|
const result = resolve(nameMapping.get(rawName) ?? rawName);
|
|
2763
2768
|
if (!result) return null;
|
|
2764
|
-
return ast.createImport({
|
|
2769
|
+
return ast.factory.createImport({
|
|
2765
2770
|
name: [result.name],
|
|
2766
2771
|
path: result.path
|
|
2767
2772
|
});
|
|
@@ -2770,7 +2775,7 @@ const adapterOas = createAdapter((options) => {
|
|
|
2770
2775
|
async parse(source) {
|
|
2771
2776
|
const streamNode = await createStream(source);
|
|
2772
2777
|
const [schemas, operations] = await Promise.all([Array.fromAsync(streamNode.schemas), Array.fromAsync(streamNode.operations)]);
|
|
2773
|
-
return ast.createInput({
|
|
2778
|
+
return ast.factory.createInput({
|
|
2774
2779
|
schemas,
|
|
2775
2780
|
operations,
|
|
2776
2781
|
meta: streamNode.meta
|