@kubb/adapter-oas 5.0.0 → 5.0.2

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
@@ -1768,8 +1768,13 @@ function convertArray({ schema, name, nullable, defaultValue, rawOptions, option
1768
1768
  //#region src/emit/parseSchema.ts
1769
1769
  /**
1770
1770
  * Ordered schema rule table. Order is significant: composition keywords (`$ref`, `allOf`,
1771
- * `oneOf`/`anyOf`) take precedence over `const`/`format`, which take precedence over the plain
1772
- * `type`. The first matching rule that produces a node wins. See {@link SchemaRule} for the
1771
+ * `oneOf`/`anyOf`) take precedence over `const`, which takes precedence over a genuine OAS 3.1
1772
+ * multi-type array (more than one non-`null` type), which takes precedence over `format`/`type`.
1773
+ * A multi-type array must split into its per-type members before `format` runs, otherwise
1774
+ * `format` collapses the whole schema to one type (e.g. `type: ['null', 'integer', 'string'],
1775
+ * format: 'int32'` would drop `string` and emit just `integer`); each split-off member still
1776
+ * carries the original `format` and re-enters this table, so `format` still applies per member.
1777
+ * The first matching rule that produces a node wins. See {@link SchemaRule} for the
1773
1778
  * match/convert/fall-through contract.
1774
1779
  */
1775
1780
  const schemaRules = [
@@ -1789,6 +1794,10 @@ const schemaRules = [
1789
1794
  match: ({ schema }) => "const" in schema && schema.const !== void 0,
1790
1795
  convert: convertConst
1791
1796
  },
1797
+ {
1798
+ match: ({ schema }) => Array.isArray(schema.type) && schema.type.filter((t) => t !== "null").length > 1,
1799
+ convert: convertMultiType
1800
+ },
1792
1801
  {
1793
1802
  match: ({ schema, options }) => {
1794
1803
  if (!schema.format) return false;
@@ -1801,10 +1810,6 @@ const schemaRules = [
1801
1810
  match: ({ schema }) => isBinary(schema),
1802
1811
  convert: convertBinary
1803
1812
  },
1804
- {
1805
- match: ({ schema }) => Array.isArray(schema.type) && schema.type.filter((t) => t !== "null").length > 1,
1806
- convert: convertMultiType
1807
- },
1808
1813
  {
1809
1814
  match: ({ schema, type }) => !type && (schema.minLength !== void 0 || schema.maxLength !== void 0 || schema.pattern !== void 0),
1810
1815
  convert: convertString
@@ -2174,7 +2179,7 @@ function createSchemaParser(ctx) {
2174
2179
  name,
2175
2180
  nullable,
2176
2181
  defaultValue: schema.default === null && nullable ? void 0 : schema.default,
2177
- type: Array.isArray(schema.type) ? schema.type[0] : schema.type,
2182
+ type: Array.isArray(schema.type) ? schema.type.find((t) => t !== "null") ?? schema.type[0] : schema.type,
2178
2183
  rawOptions,
2179
2184
  options,
2180
2185
  parse: parseSchema,