@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.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
@@ -96,6 +96,20 @@ const specialCasedFormats = /* @__PURE__ */ new Set([
|
|
|
96
96
|
"time"
|
|
97
97
|
]);
|
|
98
98
|
/**
|
|
99
|
+
* Formats that describe a number, whether they resolve through `formatMap` or through the
|
|
100
|
+
* `convertFormat` special cases. On a `type: 'string'` schema these do not make the value a
|
|
101
|
+
* number: gRPC-gateway and other ProtoJSON producers send 64-bit integers as JSON strings.
|
|
102
|
+
*
|
|
103
|
+
* @see https://protobuf.dev/programming-guides/json/#int64-strings
|
|
104
|
+
*/
|
|
105
|
+
const numericFormats = /* @__PURE__ */ new Set([
|
|
106
|
+
"int32",
|
|
107
|
+
"int64",
|
|
108
|
+
"uint64",
|
|
109
|
+
"float",
|
|
110
|
+
"double"
|
|
111
|
+
]);
|
|
112
|
+
/**
|
|
99
113
|
* Static map from OAS `format` strings to Kubb `SchemaType` values.
|
|
100
114
|
*
|
|
101
115
|
* Only formats whose AST type differs from the OAS `type` field appear here.
|
|
@@ -1363,13 +1377,15 @@ function convertConst({ schema, name, nullable, defaultValue }) {
|
|
|
1363
1377
|
* `format` rule's `match` has confirmed the format is handled (see `isHandledFormat`) and, for
|
|
1364
1378
|
* a date-ish format, that `dateType` is not `false`.
|
|
1365
1379
|
*/
|
|
1366
|
-
function convertFormat(
|
|
1380
|
+
function convertFormat(context) {
|
|
1381
|
+
const { schema, name, nullable, defaultValue, options, type } = context;
|
|
1367
1382
|
const ctx = {
|
|
1368
1383
|
schema,
|
|
1369
1384
|
name,
|
|
1370
1385
|
nullable,
|
|
1371
1386
|
defaultValue
|
|
1372
1387
|
};
|
|
1388
|
+
if (type === "string" && numericFormats.has(schema.format)) return convertString(context);
|
|
1373
1389
|
if (schema.format === "int64" || schema.format === "uint64") return createNode(ctx, {
|
|
1374
1390
|
type: options.integerType === "bigint" ? "bigint" : "integer",
|
|
1375
1391
|
primitive: "integer",
|