@kubb/adapter-oas 5.0.0-beta.20 → 5.0.0-beta.22

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 CHANGED
@@ -366,12 +366,13 @@ var URLPath = class {
366
366
  * @example
367
367
  * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
368
368
  */
369
- toTemplateString({ prefix = "", replacer } = {}) {
370
- return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
369
+ toTemplateString({ prefix, replacer } = {}) {
370
+ const result = this.path.split(/\{([^}]+)\}/).map((part, i) => {
371
371
  if (i % 2 === 0) return part;
372
372
  const param = this.#transformParam(part);
373
373
  return `\${${replacer ? replacer(param) : param}}`;
374
- }).join("")}\``;
374
+ }).join("");
375
+ return `\`${prefix ?? ""}${result}\``;
375
376
  }
376
377
  /**
377
378
  * Extracts all `{param}` segments from the path and returns them as a key-value map.
@@ -1177,7 +1178,7 @@ function createSchemaParser(ctx) {
1177
1178
  * Circular refs are detected via `resolvingRefs` and leave `schema` as `undefined`.
1178
1179
  */
1179
1180
  function convertRef({ schema, name, nullable, defaultValue, rawOptions }) {
1180
- let resolvedSchema;
1181
+ let resolvedSchema = null;
1181
1182
  const refPath = schema.$ref;
1182
1183
  if (refPath && !resolvingRefs.has(refPath)) {
1183
1184
  if (!resolvedRefCache.has(refPath)) {
@@ -1191,7 +1192,7 @@ function createSchemaParser(ctx) {
1191
1192
  } catch {}
1192
1193
  resolvedRefCache.set(refPath, resolvedSchema);
1193
1194
  }
1194
- resolvedSchema = resolvedRefCache.get(refPath);
1195
+ resolvedSchema = resolvedRefCache.get(refPath) ?? null;
1195
1196
  }
1196
1197
  return _kubb_core.ast.createSchema({
1197
1198
  ...buildSchemaNode(schema, name, nullable, defaultValue),
@@ -1577,7 +1578,7 @@ function createSchemaParser(ctx) {
1577
1578
  */
1578
1579
  function convertArray({ schema, name, nullable, defaultValue, rawOptions, options }) {
1579
1580
  const rawItems = schema.items;
1580
- const itemName = rawItems?.enum?.length && name ? _kubb_core.ast.enumPropName(void 0, name, options.enumSuffix) : void 0;
1581
+ const itemName = rawItems?.enum?.length && name ? _kubb_core.ast.enumPropName(null, name, options.enumSuffix) : void 0;
1581
1582
  const items = rawItems ? [parseSchema({
1582
1583
  schema: rawItems,
1583
1584
  name: itemName
@@ -1768,13 +1769,13 @@ function createSchemaParser(ctx) {
1768
1769
  * `$ref` entries are skipped since their flags live on the dereferenced target.
1769
1770
  */
1770
1771
  function collectPropertyKeysByFlag(schema, flag) {
1771
- if (!schema?.properties) return void 0;
1772
+ if (!schema?.properties) return null;
1772
1773
  const keys = [];
1773
1774
  for (const key in schema.properties) {
1774
1775
  const prop = schema.properties[key];
1775
1776
  if (prop && !isReference(prop) && prop[flag]) keys.push(key);
1776
1777
  }
1777
- return keys.length ? keys : void 0;
1778
+ return keys.length ? keys : null;
1778
1779
  }
1779
1780
  /**
1780
1781
  * Converts an OAS `Operation` into an `OperationNode`.
@@ -1860,15 +1861,15 @@ function buildDiscriminatorChildMap(schemas) {
1860
1861
  for (const member of members) {
1861
1862
  const intersectionNode = _kubb_core.ast.narrowSchema(member, "intersection");
1862
1863
  if (!intersectionNode?.members) continue;
1863
- let refNode;
1864
- let objNode;
1864
+ let refNode = null;
1865
+ let objNode = null;
1865
1866
  for (const m of intersectionNode.members) {
1866
1867
  refNode ??= _kubb_core.ast.narrowSchema(m, "ref");
1867
1868
  objNode ??= _kubb_core.ast.narrowSchema(m, "object");
1868
1869
  }
1869
1870
  if (!refNode?.name || !objNode) continue;
1870
1871
  const prop = objNode.properties.find((p) => p.name === discriminatorPropertyName);
1871
- const enumNode = prop ? _kubb_core.ast.narrowSchema(prop.schema, "enum") : void 0;
1872
+ const enumNode = prop ? _kubb_core.ast.narrowSchema(prop.schema, "enum") : null;
1872
1873
  if (!enumNode?.enumValues?.length) continue;
1873
1874
  const enumValues = enumNode.enumValues.filter((v) => v !== null);
1874
1875
  if (!enumValues.length) continue;
@@ -1916,7 +1917,7 @@ function patchDiscriminatorNode(node, entry) {
1916
1917
  * Reads the server URL from the document's `servers` array at `serverIndex`,
1917
1918
  * interpolating any `serverVariables` into the URL template.
1918
1919
  *
1919
- * Returns `undefined` when `serverIndex` is omitted or out of range.
1920
+ * Returns `null` when `serverIndex` is omitted or out of range.
1920
1921
  *
1921
1922
  * @example Resolve the first server
1922
1923
  * `resolveBaseUrl({ document, serverIndex: 0 })`
@@ -1926,7 +1927,7 @@ function patchDiscriminatorNode(node, entry) {
1926
1927
  */
1927
1928
  function resolveBaseUrl({ document, serverIndex, serverVariables }) {
1928
1929
  const server = serverIndex !== void 0 ? document.servers?.at(serverIndex) : void 0;
1929
- return server?.url ? resolveServerUrl(server, serverVariables) : void 0;
1930
+ return server?.url ? resolveServerUrl(server, serverVariables) : null;
1930
1931
  }
1931
1932
  /**
1932
1933
  * Parses every schema once to build the lookup structures that streaming needs upfront.
@@ -2142,7 +2143,7 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
2142
2143
  nameMapping,
2143
2144
  resolve: (schemaName) => {
2144
2145
  const result = resolve(schemaName);
2145
- if (!result) return;
2146
+ if (!result) return null;
2146
2147
  return _kubb_core.ast.createImport({
2147
2148
  name: [result.name],
2148
2149
  path: result.path