@moostjs/swagger 0.5.29 → 0.5.31
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 +20 -20
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +12 -11
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//#region rolldown:runtime
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -198,14 +197,14 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
198
197
|
}, {
|
|
199
198
|
type: paramMeta.type,
|
|
200
199
|
additionalMeta: paramMeta
|
|
201
|
-
},
|
|
200
|
+
}, void 0, logger);
|
|
202
201
|
parsed = myParseZod(zodType);
|
|
203
202
|
schema = getSwaggerSchema(parsed, true);
|
|
204
203
|
}
|
|
205
204
|
addParam({
|
|
206
205
|
name: paramName,
|
|
207
206
|
in: "path",
|
|
208
|
-
description: paramMeta ? paramMeta.description :
|
|
207
|
+
description: paramMeta ? paramMeta.description : void 0,
|
|
209
208
|
required: !paramMeta.optional && !parsed?.$optional,
|
|
210
209
|
schema: schema || { type: "string" }
|
|
211
210
|
});
|
|
@@ -220,7 +219,7 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
220
219
|
}, {
|
|
221
220
|
type: paramMeta.type,
|
|
222
221
|
additionalMeta: paramMeta
|
|
223
|
-
},
|
|
222
|
+
}, void 0, logger);
|
|
224
223
|
const parsed = myParseZod(zodType);
|
|
225
224
|
const schema = getSwaggerSchema(parsed, true);
|
|
226
225
|
if (paramMeta.paramSource === "QUERY_ITEM") endpointSpec.parameters.push({
|
|
@@ -252,7 +251,7 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
252
251
|
}, {
|
|
253
252
|
type: paramMeta.type,
|
|
254
253
|
additionalMeta: paramMeta
|
|
255
|
-
},
|
|
254
|
+
}, void 0, logger);
|
|
256
255
|
const parsed = myParseZod(zodType);
|
|
257
256
|
let contentType = "";
|
|
258
257
|
switch (parsed.$type) {
|
|
@@ -284,7 +283,7 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
284
283
|
const globalSchemas = {};
|
|
285
284
|
function getSwaggerSchema(parsed, forParam) {
|
|
286
285
|
const zodType = parsed.$ref;
|
|
287
|
-
const meta = zodType.__type_ref ? getSwaggerMate().read(zodType.__type_ref) :
|
|
286
|
+
const meta = zodType.__type_ref ? getSwaggerMate().read(zodType.__type_ref) : void 0;
|
|
288
287
|
if (!forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) return { $ref: `#/components/schemas/${zodType.__type_ref.name}` };
|
|
289
288
|
if (forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) return globalSchemas[zodType.__type_ref.name];
|
|
290
289
|
const schema = {};
|
|
@@ -358,7 +357,7 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
358
357
|
schema.type = "null";
|
|
359
358
|
break;
|
|
360
359
|
}
|
|
361
|
-
default: return
|
|
360
|
+
default: return void 0;
|
|
362
361
|
}
|
|
363
362
|
else switch (parsed.$type) {
|
|
364
363
|
case "ZodString": {
|
|
@@ -403,11 +402,11 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
403
402
|
case "ZodUnknown":
|
|
404
403
|
case "ZodNever":
|
|
405
404
|
case "ZodVoid":
|
|
406
|
-
case "ZodNaN": return
|
|
405
|
+
case "ZodNaN": return void 0;
|
|
407
406
|
case "ZodArray": {
|
|
408
407
|
schema.type = "array";
|
|
409
|
-
schema.minItems = parsed.$checks?.minLength ||
|
|
410
|
-
schema.maxItems = parsed.$checks?.maxLength ||
|
|
408
|
+
schema.minItems = parsed.$checks?.minLength || void 0;
|
|
409
|
+
schema.maxItems = parsed.$checks?.maxLength || void 0;
|
|
411
410
|
schema.items = getSwaggerSchema(parsed.$inner);
|
|
412
411
|
break;
|
|
413
412
|
}
|
|
@@ -436,7 +435,7 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
436
435
|
case "ZodSet": {
|
|
437
436
|
schema.type = "object";
|
|
438
437
|
schema.properties = {};
|
|
439
|
-
schema.additionalProperties = parsed.$type === "ZodRecord" ? {} :
|
|
438
|
+
schema.additionalProperties = parsed.$type === "ZodRecord" ? {} : void 0;
|
|
440
439
|
break;
|
|
441
440
|
}
|
|
442
441
|
case "ZodUnion":
|
|
@@ -449,6 +448,7 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
449
448
|
break;
|
|
450
449
|
}
|
|
451
450
|
case "ZodLazy": return getSwaggerSchema(parsed.$get());
|
|
451
|
+
default: return void 0;
|
|
452
452
|
}
|
|
453
453
|
if (parsed.$nullable) schema.nullable = parsed.$nullable;
|
|
454
454
|
if (parsed.$ref._def.description) schema.description = parsed.$ref._def.description;
|
|
@@ -525,7 +525,7 @@ var SwaggerController = class {
|
|
|
525
525
|
"processCors"() {
|
|
526
526
|
if (this.opts.cors) {
|
|
527
527
|
const { enableCors } = (0, __wooksjs_event_http.useSetHeaders)();
|
|
528
|
-
enableCors(this.opts.cors === true ?
|
|
528
|
+
enableCors(this.opts.cors === true ? void 0 : this.opts.cors);
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
531
|
"serveIndex"(url, location, status) {
|
|
@@ -658,11 +658,11 @@ Object.defineProperty(exports, 'SwaggerController', {
|
|
|
658
658
|
return SwaggerController;
|
|
659
659
|
}
|
|
660
660
|
});
|
|
661
|
-
exports.SwaggerDescription = SwaggerDescription
|
|
662
|
-
exports.SwaggerExample = SwaggerExample
|
|
663
|
-
exports.SwaggerExclude = SwaggerExclude
|
|
664
|
-
exports.SwaggerParam = SwaggerParam
|
|
665
|
-
exports.SwaggerRequestBody = SwaggerRequestBody
|
|
666
|
-
exports.SwaggerResponse = SwaggerResponse
|
|
667
|
-
exports.SwaggerTag = SwaggerTag
|
|
668
|
-
exports.getSwaggerMate = getSwaggerMate
|
|
661
|
+
exports.SwaggerDescription = SwaggerDescription;
|
|
662
|
+
exports.SwaggerExample = SwaggerExample;
|
|
663
|
+
exports.SwaggerExclude = SwaggerExclude;
|
|
664
|
+
exports.SwaggerParam = SwaggerParam;
|
|
665
|
+
exports.SwaggerRequestBody = SwaggerRequestBody;
|
|
666
|
+
exports.SwaggerResponse = SwaggerResponse;
|
|
667
|
+
exports.SwaggerTag = SwaggerTag;
|
|
668
|
+
exports.getSwaggerMate = getSwaggerMate;
|
package/dist/index.d.ts
CHANGED
|
@@ -96,4 +96,5 @@ declare class SwaggerController {
|
|
|
96
96
|
'serve'(path: string): Promise<unknown>;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
export { SwaggerController, SwaggerDescription, SwaggerExample, SwaggerExclude, SwaggerParam, SwaggerRequestBody, SwaggerResponse, SwaggerTag,
|
|
99
|
+
export { SwaggerController, SwaggerDescription, SwaggerExample, SwaggerExclude, SwaggerParam, SwaggerRequestBody, SwaggerResponse, SwaggerTag, getSwaggerMate };
|
|
100
|
+
export type { TSwaggerConfigType, TSwaggerMate, TSwaggerResponseOpts };
|
package/dist/index.mjs
CHANGED
|
@@ -174,14 +174,14 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
174
174
|
}, {
|
|
175
175
|
type: paramMeta.type,
|
|
176
176
|
additionalMeta: paramMeta
|
|
177
|
-
},
|
|
177
|
+
}, void 0, logger);
|
|
178
178
|
parsed = myParseZod(zodType);
|
|
179
179
|
schema = getSwaggerSchema(parsed, true);
|
|
180
180
|
}
|
|
181
181
|
addParam({
|
|
182
182
|
name: paramName,
|
|
183
183
|
in: "path",
|
|
184
|
-
description: paramMeta ? paramMeta.description :
|
|
184
|
+
description: paramMeta ? paramMeta.description : void 0,
|
|
185
185
|
required: !paramMeta.optional && !parsed?.$optional,
|
|
186
186
|
schema: schema || { type: "string" }
|
|
187
187
|
});
|
|
@@ -196,7 +196,7 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
196
196
|
}, {
|
|
197
197
|
type: paramMeta.type,
|
|
198
198
|
additionalMeta: paramMeta
|
|
199
|
-
},
|
|
199
|
+
}, void 0, logger);
|
|
200
200
|
const parsed = myParseZod(zodType);
|
|
201
201
|
const schema = getSwaggerSchema(parsed, true);
|
|
202
202
|
if (paramMeta.paramSource === "QUERY_ITEM") endpointSpec.parameters.push({
|
|
@@ -228,7 +228,7 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
228
228
|
}, {
|
|
229
229
|
type: paramMeta.type,
|
|
230
230
|
additionalMeta: paramMeta
|
|
231
|
-
},
|
|
231
|
+
}, void 0, logger);
|
|
232
232
|
const parsed = myParseZod(zodType);
|
|
233
233
|
let contentType = "";
|
|
234
234
|
switch (parsed.$type) {
|
|
@@ -260,7 +260,7 @@ function mapToSwaggerSpec(metadata, options, logger) {
|
|
|
260
260
|
const globalSchemas = {};
|
|
261
261
|
function getSwaggerSchema(parsed, forParam) {
|
|
262
262
|
const zodType = parsed.$ref;
|
|
263
|
-
const meta = zodType.__type_ref ? getSwaggerMate().read(zodType.__type_ref) :
|
|
263
|
+
const meta = zodType.__type_ref ? getSwaggerMate().read(zodType.__type_ref) : void 0;
|
|
264
264
|
if (!forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) return { $ref: `#/components/schemas/${zodType.__type_ref.name}` };
|
|
265
265
|
if (forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) return globalSchemas[zodType.__type_ref.name];
|
|
266
266
|
const schema = {};
|
|
@@ -334,7 +334,7 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
334
334
|
schema.type = "null";
|
|
335
335
|
break;
|
|
336
336
|
}
|
|
337
|
-
default: return
|
|
337
|
+
default: return void 0;
|
|
338
338
|
}
|
|
339
339
|
else switch (parsed.$type) {
|
|
340
340
|
case "ZodString": {
|
|
@@ -379,11 +379,11 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
379
379
|
case "ZodUnknown":
|
|
380
380
|
case "ZodNever":
|
|
381
381
|
case "ZodVoid":
|
|
382
|
-
case "ZodNaN": return
|
|
382
|
+
case "ZodNaN": return void 0;
|
|
383
383
|
case "ZodArray": {
|
|
384
384
|
schema.type = "array";
|
|
385
|
-
schema.minItems = parsed.$checks?.minLength ||
|
|
386
|
-
schema.maxItems = parsed.$checks?.maxLength ||
|
|
385
|
+
schema.minItems = parsed.$checks?.minLength || void 0;
|
|
386
|
+
schema.maxItems = parsed.$checks?.maxLength || void 0;
|
|
387
387
|
schema.items = getSwaggerSchema(parsed.$inner);
|
|
388
388
|
break;
|
|
389
389
|
}
|
|
@@ -412,7 +412,7 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
412
412
|
case "ZodSet": {
|
|
413
413
|
schema.type = "object";
|
|
414
414
|
schema.properties = {};
|
|
415
|
-
schema.additionalProperties = parsed.$type === "ZodRecord" ? {} :
|
|
415
|
+
schema.additionalProperties = parsed.$type === "ZodRecord" ? {} : void 0;
|
|
416
416
|
break;
|
|
417
417
|
}
|
|
418
418
|
case "ZodUnion":
|
|
@@ -425,6 +425,7 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
425
425
|
break;
|
|
426
426
|
}
|
|
427
427
|
case "ZodLazy": return getSwaggerSchema(parsed.$get());
|
|
428
|
+
default: return void 0;
|
|
428
429
|
}
|
|
429
430
|
if (parsed.$nullable) schema.nullable = parsed.$nullable;
|
|
430
431
|
if (parsed.$ref._def.description) schema.description = parsed.$ref._def.description;
|
|
@@ -501,7 +502,7 @@ var SwaggerController = class {
|
|
|
501
502
|
"processCors"() {
|
|
502
503
|
if (this.opts.cors) {
|
|
503
504
|
const { enableCors } = useSetHeaders();
|
|
504
|
-
enableCors(this.opts.cors === true ?
|
|
505
|
+
enableCors(this.opts.cors === true ? void 0 : this.opts.cors);
|
|
505
506
|
}
|
|
506
507
|
}
|
|
507
508
|
"serveIndex"(url, location, status) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/swagger",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.31",
|
|
4
4
|
"description": "@moostjs/swagger",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/swagger#readme",
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
40
|
+
"@wooksjs/event-http": "^0.6.1",
|
|
41
|
+
"@moostjs/zod": "0.5.29",
|
|
42
|
+
"@wooksjs/http-static": "^0.6.1",
|
|
43
|
+
"@moostjs/event-http": "^0.5.31",
|
|
44
|
+
"moost": "^0.5.31"
|
|
42
45
|
},
|
|
43
46
|
"dependencies": {
|
|
44
|
-
"@wooksjs/event-http": "^0.6.0",
|
|
45
|
-
"@wooksjs/http-static": "^0.6.0",
|
|
46
47
|
"swagger-ui-dist": "^5.10.5",
|
|
47
|
-
"zod-parser": "^0.0.3"
|
|
48
|
-
"@moostjs/zod": "^0.5.29"
|
|
48
|
+
"zod-parser": "^0.0.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/swagger-ui-dist": "3.30.5",
|
|
52
|
-
"vitest": "
|
|
52
|
+
"vitest": "3.2.4"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"pub": "pnpm publish --access public",
|