@moostjs/swagger 0.3.11 → 0.3.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/index.cjs +0 -5
- package/dist/index.d.ts +82 -94
- package/dist/index.mjs +0 -5
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -58,11 +58,9 @@ function SwaggerResponse(code, opts) {
|
|
|
58
58
|
const keyCode = typeof code === 'number' ? code : 0;
|
|
59
59
|
const opt = typeof code === 'number' ? opts : code;
|
|
60
60
|
const contentType = typeof opt.contentType === 'string' ? opt.contentType : '*/*';
|
|
61
|
-
// const description = typeof (opt as { description: string }).description === 'string' ? (opt as { description: string }).description : undefined
|
|
62
61
|
const response = (['object', 'function'].includes(typeof opt.response) ? opt.response : opt);
|
|
63
62
|
meta.swaggerResponses[keyCode] = meta.swaggerResponses[keyCode] || {};
|
|
64
63
|
meta.swaggerResponses[keyCode][contentType] = response;
|
|
65
|
-
// meta.swaggerResponses[keyCode].description = description
|
|
66
64
|
return meta;
|
|
67
65
|
});
|
|
68
66
|
}
|
|
@@ -397,12 +395,9 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
397
395
|
case 'ZodVoid':
|
|
398
396
|
case 'ZodNaN':
|
|
399
397
|
return undefined;
|
|
400
|
-
// case 'ZodAny':
|
|
401
398
|
case 'ZodArray':
|
|
402
399
|
schema.type = 'array';
|
|
403
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
404
400
|
schema.minItems = parsed.$checks?.minLength || undefined;
|
|
405
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
406
401
|
schema.maxItems = parsed.$checks?.maxLength || undefined;
|
|
407
402
|
schema.items = getSwaggerSchema(parsed.$inner);
|
|
408
403
|
break;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,94 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
maxItems?: number;
|
|
84
|
-
uniqueItems?: boolean;
|
|
85
|
-
properties?: Record<string, TSwaggerSchema>;
|
|
86
|
-
additionalProperties?: boolean | TSwaggerSchema;
|
|
87
|
-
required?: string[];
|
|
88
|
-
allOf?: TSwaggerSchema[];
|
|
89
|
-
anyOf?: TSwaggerSchema[];
|
|
90
|
-
oneOf?: TSwaggerSchema[];
|
|
91
|
-
not?: TSwaggerSchema;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { }
|
|
1
|
+
import { THeaderHook, TStatusHook } from '@wooksjs/event-http';
|
|
2
|
+
import * as _prostojs_mate from '@prostojs/mate';
|
|
3
|
+
import * as moost from 'moost';
|
|
4
|
+
import { z } from '@moostjs/zod';
|
|
5
|
+
|
|
6
|
+
declare class SwaggerController {
|
|
7
|
+
protected title: string;
|
|
8
|
+
constructor(title?: string);
|
|
9
|
+
assetPath: string;
|
|
10
|
+
serveIndex(url: string, location: THeaderHook, status: TStatusHook): string;
|
|
11
|
+
'swagger-initializer.js'(): string;
|
|
12
|
+
spec?: Record<string, unknown>;
|
|
13
|
+
'spec.json'(): Promise<Record<string, unknown>>;
|
|
14
|
+
files(url: string): Promise<unknown>;
|
|
15
|
+
serve(path: string): Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type TFunction = Function;
|
|
19
|
+
interface TEmpty {
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TSwaggerSchema {
|
|
23
|
+
type?: string;
|
|
24
|
+
$ref?: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
format?: string;
|
|
28
|
+
default?: unknown;
|
|
29
|
+
enum?: string[];
|
|
30
|
+
nullable?: boolean;
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
writeOnly?: boolean;
|
|
33
|
+
example?: unknown;
|
|
34
|
+
minLength?: number;
|
|
35
|
+
maxLength?: number;
|
|
36
|
+
pattern?: string;
|
|
37
|
+
minimum?: number;
|
|
38
|
+
maximum?: number;
|
|
39
|
+
exclusiveMinimum?: number;
|
|
40
|
+
exclusiveMaximum?: number;
|
|
41
|
+
multipleOf?: number;
|
|
42
|
+
items?: TSwaggerSchema | TSwaggerSchema[];
|
|
43
|
+
minItems?: number;
|
|
44
|
+
maxItems?: number;
|
|
45
|
+
uniqueItems?: boolean;
|
|
46
|
+
properties?: Record<string, TSwaggerSchema>;
|
|
47
|
+
additionalProperties?: boolean | TSwaggerSchema;
|
|
48
|
+
required?: string[];
|
|
49
|
+
allOf?: TSwaggerSchema[];
|
|
50
|
+
anyOf?: TSwaggerSchema[];
|
|
51
|
+
oneOf?: TSwaggerSchema[];
|
|
52
|
+
not?: TSwaggerSchema;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare function getSwaggerMate(): _prostojs_mate.Mate<moost.TMoostMetadata<TEmpty> & TSwaggerMate & {
|
|
56
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
57
|
+
}, moost.TMoostMetadata<TEmpty> & TSwaggerMate & {
|
|
58
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
59
|
+
}>;
|
|
60
|
+
interface TSwaggerMate {
|
|
61
|
+
swaggerTags: string[];
|
|
62
|
+
swaggerExclude: boolean;
|
|
63
|
+
swaggerDescription: string;
|
|
64
|
+
swaggerResponses: Record<number, Record<string, TSwaggerResponseConfigValue>>;
|
|
65
|
+
swaggerRequestBody: Record<string, TSwaggerResponseConfigValue>;
|
|
66
|
+
}
|
|
67
|
+
type TSwaggerResponseConfigValue = TFunction | z.ZodType | TSwaggerSchema;
|
|
68
|
+
interface TSwaggerResponseConfig {
|
|
69
|
+
contentType?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
response: TSwaggerResponseConfigValue;
|
|
72
|
+
}
|
|
73
|
+
type TSwaggerResponseOpts = TSwaggerResponseConfigValue | TSwaggerResponseConfig;
|
|
74
|
+
|
|
75
|
+
declare const SwaggerTag: (tag: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
76
|
+
declare const SwaggerExclude: () => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
77
|
+
declare const SwaggerDescription: (descr: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
78
|
+
declare function SwaggerResponse(opts: TSwaggerResponseOpts): MethodDecorator;
|
|
79
|
+
declare function SwaggerResponse(code: number, opts: TSwaggerResponseOpts): MethodDecorator;
|
|
80
|
+
declare function SwaggerRequestBody(opt: TSwaggerResponseOpts): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
81
|
+
|
|
82
|
+
export { SwaggerController, SwaggerDescription, SwaggerExclude, SwaggerRequestBody, SwaggerResponse, SwaggerTag, type TSwaggerMate, type TSwaggerResponseConfigValue, type TSwaggerResponseOpts, getSwaggerMate };
|
package/dist/index.mjs
CHANGED
|
@@ -56,11 +56,9 @@ function SwaggerResponse(code, opts) {
|
|
|
56
56
|
const keyCode = typeof code === 'number' ? code : 0;
|
|
57
57
|
const opt = typeof code === 'number' ? opts : code;
|
|
58
58
|
const contentType = typeof opt.contentType === 'string' ? opt.contentType : '*/*';
|
|
59
|
-
// const description = typeof (opt as { description: string }).description === 'string' ? (opt as { description: string }).description : undefined
|
|
60
59
|
const response = (['object', 'function'].includes(typeof opt.response) ? opt.response : opt);
|
|
61
60
|
meta.swaggerResponses[keyCode] = meta.swaggerResponses[keyCode] || {};
|
|
62
61
|
meta.swaggerResponses[keyCode][contentType] = response;
|
|
63
|
-
// meta.swaggerResponses[keyCode].description = description
|
|
64
62
|
return meta;
|
|
65
63
|
});
|
|
66
64
|
}
|
|
@@ -395,12 +393,9 @@ function getSwaggerSchema(parsed, forParam) {
|
|
|
395
393
|
case 'ZodVoid':
|
|
396
394
|
case 'ZodNaN':
|
|
397
395
|
return undefined;
|
|
398
|
-
// case 'ZodAny':
|
|
399
396
|
case 'ZodArray':
|
|
400
397
|
schema.type = 'array';
|
|
401
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
402
398
|
schema.minItems = parsed.$checks?.minLength || undefined;
|
|
403
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
404
399
|
schema.maxItems = parsed.$checks?.maxLength || undefined;
|
|
405
400
|
schema.items = getSwaggerSchema(parsed.$inner);
|
|
406
401
|
break;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/swagger",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "@moostjs/swagger",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
10
11
|
".": {
|
|
11
12
|
"import": "./dist/index.mjs",
|
|
12
13
|
"require": "./dist/index.cjs",
|
|
@@ -36,14 +37,14 @@
|
|
|
36
37
|
},
|
|
37
38
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/swagger#readme",
|
|
38
39
|
"peerDependencies": {
|
|
39
|
-
"moost": "0.3.
|
|
40
|
-
"@moostjs/event-http": "0.3.
|
|
40
|
+
"moost": "0.3.12",
|
|
41
|
+
"@moostjs/event-http": "0.3.12"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"swagger-ui-dist": "^5.10.5",
|
|
44
45
|
"zod-parser": "^0.0.3",
|
|
45
|
-
"@moostjs/zod": "0.3.
|
|
46
|
-
"@wooksjs/http-static": "^0.4.
|
|
46
|
+
"@moostjs/zod": "0.3.12",
|
|
47
|
+
"@wooksjs/http-static": "^0.4.13"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@types/swagger-ui-dist": ""
|