@kubb/adapter-oas 5.0.0-beta.105 → 5.0.0-beta.106
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 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -73,6 +73,20 @@ const specialCasedFormats = /* @__PURE__ */ new Set([
|
|
|
73
73
|
"time"
|
|
74
74
|
]);
|
|
75
75
|
/**
|
|
76
|
+
* Formats that describe a number, whether they resolve through `formatMap` or through the
|
|
77
|
+
* `convertFormat` special cases. On a `type: 'string'` schema these do not make the value a
|
|
78
|
+
* number: gRPC-gateway and other ProtoJSON producers send 64-bit integers as JSON strings.
|
|
79
|
+
*
|
|
80
|
+
* @see https://protobuf.dev/programming-guides/json/#int64-strings
|
|
81
|
+
*/
|
|
82
|
+
const numericFormats = /* @__PURE__ */ new Set([
|
|
83
|
+
"int32",
|
|
84
|
+
"int64",
|
|
85
|
+
"uint64",
|
|
86
|
+
"float",
|
|
87
|
+
"double"
|
|
88
|
+
]);
|
|
89
|
+
/**
|
|
76
90
|
* Static map from OAS `format` strings to Kubb `SchemaType` values.
|
|
77
91
|
*
|
|
78
92
|
* Only formats whose AST type differs from the OAS `type` field appear here.
|
|
@@ -1340,13 +1354,15 @@ function convertConst({ schema, name, nullable, defaultValue }) {
|
|
|
1340
1354
|
* `format` rule's `match` has confirmed the format is handled (see `isHandledFormat`) and, for
|
|
1341
1355
|
* a date-ish format, that `dateType` is not `false`.
|
|
1342
1356
|
*/
|
|
1343
|
-
function convertFormat(
|
|
1357
|
+
function convertFormat(context) {
|
|
1358
|
+
const { schema, name, nullable, defaultValue, options, type } = context;
|
|
1344
1359
|
const ctx = {
|
|
1345
1360
|
schema,
|
|
1346
1361
|
name,
|
|
1347
1362
|
nullable,
|
|
1348
1363
|
defaultValue
|
|
1349
1364
|
};
|
|
1365
|
+
if (type === "string" && numericFormats.has(schema.format)) return convertString(context);
|
|
1350
1366
|
if (schema.format === "int64" || schema.format === "uint64") return createNode(ctx, {
|
|
1351
1367
|
type: options.integerType === "bigint" ? "bigint" : "integer",
|
|
1352
1368
|
primitive: "integer",
|