@kubb/adapter-oas 5.0.5 → 5.1.0
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 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -977,21 +977,31 @@ function getPrimitiveType(type) {
|
|
|
977
977
|
return "string";
|
|
978
978
|
}
|
|
979
979
|
/**
|
|
980
|
+
* Resolves the `dateType` option down to the value for one format. The scalar form of
|
|
981
|
+
* `dateType` applies to every format; the object form picks `dateTime`/`date`/`time`
|
|
982
|
+
* individually and defaults an omitted key to `'string'`.
|
|
983
|
+
*/
|
|
984
|
+
function resolveDateTypeValue(dateType, format) {
|
|
985
|
+
if (typeof dateType !== "object" || dateType === null) return dateType;
|
|
986
|
+
return dateType[format === "date-time" ? "dateTime" : format] ?? "string";
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
980
989
|
* Resolves the AST type descriptor for a date/time format, honoring the `dateType` option.
|
|
981
|
-
* Returns `null` when `
|
|
990
|
+
* Returns `null` when the resolved value is `false`, so the format falls through to `string`.
|
|
982
991
|
*/
|
|
983
992
|
function getDateType(options, format) {
|
|
984
|
-
|
|
993
|
+
const value = resolveDateTypeValue(options.dateType, format);
|
|
994
|
+
if (!value) return null;
|
|
985
995
|
if (format === "date-time") {
|
|
986
|
-
if (
|
|
996
|
+
if (value === "date") return {
|
|
987
997
|
type: "date",
|
|
988
998
|
representation: "date"
|
|
989
999
|
};
|
|
990
|
-
if (
|
|
1000
|
+
if (value === "stringOffset") return {
|
|
991
1001
|
type: "datetime",
|
|
992
1002
|
offset: true
|
|
993
1003
|
};
|
|
994
|
-
if (
|
|
1004
|
+
if (value === "stringLocal") return {
|
|
995
1005
|
type: "datetime",
|
|
996
1006
|
local: true
|
|
997
1007
|
};
|
|
@@ -1002,11 +1012,11 @@ function getDateType(options, format) {
|
|
|
1002
1012
|
}
|
|
1003
1013
|
if (format === "date") return {
|
|
1004
1014
|
type: "date",
|
|
1005
|
-
representation:
|
|
1015
|
+
representation: value === "date" ? "date" : "string"
|
|
1006
1016
|
};
|
|
1007
1017
|
return {
|
|
1008
1018
|
type: "time",
|
|
1009
|
-
representation:
|
|
1019
|
+
representation: value === "date" ? "date" : "string"
|
|
1010
1020
|
};
|
|
1011
1021
|
}
|
|
1012
1022
|
/**
|
|
@@ -1800,7 +1810,7 @@ const schemaRules = [
|
|
|
1800
1810
|
{
|
|
1801
1811
|
match: ({ schema, options }) => {
|
|
1802
1812
|
if (!schema.format) return false;
|
|
1803
|
-
if (schema.format === "date-time" || schema.format === "date" || schema.format === "time") return options.dateType !== false;
|
|
1813
|
+
if (schema.format === "date-time" || schema.format === "date" || schema.format === "time") return resolveDateTypeValue(options.dateType, schema.format) !== false;
|
|
1804
1814
|
return isHandledFormat(schema.format);
|
|
1805
1815
|
},
|
|
1806
1816
|
convert: convertFormat
|