@kubb/adapter-oas 5.4.3 → 5.4.5

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
@@ -1539,9 +1539,7 @@ function convertFormat(context) {
1539
1539
  if (schema.format === "int64" || schema.format === "uint64") return createNode(ctx, {
1540
1540
  type: options.integerType === "bigint" ? "bigint" : "integer",
1541
1541
  primitive: "integer",
1542
- min: schema.minimum,
1543
- max: schema.maximum,
1544
- ...getExclusiveBounds(schema)
1542
+ ...getNumericConstraints(schema)
1545
1543
  });
1546
1544
  if (schema.format === "date-time" || schema.format === "date" || schema.format === "time") {
1547
1545
  const dateType = getDateType(options, schema.format);
@@ -1558,13 +1556,15 @@ function convertFormat(context) {
1558
1556
  });
1559
1557
  }
1560
1558
  const specialType = getSchemaType(schema.format);
1559
+ const isNumeric = specialType === "number" || specialType === "integer" || specialType === "bigint";
1561
1560
  return createNode(ctx, {
1562
- primitive: specialType === "number" || specialType === "integer" || specialType === "bigint" ? specialType : "string",
1561
+ primitive: isNumeric ? specialType : "string",
1563
1562
  type: specialType,
1564
1563
  ...specialType === "url" || specialType === "uuid" || specialType === "email" ? {
1565
1564
  min: schema.minLength,
1566
1565
  max: schema.maxLength
1567
- } : {}
1566
+ } : {},
1567
+ ...isNumeric ? getNumericConstraints(schema) : {}
1568
1568
  });
1569
1569
  }
1570
1570
  /**
@@ -1641,6 +1641,18 @@ function convertString({ schema, name, nullable, defaultValue }) {
1641
1641
  });
1642
1642
  }
1643
1643
  /**
1644
+ * Reads the numeric constraints shared by every `number`, `integer` and `bigint` node. A `format`
1645
+ * such as `double` or `int32` only narrows the type, so formatted numbers keep these too.
1646
+ */
1647
+ function getNumericConstraints(schema) {
1648
+ return {
1649
+ min: schema.minimum,
1650
+ max: schema.maximum,
1651
+ ...getExclusiveBounds(schema),
1652
+ multipleOf: schema.multipleOf
1653
+ };
1654
+ }
1655
+ /**
1644
1656
  * Converts a `type: 'number'` or `type: 'integer'` schema.
1645
1657
  */
1646
1658
  function convertNumeric({ schema, name, nullable, defaultValue }, type) {
@@ -1652,10 +1664,7 @@ function convertNumeric({ schema, name, nullable, defaultValue }, type) {
1652
1664
  }, {
1653
1665
  type,
1654
1666
  primitive: type,
1655
- min: schema.minimum,
1656
- max: schema.maximum,
1657
- ...getExclusiveBounds(schema),
1658
- multipleOf: schema.multipleOf
1667
+ ...getNumericConstraints(schema)
1659
1668
  });
1660
1669
  }
1661
1670
  /**