@kubb/adapter-oas 5.0.0-alpha.30 → 5.0.0-alpha.32

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk--u3MIqq1.js";
2
- import { childName, collectImports, createDiscriminantNode, createOperation, createParameter, createProperty, createResponse, createRoot, createSchema, enumPropName, extractRefName, findDiscriminator, mediaTypes, mergeAdjacentObjects, narrowSchema, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, transform } from "@kubb/ast";
2
+ import { childName, collectImports, createDiscriminantNode, createImport, createInput, createOperation, createParameter, createProperty, createResponse, createSchema, enumPropName, extractRefName, findDiscriminator, mediaTypes, mergeAdjacentObjects, narrowSchema, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, transform } from "@kubb/ast";
3
3
  import { createAdapter } from "@kubb/core";
4
4
  import path from "node:path";
5
5
  import { bundle, loadConfig } from "@redocly/openapi-core";
@@ -124,11 +124,11 @@ const typeOptionMap = new Map([
124
124
  /**
125
125
  * Injects discriminator enum values into child schemas so they know which value identifies them.
126
126
  *
127
- * Finds every union schema in `root.schemas` that has a `discriminatorPropertyName`, collects the
127
+ * Finds every union schema in `input.schemas` that has a `discriminatorPropertyName`, collects the
128
128
  * enum value each union member is mapped to, then adds (or replaces) that property on the matching
129
129
  * child object schema.
130
130
  *
131
- * Returns a new `RootNode` — the original is never mutated.
131
+ * Returns a new `InputNode` — the original is never mutated.
132
132
  *
133
133
  * @example
134
134
  * ```ts
@@ -177,7 +177,7 @@ function applyDiscriminatorInheritance(root) {
177
177
  }
178
178
  if (childMap.size === 0) return root;
179
179
  return transform(root, { schema(node, { parent }) {
180
- if (parent?.kind !== "Root" || !node.name) return;
180
+ if (parent?.kind !== "Input" || !node.name) return;
181
181
  const entry = childMap.get(node.name);
182
182
  if (!entry) return;
183
183
  const objectNode = narrowSchema(node, "object");
@@ -1602,7 +1602,7 @@ function createSchemaParser(ctx) {
1602
1602
  };
1603
1603
  }
1604
1604
  /**
1605
- * Converts the entire OpenAPI spec into a `RootNode` (the top-level `@kubb/ast` tree).
1605
+ * Converts the entire OpenAPI spec into an `InputNode` (the top-level `@kubb/ast` tree).
1606
1606
  *
1607
1607
  * This is the main entry point: `OpenAPI / Swagger → Kubb AST`.
1608
1608
  * No code is generated here — the resulting tree is spec-agnostic and consumed by
@@ -1631,7 +1631,7 @@ function parseOas(document, options = {}) {
1631
1631
  }, mergedOptions));
1632
1632
  const paths = new BaseOas(document).getPaths();
1633
1633
  return {
1634
- root: createRoot({
1634
+ root: createInput({
1635
1635
  schemas,
1636
1636
  operations: Object.entries(paths).flatMap(([_path, methods]) => Object.entries(methods).map(([, operation]) => operation ? _parseOperation(mergedOptions, operation) : null).filter((op) => op !== null))
1637
1637
  }),
@@ -1648,7 +1648,7 @@ const adapterOasName = "oas";
1648
1648
  * Creates the default OpenAPI / Swagger adapter for Kubb.
1649
1649
  *
1650
1650
  * Parses the spec, optionally validates it, resolves the base URL, and converts
1651
- * everything into a `RootNode` that downstream plugins consume.
1651
+ * everything into an `InputNode` that downstream plugins consume.
1652
1652
  *
1653
1653
  * @example
1654
1654
  * ```ts
@@ -1667,7 +1667,7 @@ const adapterOas = createAdapter((options) => {
1667
1667
  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;
1668
1668
  let nameMapping = /* @__PURE__ */ new Map();
1669
1669
  let parsedDocument;
1670
- let rootNode;
1670
+ let inputNode;
1671
1671
  return {
1672
1672
  name: "oas",
1673
1673
  get options() {
@@ -1688,8 +1688,8 @@ const adapterOas = createAdapter((options) => {
1688
1688
  get document() {
1689
1689
  return parsedDocument;
1690
1690
  },
1691
- get rootNode() {
1692
- return rootNode;
1691
+ get inputNode() {
1692
+ return inputNode;
1693
1693
  },
1694
1694
  getImports(node, resolve) {
1695
1695
  return collectImports({
@@ -1698,10 +1698,10 @@ const adapterOas = createAdapter((options) => {
1698
1698
  resolve: (schemaName) => {
1699
1699
  const result = resolve(schemaName);
1700
1700
  if (!result) return;
1701
- return {
1701
+ return createImport({
1702
1702
  name: [result.name],
1703
1703
  path: result.path
1704
- };
1704
+ });
1705
1705
  }
1706
1706
  });
1707
1707
  },
@@ -1721,7 +1721,7 @@ const adapterOas = createAdapter((options) => {
1721
1721
  const node = discriminator === "inherit" ? applyDiscriminatorInheritance(parsedRoot) : parsedRoot;
1722
1722
  nameMapping = parsedNameMapping;
1723
1723
  parsedDocument = document;
1724
- rootNode = createRoot({
1724
+ inputNode = createInput({
1725
1725
  ...node,
1726
1726
  meta: {
1727
1727
  title: document.info?.title,
@@ -1730,7 +1730,7 @@ const adapterOas = createAdapter((options) => {
1730
1730
  baseURL
1731
1731
  }
1732
1732
  });
1733
- return rootNode;
1733
+ return inputNode;
1734
1734
  }
1735
1735
  };
1736
1736
  });