@kubb/adapter-oas 5.0.0-alpha.31 → 5.0.0-alpha.33
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 +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/adapter.ts +9 -9
- package/src/discriminator.ts +5 -5
- package/src/parser.ts +5 -5
package/dist/index.cjs
CHANGED
|
@@ -152,11 +152,11 @@ const typeOptionMap = new Map([
|
|
|
152
152
|
/**
|
|
153
153
|
* Injects discriminator enum values into child schemas so they know which value identifies them.
|
|
154
154
|
*
|
|
155
|
-
* Finds every union schema in `
|
|
155
|
+
* Finds every union schema in `input.schemas` that has a `discriminatorPropertyName`, collects the
|
|
156
156
|
* enum value each union member is mapped to, then adds (or replaces) that property on the matching
|
|
157
157
|
* child object schema.
|
|
158
158
|
*
|
|
159
|
-
* Returns a new `
|
|
159
|
+
* Returns a new `InputNode` — the original is never mutated.
|
|
160
160
|
*
|
|
161
161
|
* @example
|
|
162
162
|
* ```ts
|
|
@@ -205,7 +205,7 @@ function applyDiscriminatorInheritance(root) {
|
|
|
205
205
|
}
|
|
206
206
|
if (childMap.size === 0) return root;
|
|
207
207
|
return (0, _kubb_ast.transform)(root, { schema(node, { parent }) {
|
|
208
|
-
if (parent?.kind !== "
|
|
208
|
+
if (parent?.kind !== "Input" || !node.name) return;
|
|
209
209
|
const entry = childMap.get(node.name);
|
|
210
210
|
if (!entry) return;
|
|
211
211
|
const objectNode = (0, _kubb_ast.narrowSchema)(node, "object");
|
|
@@ -1630,7 +1630,7 @@ function createSchemaParser(ctx) {
|
|
|
1630
1630
|
};
|
|
1631
1631
|
}
|
|
1632
1632
|
/**
|
|
1633
|
-
* Converts the entire OpenAPI spec into
|
|
1633
|
+
* Converts the entire OpenAPI spec into an `InputNode` (the top-level `@kubb/ast` tree).
|
|
1634
1634
|
*
|
|
1635
1635
|
* This is the main entry point: `OpenAPI / Swagger → Kubb AST`.
|
|
1636
1636
|
* No code is generated here — the resulting tree is spec-agnostic and consumed by
|
|
@@ -1659,7 +1659,7 @@ function parseOas(document, options = {}) {
|
|
|
1659
1659
|
}, mergedOptions));
|
|
1660
1660
|
const paths = new oas.default(document).getPaths();
|
|
1661
1661
|
return {
|
|
1662
|
-
root: (0, _kubb_ast.
|
|
1662
|
+
root: (0, _kubb_ast.createInput)({
|
|
1663
1663
|
schemas,
|
|
1664
1664
|
operations: Object.entries(paths).flatMap(([_path, methods]) => Object.entries(methods).map(([, operation]) => operation ? _parseOperation(mergedOptions, operation) : null).filter((op) => op !== null))
|
|
1665
1665
|
}),
|
|
@@ -1676,7 +1676,7 @@ const adapterOasName = "oas";
|
|
|
1676
1676
|
* Creates the default OpenAPI / Swagger adapter for Kubb.
|
|
1677
1677
|
*
|
|
1678
1678
|
* Parses the spec, optionally validates it, resolves the base URL, and converts
|
|
1679
|
-
* everything into
|
|
1679
|
+
* everything into an `InputNode` that downstream plugins consume.
|
|
1680
1680
|
*
|
|
1681
1681
|
* @example
|
|
1682
1682
|
* ```ts
|
|
@@ -1695,7 +1695,7 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
1695
1695
|
const { validate = true, contentType, serverIndex, serverVariables, discriminator = "strict", dateType = DEFAULT_PARSER_OPTIONS.dateType, integerType = DEFAULT_PARSER_OPTIONS.integerType, unknownType = DEFAULT_PARSER_OPTIONS.unknownType, enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix, emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType } = options;
|
|
1696
1696
|
let nameMapping = /* @__PURE__ */ new Map();
|
|
1697
1697
|
let parsedDocument;
|
|
1698
|
-
let
|
|
1698
|
+
let inputNode;
|
|
1699
1699
|
return {
|
|
1700
1700
|
name: "oas",
|
|
1701
1701
|
get options() {
|
|
@@ -1716,8 +1716,8 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
1716
1716
|
get document() {
|
|
1717
1717
|
return parsedDocument;
|
|
1718
1718
|
},
|
|
1719
|
-
get
|
|
1720
|
-
return
|
|
1719
|
+
get inputNode() {
|
|
1720
|
+
return inputNode;
|
|
1721
1721
|
},
|
|
1722
1722
|
getImports(node, resolve) {
|
|
1723
1723
|
return (0, _kubb_ast.collectImports)({
|
|
@@ -1726,10 +1726,10 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
1726
1726
|
resolve: (schemaName) => {
|
|
1727
1727
|
const result = resolve(schemaName);
|
|
1728
1728
|
if (!result) return;
|
|
1729
|
-
return {
|
|
1729
|
+
return (0, _kubb_ast.createImport)({
|
|
1730
1730
|
name: [result.name],
|
|
1731
1731
|
path: result.path
|
|
1732
|
-
};
|
|
1732
|
+
});
|
|
1733
1733
|
}
|
|
1734
1734
|
});
|
|
1735
1735
|
},
|
|
@@ -1749,7 +1749,7 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
1749
1749
|
const node = discriminator === "inherit" ? applyDiscriminatorInheritance(parsedRoot) : parsedRoot;
|
|
1750
1750
|
nameMapping = parsedNameMapping;
|
|
1751
1751
|
parsedDocument = document;
|
|
1752
|
-
|
|
1752
|
+
inputNode = (0, _kubb_ast.createInput)({
|
|
1753
1753
|
...node,
|
|
1754
1754
|
meta: {
|
|
1755
1755
|
title: document.info?.title,
|
|
@@ -1758,7 +1758,7 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
1758
1758
|
baseURL
|
|
1759
1759
|
}
|
|
1760
1760
|
});
|
|
1761
|
-
return
|
|
1761
|
+
return inputNode;
|
|
1762
1762
|
}
|
|
1763
1763
|
};
|
|
1764
1764
|
});
|