@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.cjs
CHANGED
|
@@ -1518,7 +1518,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
resolvedSchema = resolvedRefCache.get(refPath) ?? null;
|
|
1520
1520
|
}
|
|
1521
|
-
return _kubb_core.ast.createSchema({
|
|
1521
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1522
1522
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1523
1523
|
type: "ref",
|
|
1524
1524
|
name: (0, _kubb_ast_utils.extractRefName)(schema.$ref),
|
|
@@ -1539,7 +1539,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1539
1539
|
const { kind: _kind, ...memberNodeProps } = memberNode;
|
|
1540
1540
|
const mergedNullable = nullable || memberNode.nullable || void 0;
|
|
1541
1541
|
const mergedDefault = schema.default === null && mergedNullable ? void 0 : schema.default ?? memberNode.default;
|
|
1542
|
-
return _kubb_core.ast.createSchema({
|
|
1542
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1543
1543
|
...memberNodeProps,
|
|
1544
1544
|
name,
|
|
1545
1545
|
title: schema.title ?? memberNode.title,
|
|
@@ -1603,11 +1603,11 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1603
1603
|
const { allOf: _allOf, ...schemaWithoutAllOf } = schema;
|
|
1604
1604
|
allOfMembers.push(parseSchema({ schema: schemaWithoutAllOf }, rawOptions));
|
|
1605
1605
|
}
|
|
1606
|
-
for (const { propertyName, value } of filteredDiscriminantValues) allOfMembers.push(_kubb_core.ast.createDiscriminantNode({
|
|
1606
|
+
for (const { propertyName, value } of filteredDiscriminantValues) allOfMembers.push(_kubb_core.ast.factory.createDiscriminantNode({
|
|
1607
1607
|
propertyName,
|
|
1608
1608
|
value
|
|
1609
1609
|
}));
|
|
1610
|
-
return _kubb_core.ast.createSchema({
|
|
1610
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1611
1611
|
type: "intersection",
|
|
1612
1612
|
members: [..._kubb_core.ast.mergeAdjacentObjectsLazy(allOfMembers.slice(0, syntheticStart)), ..._kubb_core.ast.mergeAdjacentObjectsLazy(allOfMembers.slice(syntheticStart))],
|
|
1613
1613
|
...buildSchemaNode(schema, name, nullable, defaultValue)
|
|
@@ -1620,7 +1620,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1620
1620
|
function pickDiscriminatorPropertyNode(node, propertyName) {
|
|
1621
1621
|
const discriminatorProperty = _kubb_core.ast.narrowSchema(node, "object")?.properties?.find((property) => property.name === propertyName);
|
|
1622
1622
|
if (!discriminatorProperty) return null;
|
|
1623
|
-
return _kubb_core.ast.createSchema({
|
|
1623
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1624
1624
|
type: "object",
|
|
1625
1625
|
primitive: "object",
|
|
1626
1626
|
properties: [discriminatorProperty]
|
|
@@ -1655,27 +1655,27 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1655
1655
|
propertyName: discriminator.propertyName,
|
|
1656
1656
|
values: [discriminatorValue]
|
|
1657
1657
|
}), discriminator.propertyName) : void 0;
|
|
1658
|
-
return _kubb_core.ast.createSchema({
|
|
1658
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1659
1659
|
type: "intersection",
|
|
1660
|
-
members: [memberNode, narrowedDiscriminatorNode ?? _kubb_core.ast.createDiscriminantNode({
|
|
1660
|
+
members: [memberNode, narrowedDiscriminatorNode ?? _kubb_core.ast.factory.createDiscriminantNode({
|
|
1661
1661
|
propertyName: discriminator.propertyName,
|
|
1662
1662
|
value: discriminatorValue
|
|
1663
1663
|
})]
|
|
1664
1664
|
});
|
|
1665
1665
|
});
|
|
1666
|
-
const unionNode = _kubb_core.ast.createSchema({
|
|
1666
|
+
const unionNode = _kubb_core.ast.factory.createSchema({
|
|
1667
1667
|
type: "union",
|
|
1668
1668
|
...unionBase,
|
|
1669
1669
|
members
|
|
1670
1670
|
});
|
|
1671
1671
|
if (!sharedPropertiesNode) return unionNode;
|
|
1672
|
-
return _kubb_core.ast.createSchema({
|
|
1672
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1673
1673
|
type: "intersection",
|
|
1674
1674
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1675
1675
|
members: [unionNode, sharedPropertiesNode]
|
|
1676
1676
|
});
|
|
1677
1677
|
}
|
|
1678
|
-
return _kubb_core.ast.createSchema({
|
|
1678
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1679
1679
|
type: "union",
|
|
1680
1680
|
...unionBase,
|
|
1681
1681
|
members: _kubb_core.ast.simplifyUnion(unionMembers.map((s) => parseSchema({
|
|
@@ -1689,7 +1689,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1689
1689
|
*/
|
|
1690
1690
|
function convertConst({ schema, name, nullable, defaultValue }) {
|
|
1691
1691
|
const constValue = schema.const;
|
|
1692
|
-
if (constValue === null) return _kubb_core.ast.createSchema({
|
|
1692
|
+
if (constValue === null) return _kubb_core.ast.factory.createSchema({
|
|
1693
1693
|
type: "null",
|
|
1694
1694
|
primitive: "null",
|
|
1695
1695
|
name,
|
|
@@ -1699,7 +1699,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1699
1699
|
format: schema.format
|
|
1700
1700
|
});
|
|
1701
1701
|
const constPrimitive = getPrimitiveType(typeof constValue === "number" ? "number" : typeof constValue === "boolean" ? "boolean" : "string");
|
|
1702
|
-
return _kubb_core.ast.createSchema({
|
|
1702
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1703
1703
|
type: "enum",
|
|
1704
1704
|
primitive: constPrimitive,
|
|
1705
1705
|
enumValues: [constValue],
|
|
@@ -1712,7 +1712,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1712
1712
|
*/
|
|
1713
1713
|
function convertFormat({ schema, name, nullable, defaultValue, options }) {
|
|
1714
1714
|
const base = buildSchemaNode(schema, name, nullable, defaultValue);
|
|
1715
|
-
if (schema.format === "int64") return _kubb_core.ast.createSchema({
|
|
1715
|
+
if (schema.format === "int64") return _kubb_core.ast.factory.createSchema({
|
|
1716
1716
|
type: options.integerType === "bigint" ? "bigint" : "integer",
|
|
1717
1717
|
primitive: "integer",
|
|
1718
1718
|
...base,
|
|
@@ -1724,14 +1724,14 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1724
1724
|
if (schema.format === "date-time" || schema.format === "date" || schema.format === "time") {
|
|
1725
1725
|
const dateType = getDateType(options, schema.format);
|
|
1726
1726
|
if (!dateType) return null;
|
|
1727
|
-
if (dateType.type === "datetime") return _kubb_core.ast.createSchema({
|
|
1727
|
+
if (dateType.type === "datetime") return _kubb_core.ast.factory.createSchema({
|
|
1728
1728
|
...base,
|
|
1729
1729
|
primitive: "string",
|
|
1730
1730
|
type: "datetime",
|
|
1731
1731
|
offset: dateType.offset,
|
|
1732
1732
|
local: dateType.local
|
|
1733
1733
|
});
|
|
1734
|
-
return _kubb_core.ast.createSchema({
|
|
1734
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1735
1735
|
...base,
|
|
1736
1736
|
primitive: "string",
|
|
1737
1737
|
type: dateType.type,
|
|
@@ -1741,36 +1741,36 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1741
1741
|
const specialType = getSchemaType(schema.format);
|
|
1742
1742
|
if (!specialType) return null;
|
|
1743
1743
|
const specialPrimitive = specialType === "number" || specialType === "integer" || specialType === "bigint" ? specialType : "string";
|
|
1744
|
-
if (specialType === "number" || specialType === "integer" || specialType === "bigint") return _kubb_core.ast.createSchema({
|
|
1744
|
+
if (specialType === "number" || specialType === "integer" || specialType === "bigint") return _kubb_core.ast.factory.createSchema({
|
|
1745
1745
|
...base,
|
|
1746
1746
|
primitive: specialPrimitive,
|
|
1747
1747
|
type: specialType
|
|
1748
1748
|
});
|
|
1749
|
-
if (specialType === "url") return _kubb_core.ast.createSchema({
|
|
1749
|
+
if (specialType === "url") return _kubb_core.ast.factory.createSchema({
|
|
1750
1750
|
...base,
|
|
1751
1751
|
primitive: "string",
|
|
1752
1752
|
type: "url",
|
|
1753
1753
|
min: schema.minLength,
|
|
1754
1754
|
max: schema.maxLength
|
|
1755
1755
|
});
|
|
1756
|
-
if (specialType === "ipv4") return _kubb_core.ast.createSchema({
|
|
1756
|
+
if (specialType === "ipv4") return _kubb_core.ast.factory.createSchema({
|
|
1757
1757
|
...base,
|
|
1758
1758
|
primitive: "string",
|
|
1759
1759
|
type: "ipv4"
|
|
1760
1760
|
});
|
|
1761
|
-
if (specialType === "ipv6") return _kubb_core.ast.createSchema({
|
|
1761
|
+
if (specialType === "ipv6") return _kubb_core.ast.factory.createSchema({
|
|
1762
1762
|
...base,
|
|
1763
1763
|
primitive: "string",
|
|
1764
1764
|
type: "ipv6"
|
|
1765
1765
|
});
|
|
1766
|
-
if (specialType === "uuid" || specialType === "email") return _kubb_core.ast.createSchema({
|
|
1766
|
+
if (specialType === "uuid" || specialType === "email") return _kubb_core.ast.factory.createSchema({
|
|
1767
1767
|
...base,
|
|
1768
1768
|
primitive: "string",
|
|
1769
1769
|
type: specialType,
|
|
1770
1770
|
min: schema.minLength,
|
|
1771
1771
|
max: schema.maxLength
|
|
1772
1772
|
});
|
|
1773
|
-
return _kubb_core.ast.createSchema({
|
|
1773
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1774
1774
|
...base,
|
|
1775
1775
|
primitive: specialPrimitive,
|
|
1776
1776
|
type: specialType
|
|
@@ -1786,7 +1786,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1786
1786
|
}, rawOptions);
|
|
1787
1787
|
const nullInEnum = schema.enum.includes(null);
|
|
1788
1788
|
const filteredValues = nullInEnum ? schema.enum.filter((v) => v !== null) : schema.enum;
|
|
1789
|
-
if (nullInEnum && filteredValues.length === 0) return _kubb_core.ast.createSchema({
|
|
1789
|
+
if (nullInEnum && filteredValues.length === 0) return _kubb_core.ast.factory.createSchema({
|
|
1790
1790
|
type: "null",
|
|
1791
1791
|
primitive: "null",
|
|
1792
1792
|
name,
|
|
@@ -1818,7 +1818,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1818
1818
|
const rawEnumNames = extensionKey ? schema[extensionKey] : void 0;
|
|
1819
1819
|
const uniqueValues = [...new Set(filteredValues)];
|
|
1820
1820
|
const seenNames = /* @__PURE__ */ new Set();
|
|
1821
|
-
return _kubb_core.ast.createSchema({
|
|
1821
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1822
1822
|
...enumBase,
|
|
1823
1823
|
primitive: enumPrimitiveType,
|
|
1824
1824
|
namedEnumValues: uniqueValues.map((value, index) => ({
|
|
@@ -1832,7 +1832,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1832
1832
|
})
|
|
1833
1833
|
});
|
|
1834
1834
|
}
|
|
1835
|
-
return _kubb_core.ast.createSchema({
|
|
1835
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1836
1836
|
...enumBase,
|
|
1837
1837
|
enumValues: [...new Set(filteredValues)]
|
|
1838
1838
|
});
|
|
@@ -1861,7 +1861,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1861
1861
|
}
|
|
1862
1862
|
return node;
|
|
1863
1863
|
})();
|
|
1864
|
-
return _kubb_core.ast.createProperty({
|
|
1864
|
+
return _kubb_core.ast.factory.createProperty({
|
|
1865
1865
|
name: propName,
|
|
1866
1866
|
schema: {
|
|
1867
1867
|
...schemaNode,
|
|
@@ -1875,11 +1875,11 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1875
1875
|
if (additionalProperties === true) return true;
|
|
1876
1876
|
if (additionalProperties === false) return false;
|
|
1877
1877
|
if (additionalProperties && Object.keys(additionalProperties).length > 0) return parseSchema({ schema: additionalProperties }, rawOptions);
|
|
1878
|
-
if (additionalProperties) return _kubb_core.ast.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
1878
|
+
if (additionalProperties) return _kubb_core.ast.factory.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
1879
1879
|
})();
|
|
1880
1880
|
const rawPatternProperties = "patternProperties" in schema ? schema.patternProperties : void 0;
|
|
1881
|
-
const patternProperties = rawPatternProperties ? Object.fromEntries(Object.entries(rawPatternProperties).map(([pattern, patternSchema]) => [pattern, patternSchema === true || typeof patternSchema === "object" && Object.keys(patternSchema).length === 0 ? _kubb_core.ast.createSchema({ type: typeOptionMap.get(options.unknownType) }) : parseSchema({ schema: patternSchema }, rawOptions)])) : void 0;
|
|
1882
|
-
const objectNode = _kubb_core.ast.createSchema({
|
|
1881
|
+
const patternProperties = rawPatternProperties ? Object.fromEntries(Object.entries(rawPatternProperties).map(([pattern, patternSchema]) => [pattern, patternSchema === true || typeof patternSchema === "object" && Object.keys(patternSchema).length === 0 ? _kubb_core.ast.factory.createSchema({ type: typeOptionMap.get(options.unknownType) }) : parseSchema({ schema: patternSchema }, rawOptions)])) : void 0;
|
|
1882
|
+
const objectNode = _kubb_core.ast.factory.createSchema({
|
|
1883
1883
|
type: "object",
|
|
1884
1884
|
primitive: "object",
|
|
1885
1885
|
properties,
|
|
@@ -1907,8 +1907,8 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1907
1907
|
*/
|
|
1908
1908
|
function convertTuple({ schema, name, nullable, defaultValue, rawOptions }) {
|
|
1909
1909
|
const tupleItems = (schema.prefixItems ?? []).map((item) => parseSchema({ schema: item }, rawOptions));
|
|
1910
|
-
const rest = schema.items ? parseSchema({ schema: schema.items }, rawOptions) : _kubb_core.ast.createSchema({ type: "any" });
|
|
1911
|
-
return _kubb_core.ast.createSchema({
|
|
1910
|
+
const rest = schema.items ? parseSchema({ schema: schema.items }, rawOptions) : _kubb_core.ast.factory.createSchema({ type: "any" });
|
|
1911
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1912
1912
|
type: "tuple",
|
|
1913
1913
|
primitive: "array",
|
|
1914
1914
|
items: tupleItems,
|
|
@@ -1928,7 +1928,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1928
1928
|
schema: rawItems,
|
|
1929
1929
|
name: itemName
|
|
1930
1930
|
}, rawOptions)] : [];
|
|
1931
|
-
return _kubb_core.ast.createSchema({
|
|
1931
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1932
1932
|
type: "array",
|
|
1933
1933
|
primitive: "array",
|
|
1934
1934
|
items,
|
|
@@ -1942,7 +1942,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1942
1942
|
* Converts a `type: 'string'` schema into a `StringSchemaNode`.
|
|
1943
1943
|
*/
|
|
1944
1944
|
function convertString({ schema, name, nullable, defaultValue }) {
|
|
1945
|
-
return _kubb_core.ast.createSchema({
|
|
1945
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1946
1946
|
type: "string",
|
|
1947
1947
|
primitive: "string",
|
|
1948
1948
|
min: schema.minLength,
|
|
@@ -1955,7 +1955,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1955
1955
|
* Converts a `type: 'number'` or `type: 'integer'` schema.
|
|
1956
1956
|
*/
|
|
1957
1957
|
function convertNumeric({ schema, name, nullable, defaultValue }, type) {
|
|
1958
|
-
return _kubb_core.ast.createSchema({
|
|
1958
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1959
1959
|
type,
|
|
1960
1960
|
primitive: type,
|
|
1961
1961
|
min: schema.minimum,
|
|
@@ -1970,7 +1970,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1970
1970
|
* Converts a `type: 'boolean'` schema.
|
|
1971
1971
|
*/
|
|
1972
1972
|
function convertBoolean({ schema, name, nullable, defaultValue }) {
|
|
1973
|
-
return _kubb_core.ast.createSchema({
|
|
1973
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1974
1974
|
type: "boolean",
|
|
1975
1975
|
primitive: "boolean",
|
|
1976
1976
|
...buildSchemaNode(schema, name, nullable, defaultValue)
|
|
@@ -1980,7 +1980,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1980
1980
|
* Converts an explicit `type: 'null'` schema.
|
|
1981
1981
|
*/
|
|
1982
1982
|
function convertNull({ schema, name, nullable }) {
|
|
1983
|
-
return _kubb_core.ast.createSchema({
|
|
1983
|
+
return _kubb_core.ast.factory.createSchema({
|
|
1984
1984
|
type: "null",
|
|
1985
1985
|
primitive: "null",
|
|
1986
1986
|
name,
|
|
@@ -1996,7 +1996,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1996
1996
|
* into a `blob` node.
|
|
1997
1997
|
*/
|
|
1998
1998
|
function convertBlob({ schema, name, nullable, defaultValue }) {
|
|
1999
|
-
return _kubb_core.ast.createSchema({
|
|
1999
|
+
return _kubb_core.ast.factory.createSchema({
|
|
2000
2000
|
type: "blob",
|
|
2001
2001
|
primitive: "string",
|
|
2002
2002
|
...buildSchemaNode(schema, name, nullable, defaultValue)
|
|
@@ -2013,7 +2013,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2013
2013
|
const nonNullTypes = types.filter((t) => t !== "null");
|
|
2014
2014
|
if (nonNullTypes.length <= 1) return null;
|
|
2015
2015
|
const arrayNullable = types.includes("null") || nullable || void 0;
|
|
2016
|
-
return _kubb_core.ast.createSchema({
|
|
2016
|
+
return _kubb_core.ast.factory.createSchema({
|
|
2017
2017
|
type: "union",
|
|
2018
2018
|
members: nonNullTypes.map((t) => parseSchema({
|
|
2019
2019
|
schema: {
|
|
@@ -2156,7 +2156,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2156
2156
|
if (node) return node;
|
|
2157
2157
|
}
|
|
2158
2158
|
const emptyType = typeOptionMap.get(options.emptySchemaType);
|
|
2159
|
-
return _kubb_core.ast.createSchema({
|
|
2159
|
+
return _kubb_core.ast.factory.createSchema({
|
|
2160
2160
|
type: emptyType,
|
|
2161
2161
|
name,
|
|
2162
2162
|
title: schema.title,
|
|
@@ -2174,8 +2174,8 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2174
2174
|
const schema = param["schema"] ? parseSchema({
|
|
2175
2175
|
schema: param["schema"],
|
|
2176
2176
|
name: schemaName
|
|
2177
|
-
}, options) : _kubb_core.ast.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
2178
|
-
return _kubb_core.ast.createParameter({
|
|
2177
|
+
}, options) : _kubb_core.ast.factory.createSchema({ type: typeOptionMap.get(options.unknownType) });
|
|
2178
|
+
return _kubb_core.ast.factory.createParameter({
|
|
2179
2179
|
name: paramName,
|
|
2180
2180
|
in: param["in"],
|
|
2181
2181
|
schema: {
|
|
@@ -2262,7 +2262,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2262
2262
|
schema: raw && Object.keys(raw).length > 0 ? parseSchema({
|
|
2263
2263
|
schema: raw,
|
|
2264
2264
|
name: responseName
|
|
2265
|
-
}, options) : _kubb_core.ast.createSchema({ type: typeOptionMap.get(options.emptySchemaType) }),
|
|
2265
|
+
}, options) : _kubb_core.ast.factory.createSchema({ type: typeOptionMap.get(options.emptySchemaType) }),
|
|
2266
2266
|
keysToOmit: collectPropertyKeysByFlag(raw, "writeOnly")
|
|
2267
2267
|
};
|
|
2268
2268
|
};
|
|
@@ -2277,7 +2277,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2277
2277
|
}) || "application/json",
|
|
2278
2278
|
...parseEntrySchema(ctx.contentType)
|
|
2279
2279
|
});
|
|
2280
|
-
return _kubb_core.ast.createResponse({
|
|
2280
|
+
return _kubb_core.ast.factory.createResponse({
|
|
2281
2281
|
statusCode,
|
|
2282
2282
|
description,
|
|
2283
2283
|
content
|
|
@@ -2291,7 +2291,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2291
2291
|
const fallback = pathItemDoc?.[key];
|
|
2292
2292
|
return typeof fallback === "string" ? fallback : void 0;
|
|
2293
2293
|
};
|
|
2294
|
-
return _kubb_core.ast.createOperation({
|
|
2294
|
+
return _kubb_core.ast.factory.createOperation({
|
|
2295
2295
|
operationId,
|
|
2296
2296
|
protocol: "http",
|
|
2297
2297
|
method: operation.method.toUpperCase(),
|
|
@@ -2373,11 +2373,11 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
2373
2373
|
const objectNode = _kubb_core.ast.narrowSchema(node, "object");
|
|
2374
2374
|
if (!objectNode) return node;
|
|
2375
2375
|
const { propertyName, enumValues } = entry;
|
|
2376
|
-
const enumSchema = _kubb_core.ast.createSchema({
|
|
2376
|
+
const enumSchema = _kubb_core.ast.factory.createSchema({
|
|
2377
2377
|
type: "enum",
|
|
2378
2378
|
enumValues
|
|
2379
2379
|
});
|
|
2380
|
-
const newProp = _kubb_core.ast.createProperty({
|
|
2380
|
+
const newProp = _kubb_core.ast.factory.createProperty({
|
|
2381
2381
|
name: propertyName,
|
|
2382
2382
|
required: true,
|
|
2383
2383
|
schema: enumSchema
|
|
@@ -2462,7 +2462,7 @@ function createDedupePlan({ schemaNodes, operationNodes, schemaNames, circularNa
|
|
|
2462
2462
|
if (node.type === "enum") return true;
|
|
2463
2463
|
if (node.type !== "object") return false;
|
|
2464
2464
|
if (node.name && circularSchemas.has(node.name)) return false;
|
|
2465
|
-
return !
|
|
2465
|
+
return !(0, _kubb_ast_utils.containsCircularRef)(node, { circularSchemas });
|
|
2466
2466
|
},
|
|
2467
2467
|
nameFor: (node) => {
|
|
2468
2468
|
const base = node.name;
|
|
@@ -2536,7 +2536,7 @@ function preScan({ schemas, parseSchema, parseOperation, document, parserOptions
|
|
|
2536
2536
|
if (_kubb_core.ast.narrowSchema(node, _kubb_core.ast.schemaTypes.enum) && node.name) enumNames.push(node.name);
|
|
2537
2537
|
if (discriminator === "inherit" && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) discriminatorParentNodes.push(node);
|
|
2538
2538
|
}
|
|
2539
|
-
const circularNames = [...
|
|
2539
|
+
const circularNames = [...(0, _kubb_ast_utils.findCircularSchemas)(allNodes)];
|
|
2540
2540
|
const discriminatorChildMap = discriminatorParentNodes.length > 0 ? buildDiscriminatorChildMap(discriminatorParentNodes) : null;
|
|
2541
2541
|
let dedupePlan = null;
|
|
2542
2542
|
if (dedupe) {
|
|
@@ -2584,7 +2584,7 @@ function createInputStream({ schemas, parseSchema, parseOperation, document, par
|
|
|
2584
2584
|
const rewriteTopLevelSchema = (node) => {
|
|
2585
2585
|
if (!dedupePlan) return node;
|
|
2586
2586
|
const canonical = dedupePlan.canonicalBySignature.get(_kubb_core.ast.signatureOf(node));
|
|
2587
|
-
if (canonical && canonical.name !== node.name) return _kubb_core.ast.createSchema({
|
|
2587
|
+
if (canonical && canonical.name !== node.name) return _kubb_core.ast.factory.createSchema({
|
|
2588
2588
|
type: "ref",
|
|
2589
2589
|
name: node.name ?? null,
|
|
2590
2590
|
ref: canonical.ref,
|
|
@@ -2625,7 +2625,12 @@ function createInputStream({ schemas, parseSchema, parseOperation, document, par
|
|
|
2625
2625
|
}
|
|
2626
2626
|
})();
|
|
2627
2627
|
} };
|
|
2628
|
-
return _kubb_core.ast.
|
|
2628
|
+
return _kubb_core.ast.factory.createInput({
|
|
2629
|
+
stream: true,
|
|
2630
|
+
schemas: schemasIterable,
|
|
2631
|
+
operations: operationsIterable,
|
|
2632
|
+
meta
|
|
2633
|
+
});
|
|
2629
2634
|
}
|
|
2630
2635
|
//#endregion
|
|
2631
2636
|
//#region src/adapter.ts
|
|
@@ -2784,7 +2789,7 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
2784
2789
|
const rawName = (0, _kubb_ast_utils.extractRefName)(schemaRef.ref);
|
|
2785
2790
|
const result = resolve(nameMapping.get(rawName) ?? rawName);
|
|
2786
2791
|
if (!result) return null;
|
|
2787
|
-
return _kubb_core.ast.createImport({
|
|
2792
|
+
return _kubb_core.ast.factory.createImport({
|
|
2788
2793
|
name: [result.name],
|
|
2789
2794
|
path: result.path
|
|
2790
2795
|
});
|
|
@@ -2793,7 +2798,7 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
2793
2798
|
async parse(source) {
|
|
2794
2799
|
const streamNode = await createStream(source);
|
|
2795
2800
|
const [schemas, operations] = await Promise.all([Array.fromAsync(streamNode.schemas), Array.fromAsync(streamNode.operations)]);
|
|
2796
|
-
return _kubb_core.ast.createInput({
|
|
2801
|
+
return _kubb_core.ast.factory.createInput({
|
|
2797
2802
|
schemas,
|
|
2798
2803
|
operations,
|
|
2799
2804
|
meta: streamNode.meta
|