@kubb/plugin-oas 3.0.0-alpha.10 → 3.0.0-alpha.12
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/{chunk-M347763D.js → chunk-2X5GZFQP.js} +14 -46
- package/dist/chunk-2X5GZFQP.js.map +1 -0
- package/dist/{chunk-IAUV3UKH.cjs → chunk-47SNBYWH.cjs} +102 -121
- package/dist/chunk-47SNBYWH.cjs.map +1 -0
- package/dist/{chunk-SZDO532A.js → chunk-4VKHSKYX.js} +7 -12
- package/dist/{chunk-SZDO532A.js.map → chunk-4VKHSKYX.js.map} +1 -1
- package/dist/{chunk-N7EEVJA6.js → chunk-4WUMV7QX.js} +9 -12
- package/dist/chunk-4WUMV7QX.js.map +1 -0
- package/dist/chunk-6AVEWDKE.cjs +8 -0
- package/dist/chunk-6AVEWDKE.cjs.map +1 -0
- package/dist/chunk-S6RFFHLW.cjs +38 -0
- package/dist/chunk-S6RFFHLW.cjs.map +1 -0
- package/dist/chunk-WN5S6RCU.js +6 -0
- package/dist/chunk-WN5S6RCU.js.map +1 -0
- package/dist/{chunk-NU4F7G47.cjs → chunk-XQPCA75E.cjs} +21 -20
- package/dist/chunk-XQPCA75E.cjs.map +1 -0
- package/dist/components.cjs +21 -12
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +4 -12
- package/dist/components.js.map +1 -1
- package/dist/hooks.cjs +30 -34
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +10 -22
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +92 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -32
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +39 -31
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +9 -24
- package/dist/utils.js.map +1 -1
- package/package.json +9 -9
- package/dist/chunk-75BIOXB7.cjs +0 -7
- package/dist/chunk-75BIOXB7.cjs.map +0 -1
- package/dist/chunk-IAUV3UKH.cjs.map +0 -1
- package/dist/chunk-M347763D.js.map +0 -1
- package/dist/chunk-N7EEVJA6.js.map +0 -1
- package/dist/chunk-NU4F7G47.cjs.map +0 -1
- package/dist/chunk-O76YQFZB.cjs +0 -35
- package/dist/chunk-O76YQFZB.cjs.map +0 -1
- package/dist/chunk-SQ64ESS4.js +0 -7
- package/dist/chunk-SQ64ESS4.js.map +0 -1
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkXQPCA75E_cjs = require('./chunk-XQPCA75E.cjs');
|
|
4
|
+
var core = require('@kubb/core');
|
|
5
|
+
var transformers = require('@kubb/core/transformers');
|
|
6
|
+
var utils = require('@kubb/core/utils');
|
|
7
|
+
var oas = require('@kubb/oas');
|
|
8
|
+
var remeda = require('remeda');
|
|
9
|
+
var react = require('@kubb/react');
|
|
3
10
|
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
4
12
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
|
|
13
|
+
var transformers__default = /*#__PURE__*/_interopDefault(transformers);
|
|
8
14
|
|
|
9
15
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
|
|
10
|
-
var require_react_production_min =
|
|
16
|
+
var require_react_production_min = chunkXQPCA75E_cjs.__commonJS({
|
|
11
17
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js"(exports) {
|
|
12
|
-
|
|
13
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
18
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
14
19
|
var l = Symbol.for("react.element");
|
|
15
20
|
var n = Symbol.for("react.portal");
|
|
16
21
|
var p = Symbol.for("react.fragment");
|
|
@@ -281,13 +286,11 @@ var require_react_production_min = _chunkNU4F7G47cjs.__commonJS.call(void 0, {
|
|
|
281
286
|
});
|
|
282
287
|
|
|
283
288
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js
|
|
284
|
-
var require_react_development =
|
|
289
|
+
var require_react_development = chunkXQPCA75E_cjs.__commonJS({
|
|
285
290
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js"(exports, module) {
|
|
286
|
-
|
|
287
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
291
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
288
292
|
if (process.env.NODE_ENV !== "production") {
|
|
289
293
|
(function() {
|
|
290
|
-
"use strict";
|
|
291
294
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
292
295
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
293
296
|
}
|
|
@@ -2156,10 +2159,9 @@ var require_react_development = _chunkNU4F7G47cjs.__commonJS.call(void 0, {
|
|
|
2156
2159
|
});
|
|
2157
2160
|
|
|
2158
2161
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
|
|
2159
|
-
var require_react =
|
|
2162
|
+
var require_react = chunkXQPCA75E_cjs.__commonJS({
|
|
2160
2163
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"(exports, module) {
|
|
2161
|
-
|
|
2162
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
2164
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
2163
2165
|
if (process.env.NODE_ENV === "production") {
|
|
2164
2166
|
module.exports = require_react_production_min();
|
|
2165
2167
|
} else {
|
|
@@ -2169,10 +2171,9 @@ var require_react = _chunkNU4F7G47cjs.__commonJS.call(void 0, {
|
|
|
2169
2171
|
});
|
|
2170
2172
|
|
|
2171
2173
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js
|
|
2172
|
-
var require_react_jsx_runtime_production_min =
|
|
2174
|
+
var require_react_jsx_runtime_production_min = chunkXQPCA75E_cjs.__commonJS({
|
|
2173
2175
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js"(exports) {
|
|
2174
|
-
|
|
2175
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
2176
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
2176
2177
|
var f = require_react();
|
|
2177
2178
|
var k = Symbol.for("react.element");
|
|
2178
2179
|
var l = Symbol.for("react.fragment");
|
|
@@ -2195,13 +2196,11 @@ var require_react_jsx_runtime_production_min = _chunkNU4F7G47cjs.__commonJS.call
|
|
|
2195
2196
|
});
|
|
2196
2197
|
|
|
2197
2198
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.js
|
|
2198
|
-
var require_react_jsx_runtime_development =
|
|
2199
|
+
var require_react_jsx_runtime_development = chunkXQPCA75E_cjs.__commonJS({
|
|
2199
2200
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.js"(exports) {
|
|
2200
|
-
|
|
2201
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
2201
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
2202
2202
|
if (process.env.NODE_ENV !== "production") {
|
|
2203
2203
|
(function() {
|
|
2204
|
-
"use strict";
|
|
2205
2204
|
var React = require_react();
|
|
2206
2205
|
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
|
2207
2206
|
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
@@ -2874,11 +2873,6 @@ var require_react_jsx_runtime_development = _chunkNU4F7G47cjs.__commonJS.call(vo
|
|
|
2874
2873
|
}
|
|
2875
2874
|
function getSourceInfoErrorAddendum(source) {
|
|
2876
2875
|
{
|
|
2877
|
-
if (source !== void 0) {
|
|
2878
|
-
var fileName = source.fileName.replace(/^.*[\\\/]/, "");
|
|
2879
|
-
var lineNumber = source.lineNumber;
|
|
2880
|
-
return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
|
|
2881
|
-
}
|
|
2882
2876
|
return "";
|
|
2883
2877
|
}
|
|
2884
2878
|
}
|
|
@@ -3004,7 +2998,7 @@ var require_react_jsx_runtime_development = _chunkNU4F7G47cjs.__commonJS.call(vo
|
|
|
3004
2998
|
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
|
3005
2999
|
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
|
3006
3000
|
}
|
|
3007
|
-
var sourceInfo = getSourceInfoErrorAddendum(
|
|
3001
|
+
var sourceInfo = getSourceInfoErrorAddendum();
|
|
3008
3002
|
if (sourceInfo) {
|
|
3009
3003
|
info += sourceInfo;
|
|
3010
3004
|
} else {
|
|
@@ -3089,10 +3083,9 @@ var require_react_jsx_runtime_development = _chunkNU4F7G47cjs.__commonJS.call(vo
|
|
|
3089
3083
|
});
|
|
3090
3084
|
|
|
3091
3085
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js
|
|
3092
|
-
var require_jsx_runtime =
|
|
3086
|
+
var require_jsx_runtime = chunkXQPCA75E_cjs.__commonJS({
|
|
3093
3087
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js"(exports, module) {
|
|
3094
|
-
|
|
3095
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
3088
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
3096
3089
|
if (process.env.NODE_ENV === "production") {
|
|
3097
3090
|
module.exports = require_react_jsx_runtime_production_min();
|
|
3098
3091
|
} else {
|
|
@@ -3102,7 +3095,7 @@ var require_jsx_runtime = _chunkNU4F7G47cjs.__commonJS.call(void 0, {
|
|
|
3102
3095
|
});
|
|
3103
3096
|
|
|
3104
3097
|
// src/SchemaMapper.ts
|
|
3105
|
-
|
|
3098
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
3106
3099
|
var schemaKeywords = {
|
|
3107
3100
|
any: "any",
|
|
3108
3101
|
strict: "strict",
|
|
@@ -3154,15 +3147,10 @@ function isKeyword(meta, keyword) {
|
|
|
3154
3147
|
}
|
|
3155
3148
|
|
|
3156
3149
|
// src/SchemaGenerator.ts
|
|
3157
|
-
|
|
3158
|
-
var
|
|
3159
|
-
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
3160
|
-
var _utils = require('@kubb/core/utils');
|
|
3161
|
-
var _oas = require('@kubb/oas');
|
|
3162
|
-
var _remeda = require('remeda');
|
|
3163
|
-
var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerator {constructor(...args2) { super(...args2); _class.prototype.__init.call(this); }
|
|
3150
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
3151
|
+
var SchemaGenerator = class _SchemaGenerator extends core.BaseGenerator {
|
|
3164
3152
|
// Collect the types of all referenced schemas, so we can export them later
|
|
3165
|
-
|
|
3153
|
+
refs = {};
|
|
3166
3154
|
// Keep track of already used type aliases
|
|
3167
3155
|
#usedAliasNames = {};
|
|
3168
3156
|
/**
|
|
@@ -3173,8 +3161,8 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3173
3161
|
parse(props) {
|
|
3174
3162
|
const options = this.#getOptions(props);
|
|
3175
3163
|
const defaultSchemas = this.#parseSchemaObject(props);
|
|
3176
|
-
const schemas =
|
|
3177
|
-
return
|
|
3164
|
+
const schemas = options.transformers?.schema?.(props, defaultSchemas) || defaultSchemas || [];
|
|
3165
|
+
return remeda.uniqueWith(schemas, remeda.isDeepEqual);
|
|
3178
3166
|
}
|
|
3179
3167
|
deepSearch(tree, keyword) {
|
|
3180
3168
|
return _SchemaGenerator.deepSearch(tree, keyword);
|
|
@@ -3184,16 +3172,16 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3184
3172
|
}
|
|
3185
3173
|
static deepSearch(tree, keyword) {
|
|
3186
3174
|
const foundItems = [];
|
|
3187
|
-
|
|
3175
|
+
tree?.forEach((schema) => {
|
|
3188
3176
|
if (schema.keyword === keyword) {
|
|
3189
3177
|
foundItems.push(schema);
|
|
3190
3178
|
}
|
|
3191
3179
|
if (schema.keyword === schemaKeywords.object) {
|
|
3192
3180
|
const subItem = schema;
|
|
3193
|
-
Object.values(
|
|
3181
|
+
Object.values(subItem.args?.properties || {}).forEach((entrySchema) => {
|
|
3194
3182
|
foundItems.push(..._SchemaGenerator.deepSearch(entrySchema, keyword));
|
|
3195
3183
|
});
|
|
3196
|
-
Object.values(
|
|
3184
|
+
Object.values(subItem.args?.additionalProperties || {}).forEach((entrySchema) => {
|
|
3197
3185
|
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
3198
3186
|
});
|
|
3199
3187
|
}
|
|
@@ -3221,34 +3209,34 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3221
3209
|
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
3222
3210
|
});
|
|
3223
3211
|
}
|
|
3224
|
-
})
|
|
3212
|
+
});
|
|
3225
3213
|
return foundItems;
|
|
3226
3214
|
}
|
|
3227
3215
|
static findInObject(tree, keyword) {
|
|
3228
3216
|
let foundItem = void 0;
|
|
3229
|
-
|
|
3217
|
+
tree?.forEach((schema) => {
|
|
3230
3218
|
if (!foundItem && schema.keyword === keyword) {
|
|
3231
3219
|
foundItem = schema;
|
|
3232
3220
|
}
|
|
3233
3221
|
if (schema.keyword === schemaKeywords.object) {
|
|
3234
3222
|
const subItem = schema;
|
|
3235
|
-
Object.values(
|
|
3223
|
+
Object.values(subItem.args?.properties || {}).forEach((entrySchema) => {
|
|
3236
3224
|
if (!foundItem) {
|
|
3237
3225
|
foundItem = _SchemaGenerator.find(entrySchema, keyword);
|
|
3238
3226
|
}
|
|
3239
3227
|
});
|
|
3240
|
-
Object.values(
|
|
3228
|
+
Object.values(subItem.args?.additionalProperties || {}).forEach((entrySchema) => {
|
|
3241
3229
|
if (!foundItem) {
|
|
3242
3230
|
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
3243
3231
|
}
|
|
3244
3232
|
});
|
|
3245
3233
|
}
|
|
3246
|
-
})
|
|
3234
|
+
});
|
|
3247
3235
|
return foundItem;
|
|
3248
3236
|
}
|
|
3249
3237
|
static find(tree, keyword) {
|
|
3250
3238
|
let foundItem = void 0;
|
|
3251
|
-
|
|
3239
|
+
tree?.forEach((schema) => {
|
|
3252
3240
|
if (!foundItem && schema.keyword === keyword) {
|
|
3253
3241
|
foundItem = schema;
|
|
3254
3242
|
}
|
|
@@ -3284,7 +3272,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3284
3272
|
}
|
|
3285
3273
|
});
|
|
3286
3274
|
}
|
|
3287
|
-
})
|
|
3275
|
+
});
|
|
3288
3276
|
return foundItem;
|
|
3289
3277
|
}
|
|
3290
3278
|
#getUsedEnumNames(props) {
|
|
@@ -3295,12 +3283,12 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3295
3283
|
const { override = [] } = this.context;
|
|
3296
3284
|
return {
|
|
3297
3285
|
...this.options,
|
|
3298
|
-
...
|
|
3286
|
+
...override.find(({ pattern, type }) => {
|
|
3299
3287
|
if (name && type === "schemaName") {
|
|
3300
3288
|
return !!name.match(pattern);
|
|
3301
3289
|
}
|
|
3302
3290
|
return false;
|
|
3303
|
-
})
|
|
3291
|
+
})?.options || {}
|
|
3304
3292
|
};
|
|
3305
3293
|
}
|
|
3306
3294
|
#getUnknownReturn(props) {
|
|
@@ -3314,14 +3302,14 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3314
3302
|
* Recursively creates a type literal with the given props.
|
|
3315
3303
|
*/
|
|
3316
3304
|
#parseProperties({ schema, name }) {
|
|
3317
|
-
const properties =
|
|
3318
|
-
const additionalProperties =
|
|
3319
|
-
const required =
|
|
3305
|
+
const properties = schema?.properties || {};
|
|
3306
|
+
const additionalProperties = schema?.additionalProperties;
|
|
3307
|
+
const required = schema?.required;
|
|
3320
3308
|
const propertiesSchemas = Object.keys(properties).map((propertyName) => {
|
|
3321
3309
|
const validationFunctions = [];
|
|
3322
3310
|
const propertySchema = properties[propertyName];
|
|
3323
|
-
const isRequired = Array.isArray(required) ?
|
|
3324
|
-
const nullable =
|
|
3311
|
+
const isRequired = Array.isArray(required) ? required?.includes(propertyName) : !!required;
|
|
3312
|
+
const nullable = propertySchema.nullable ?? propertySchema["x-nullable"] ?? false;
|
|
3325
3313
|
validationFunctions.push(...this.parse({ schema: propertySchema, name: propertyName, parentName: name }));
|
|
3326
3314
|
validationFunctions.push({
|
|
3327
3315
|
keyword: schemaKeywords.name,
|
|
@@ -3356,7 +3344,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3356
3344
|
#getRefAlias(obj) {
|
|
3357
3345
|
const { $ref } = obj;
|
|
3358
3346
|
let ref = this.refs[$ref];
|
|
3359
|
-
const originalName =
|
|
3347
|
+
const originalName = utils.getUniqueName($ref.replace(/.+\//, ""), this.#usedAliasNames);
|
|
3360
3348
|
const propertyName = this.context.pluginManager.resolveName({
|
|
3361
3349
|
name: originalName,
|
|
3362
3350
|
pluginKey: this.context.plugin.key,
|
|
@@ -3388,12 +3376,12 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3388
3376
|
return [
|
|
3389
3377
|
{
|
|
3390
3378
|
keyword: schemaKeywords.ref,
|
|
3391
|
-
args: { name: ref.propertyName, path:
|
|
3379
|
+
args: { name: ref.propertyName, path: ref?.path }
|
|
3392
3380
|
}
|
|
3393
3381
|
];
|
|
3394
3382
|
}
|
|
3395
3383
|
#getParsedSchemaObject(schema) {
|
|
3396
|
-
const parsedSchema =
|
|
3384
|
+
const parsedSchema = chunkXQPCA75E_cjs.getSchemaFactory(this.context.oas)(schema);
|
|
3397
3385
|
return parsedSchema;
|
|
3398
3386
|
}
|
|
3399
3387
|
/**
|
|
@@ -3416,19 +3404,19 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3416
3404
|
}
|
|
3417
3405
|
}
|
|
3418
3406
|
];
|
|
3419
|
-
const min =
|
|
3420
|
-
const max =
|
|
3421
|
-
const nullable =
|
|
3407
|
+
const min = schema.minimum ?? schema.minLength ?? schema.minItems ?? void 0;
|
|
3408
|
+
const max = schema.maximum ?? schema.maxLength ?? schema.maxItems ?? void 0;
|
|
3409
|
+
const nullable = schema.nullable ?? schema["x-nullable"] ?? false;
|
|
3422
3410
|
if (schema.default !== void 0 && !Array.isArray(schema.default)) {
|
|
3423
3411
|
if (typeof schema.default === "string") {
|
|
3424
3412
|
baseItems.push({
|
|
3425
3413
|
keyword: schemaKeywords.default,
|
|
3426
|
-
args:
|
|
3414
|
+
args: transformers__default.default.stringify(schema.default)
|
|
3427
3415
|
});
|
|
3428
3416
|
} else if (typeof schema.default === "boolean") {
|
|
3429
3417
|
baseItems.push({
|
|
3430
3418
|
keyword: schemaKeywords.default,
|
|
3431
|
-
args:
|
|
3419
|
+
args: schema.default ?? false
|
|
3432
3420
|
});
|
|
3433
3421
|
} else {
|
|
3434
3422
|
baseItems.push({
|
|
@@ -3467,7 +3455,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3467
3455
|
if (schema.readOnly) {
|
|
3468
3456
|
baseItems.push({ keyword: schemaKeywords.readOnly });
|
|
3469
3457
|
}
|
|
3470
|
-
if (
|
|
3458
|
+
if (oas.isReference(schema)) {
|
|
3471
3459
|
return [
|
|
3472
3460
|
...this.#getRefAlias(schema),
|
|
3473
3461
|
nullable && { keyword: schemaKeywords.nullable },
|
|
@@ -3543,7 +3531,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3543
3531
|
return [and, ...baseItems];
|
|
3544
3532
|
}
|
|
3545
3533
|
if (schema.enum) {
|
|
3546
|
-
const enumName =
|
|
3534
|
+
const enumName = utils.getUniqueName(transformers.pascalCase([parentName, name, options.enumSuffix].join(" ")), this.#getUsedEnumNames({ schema, name }));
|
|
3547
3535
|
const typeName = this.context.pluginManager.resolveName({
|
|
3548
3536
|
name: enumName,
|
|
3549
3537
|
pluginKey: this.context.plugin.key,
|
|
@@ -3563,9 +3551,9 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3563
3551
|
typeName,
|
|
3564
3552
|
asConst: false,
|
|
3565
3553
|
items: [...new Set(schema[extensionKey])].map((name2, index) => ({
|
|
3566
|
-
name:
|
|
3567
|
-
value:
|
|
3568
|
-
format:
|
|
3554
|
+
name: transformers__default.default.stringify(name2),
|
|
3555
|
+
value: schema.enum?.[index],
|
|
3556
|
+
format: remeda.isNumber(schema.enum?.[index]) ? "number" : "string"
|
|
3569
3557
|
}))
|
|
3570
3558
|
}
|
|
3571
3559
|
},
|
|
@@ -3575,7 +3563,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3575
3563
|
];
|
|
3576
3564
|
});
|
|
3577
3565
|
if (schema.type === "number" || schema.type === "integer") {
|
|
3578
|
-
const enumNames =
|
|
3566
|
+
const enumNames = extensionEnums[0]?.find((item) => isKeyword(item, schemaKeywords.enum));
|
|
3579
3567
|
return [
|
|
3580
3568
|
{
|
|
3581
3569
|
keyword: schemaKeywords.enum,
|
|
@@ -3583,7 +3571,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3583
3571
|
name: enumName,
|
|
3584
3572
|
typeName,
|
|
3585
3573
|
asConst: true,
|
|
3586
|
-
items:
|
|
3574
|
+
items: enumNames?.args?.items ? [...new Set(enumNames.args.items)].map(({ name: name2, value }) => ({
|
|
3587
3575
|
name: name2,
|
|
3588
3576
|
value,
|
|
3589
3577
|
format: "number"
|
|
@@ -3610,9 +3598,9 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3610
3598
|
typeName,
|
|
3611
3599
|
asConst: false,
|
|
3612
3600
|
items: [...new Set(filteredValues)].map((value) => ({
|
|
3613
|
-
name:
|
|
3601
|
+
name: transformers__default.default.stringify(value),
|
|
3614
3602
|
value,
|
|
3615
|
-
format:
|
|
3603
|
+
format: remeda.isNumber(value) ? "number" : "string"
|
|
3616
3604
|
}))
|
|
3617
3605
|
}
|
|
3618
3606
|
},
|
|
@@ -3621,8 +3609,8 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3621
3609
|
}
|
|
3622
3610
|
if ("prefixItems" in schema) {
|
|
3623
3611
|
const prefixItems = schema.prefixItems;
|
|
3624
|
-
const min2 =
|
|
3625
|
-
const max2 =
|
|
3612
|
+
const min2 = schema.minimum ?? schema.minLength ?? schema.minItems ?? void 0;
|
|
3613
|
+
const max2 = schema.maximum ?? schema.maxLength ?? schema.maxItems ?? void 0;
|
|
3626
3614
|
return [
|
|
3627
3615
|
{
|
|
3628
3616
|
keyword: schemaKeywords.tuple,
|
|
@@ -3711,13 +3699,11 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3711
3699
|
case "idn-hostname":
|
|
3712
3700
|
baseItems.unshift({ keyword: schemaKeywords.url });
|
|
3713
3701
|
break;
|
|
3714
|
-
default:
|
|
3715
|
-
break;
|
|
3716
3702
|
}
|
|
3717
3703
|
}
|
|
3718
3704
|
if ("items" in schema || schema.type === "array") {
|
|
3719
|
-
const min2 =
|
|
3720
|
-
const max2 =
|
|
3705
|
+
const min2 = schema.minimum ?? schema.minLength ?? schema.minItems ?? void 0;
|
|
3706
|
+
const max2 = schema.maximum ?? schema.maxLength ?? schema.maxItems ?? void 0;
|
|
3721
3707
|
const items = this.parse({ schema: "items" in schema ? schema.items : [], name, parentName });
|
|
3722
3708
|
return [
|
|
3723
3709
|
{
|
|
@@ -3758,7 +3744,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3758
3744
|
}
|
|
3759
3745
|
async build(...generators) {
|
|
3760
3746
|
const { oas, contentType, include } = this.context;
|
|
3761
|
-
const schemas =
|
|
3747
|
+
const schemas = chunkXQPCA75E_cjs.getSchemas({ oas, contentType, includes: include });
|
|
3762
3748
|
const promises = Object.entries(schemas).reduce((acc, [name, schema]) => {
|
|
3763
3749
|
const options = this.#getOptions({ name });
|
|
3764
3750
|
const promiseOperation = this.schema.call(this, name, schema, {
|
|
@@ -3768,8 +3754,8 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3768
3754
|
if (promiseOperation) {
|
|
3769
3755
|
acc.push(promiseOperation);
|
|
3770
3756
|
}
|
|
3771
|
-
|
|
3772
|
-
const promise =
|
|
3757
|
+
generators?.forEach((generator) => {
|
|
3758
|
+
const promise = generator.schema?.({
|
|
3773
3759
|
instance: this,
|
|
3774
3760
|
name,
|
|
3775
3761
|
schema,
|
|
@@ -3777,11 +3763,11 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3777
3763
|
...this.options,
|
|
3778
3764
|
...options
|
|
3779
3765
|
}
|
|
3780
|
-
})
|
|
3766
|
+
});
|
|
3781
3767
|
if (promise) {
|
|
3782
3768
|
acc.push(promise);
|
|
3783
3769
|
}
|
|
3784
|
-
})
|
|
3770
|
+
});
|
|
3785
3771
|
return acc;
|
|
3786
3772
|
}, []);
|
|
3787
3773
|
const files = await Promise.all(promises);
|
|
@@ -3793,27 +3779,24 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerat
|
|
|
3793
3779
|
async schema(name, object, options) {
|
|
3794
3780
|
return [];
|
|
3795
3781
|
}
|
|
3796
|
-
}
|
|
3782
|
+
};
|
|
3797
3783
|
|
|
3798
3784
|
// src/components/Operation.tsx
|
|
3799
|
-
|
|
3800
|
-
var import_jsx_runtime =
|
|
3801
|
-
var
|
|
3802
|
-
var OperationContext = _react.createContext.call(void 0, {});
|
|
3785
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
3786
|
+
var import_jsx_runtime = chunkXQPCA75E_cjs.__toESM(require_jsx_runtime(), 1);
|
|
3787
|
+
var OperationContext = react.createContext({});
|
|
3803
3788
|
function Operation({ operation, children }) {
|
|
3804
3789
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OperationContext.Provider, { value: { operation }, children });
|
|
3805
3790
|
}
|
|
3806
3791
|
Operation.Context = OperationContext;
|
|
3807
3792
|
|
|
3808
3793
|
// src/hooks/useSchema.ts
|
|
3809
|
-
|
|
3810
|
-
|
|
3794
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
3811
3795
|
|
|
3812
3796
|
// src/components/Schema.tsx
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
var
|
|
3816
|
-
var SchemaContext = _react.createContext.call(void 0, {
|
|
3797
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
3798
|
+
var import_jsx_runtime2 = chunkXQPCA75E_cjs.__toESM(require_jsx_runtime(), 1);
|
|
3799
|
+
var SchemaContext = react.createContext({
|
|
3817
3800
|
name: "unknown",
|
|
3818
3801
|
tree: []
|
|
3819
3802
|
});
|
|
@@ -3821,7 +3804,7 @@ function Schema({ name, value, tree = [], children }) {
|
|
|
3821
3804
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaContext.Provider, { value: { name, schema: value, tree }, children });
|
|
3822
3805
|
}
|
|
3823
3806
|
Schema.File = function({ output, isTypeOnly, children }) {
|
|
3824
|
-
const { plugin, pluginManager, mode } =
|
|
3807
|
+
const { plugin, pluginManager, mode } = react.useApp();
|
|
3825
3808
|
const { name } = useSchema();
|
|
3826
3809
|
if (mode === "single") {
|
|
3827
3810
|
const baseName2 = `${pluginManager.resolveName({
|
|
@@ -3837,7 +3820,7 @@ Schema.File = function({ output, isTypeOnly, children }) {
|
|
|
3837
3820
|
return null;
|
|
3838
3821
|
}
|
|
3839
3822
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3840
|
-
|
|
3823
|
+
react.File,
|
|
3841
3824
|
{
|
|
3842
3825
|
baseName: baseName2,
|
|
3843
3826
|
path: resolvedPath2,
|
|
@@ -3861,7 +3844,7 @@ Schema.File = function({ output, isTypeOnly, children }) {
|
|
|
3861
3844
|
return null;
|
|
3862
3845
|
}
|
|
3863
3846
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
3864
|
-
|
|
3847
|
+
react.File,
|
|
3865
3848
|
{
|
|
3866
3849
|
baseName,
|
|
3867
3850
|
path: resolvedPath,
|
|
@@ -3877,45 +3860,33 @@ Schema.File = function({ output, isTypeOnly, children }) {
|
|
|
3877
3860
|
};
|
|
3878
3861
|
Schema.Imports = ({ isTypeOnly }) => {
|
|
3879
3862
|
const { tree } = useSchema();
|
|
3880
|
-
const { path: root } =
|
|
3863
|
+
const { path: root } = react.useFile();
|
|
3881
3864
|
const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref);
|
|
3882
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children:
|
|
3865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: refs?.map((item, i) => {
|
|
3883
3866
|
if (!item.args.path) {
|
|
3884
3867
|
return void 0;
|
|
3885
3868
|
}
|
|
3886
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3887
|
-
})
|
|
3869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(react.File.Import, { root, name: [item.args.name], path: item.args.path, isTypeOnly }, i);
|
|
3870
|
+
}).filter(Boolean) });
|
|
3888
3871
|
};
|
|
3889
3872
|
Schema.Context = SchemaContext;
|
|
3890
3873
|
|
|
3891
3874
|
// src/hooks/useSchema.ts
|
|
3892
3875
|
function useSchema() {
|
|
3893
|
-
const props =
|
|
3876
|
+
const props = react.useContext(Schema.Context);
|
|
3894
3877
|
return props;
|
|
3895
3878
|
}
|
|
3896
3879
|
|
|
3897
3880
|
// src/components/Oas.tsx
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
var
|
|
3901
|
-
var OasContext = _react.createContext.call(void 0, {});
|
|
3881
|
+
chunkXQPCA75E_cjs.init_cjs_shims();
|
|
3882
|
+
var import_jsx_runtime3 = chunkXQPCA75E_cjs.__toESM(require_jsx_runtime(), 1);
|
|
3883
|
+
var OasContext = react.createContext({});
|
|
3902
3884
|
function Oas({ oas, children, operations, generator }) {
|
|
3903
3885
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(OasContext.Provider, { value: { oas, generator, operations }, children });
|
|
3904
3886
|
}
|
|
3905
3887
|
Oas.Context = OasContext;
|
|
3906
3888
|
Oas.Operation = Operation;
|
|
3907
3889
|
Oas.Schema = Schema;
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
exports.schemaKeywords = schemaKeywords; exports.isKeyword = isKeyword; exports.SchemaGenerator = SchemaGenerator; exports.require_jsx_runtime = require_jsx_runtime; exports.Operation = Operation; exports.useSchema = useSchema; exports.Schema = Schema; exports.Oas = Oas;
|
|
3919
3890
|
/*! Bundled license information:
|
|
3920
3891
|
|
|
3921
3892
|
react/cjs/react.production.min.js:
|
|
@@ -3962,4 +3933,14 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
3962
3933
|
* LICENSE file in the root directory of this source tree.
|
|
3963
3934
|
*)
|
|
3964
3935
|
*/
|
|
3965
|
-
|
|
3936
|
+
|
|
3937
|
+
exports.Oas = Oas;
|
|
3938
|
+
exports.Operation = Operation;
|
|
3939
|
+
exports.Schema = Schema;
|
|
3940
|
+
exports.SchemaGenerator = SchemaGenerator;
|
|
3941
|
+
exports.isKeyword = isKeyword;
|
|
3942
|
+
exports.require_jsx_runtime = require_jsx_runtime;
|
|
3943
|
+
exports.schemaKeywords = schemaKeywords;
|
|
3944
|
+
exports.useSchema = useSchema;
|
|
3945
|
+
//# sourceMappingURL=chunk-47SNBYWH.cjs.map
|
|
3946
|
+
//# sourceMappingURL=chunk-47SNBYWH.cjs.map
|