@kubb/adapter-oas 5.0.6 → 5.2.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.d.ts +3 -3
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1269,7 +1269,7 @@ type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasReso
|
|
|
1269
1269
|
/**
|
|
1270
1270
|
* The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
|
|
1271
1271
|
*/
|
|
1272
|
-
declare const adapterOasName = "oas";
|
|
1272
|
+
export declare const adapterOasName = "oas";
|
|
1273
1273
|
/**
|
|
1274
1274
|
* Default Kubb adapter for OpenAPI 2.0, 3.0, and 3.1 specifications. Reads the
|
|
1275
1275
|
* spec from `input` (a file path, URL, inline content, or parsed object), validates
|
|
@@ -1297,7 +1297,7 @@ declare const adapterOasName = "oas";
|
|
|
1297
1297
|
* })
|
|
1298
1298
|
* ```
|
|
1299
1299
|
*/
|
|
1300
|
-
declare const adapterOas: (options?: AdapterOasOptions | undefined) => import("@kubb/core").Adapter<AdapterOas>;
|
|
1300
|
+
export declare const adapterOas: (options?: AdapterOasOptions | undefined) => import("@kubb/core").Adapter<AdapterOas>;
|
|
1301
1301
|
//#endregion
|
|
1302
|
-
export {
|
|
1302
|
+
export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
|
|
1303
1303
|
//# sourceMappingURL=index.d.ts.map
|
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
|