@kubb/adapter-oas 5.4.2 → 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 +18 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1516,9 +1516,7 @@ function convertFormat(context) {
|
|
|
1516
1516
|
if (schema.format === "int64" || schema.format === "uint64") return createNode(ctx, {
|
|
1517
1517
|
type: options.integerType === "bigint" ? "bigint" : "integer",
|
|
1518
1518
|
primitive: "integer",
|
|
1519
|
-
|
|
1520
|
-
max: schema.maximum,
|
|
1521
|
-
...getExclusiveBounds(schema)
|
|
1519
|
+
...getNumericConstraints(schema)
|
|
1522
1520
|
});
|
|
1523
1521
|
if (schema.format === "date-time" || schema.format === "date" || schema.format === "time") {
|
|
1524
1522
|
const dateType = getDateType(options, schema.format);
|
|
@@ -1535,13 +1533,15 @@ function convertFormat(context) {
|
|
|
1535
1533
|
});
|
|
1536
1534
|
}
|
|
1537
1535
|
const specialType = getSchemaType(schema.format);
|
|
1536
|
+
const isNumeric = specialType === "number" || specialType === "integer" || specialType === "bigint";
|
|
1538
1537
|
return createNode(ctx, {
|
|
1539
|
-
primitive:
|
|
1538
|
+
primitive: isNumeric ? specialType : "string",
|
|
1540
1539
|
type: specialType,
|
|
1541
1540
|
...specialType === "url" || specialType === "uuid" || specialType === "email" ? {
|
|
1542
1541
|
min: schema.minLength,
|
|
1543
1542
|
max: schema.maxLength
|
|
1544
|
-
} : {}
|
|
1543
|
+
} : {},
|
|
1544
|
+
...isNumeric ? getNumericConstraints(schema) : {}
|
|
1545
1545
|
});
|
|
1546
1546
|
}
|
|
1547
1547
|
/**
|
|
@@ -1618,6 +1618,18 @@ function convertString({ schema, name, nullable, defaultValue }) {
|
|
|
1618
1618
|
});
|
|
1619
1619
|
}
|
|
1620
1620
|
/**
|
|
1621
|
+
* Reads the numeric constraints shared by every `number`, `integer` and `bigint` node. A `format`
|
|
1622
|
+
* such as `double` or `int32` only narrows the type, so formatted numbers keep these too.
|
|
1623
|
+
*/
|
|
1624
|
+
function getNumericConstraints(schema) {
|
|
1625
|
+
return {
|
|
1626
|
+
min: schema.minimum,
|
|
1627
|
+
max: schema.maximum,
|
|
1628
|
+
...getExclusiveBounds(schema),
|
|
1629
|
+
multipleOf: schema.multipleOf
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1621
1633
|
* Converts a `type: 'number'` or `type: 'integer'` schema.
|
|
1622
1634
|
*/
|
|
1623
1635
|
function convertNumeric({ schema, name, nullable, defaultValue }, type) {
|
|
@@ -1629,10 +1641,7 @@ function convertNumeric({ schema, name, nullable, defaultValue }, type) {
|
|
|
1629
1641
|
}, {
|
|
1630
1642
|
type,
|
|
1631
1643
|
primitive: type,
|
|
1632
|
-
|
|
1633
|
-
max: schema.maximum,
|
|
1634
|
-
...getExclusiveBounds(schema),
|
|
1635
|
-
multipleOf: schema.multipleOf
|
|
1644
|
+
...getNumericConstraints(schema)
|
|
1636
1645
|
});
|
|
1637
1646
|
}
|
|
1638
1647
|
/**
|