@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 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 { Mate } from '@prostojs/mate';
2
- import { THeaderHook } from '@wooksjs/event-http';
3
- import { TMateParamMeta } from '@prostojs/mate';
4
- import { TMoostMetadata } from 'moost';
5
- import { TStatusHook } from '@wooksjs/event-http';
6
- import { z } from '@moostjs/zod';
7
-
8
- export declare function getSwaggerMate(): Mate<TMoostMetadata<TEmpty> & TSwaggerMate & {
9
- params: (TEmpty & TMateParamMeta)[];
10
- }, TMoostMetadata<TEmpty> & TSwaggerMate & {
11
- params: (TEmpty & TMateParamMeta)[];
12
- }>;
13
-
14
- export declare class SwaggerController {
15
- protected title: string;
16
- constructor(title?: string);
17
- assetPath: string;
18
- serveIndex(url: string, location: THeaderHook, status: TStatusHook): string;
19
- 'swagger-initializer.js'(): string;
20
- spec?: Record<string, unknown>;
21
- 'spec.json'(): Promise<Record<string, unknown>>;
22
- files(url: string): Promise<unknown>;
23
- serve(path: string): Promise<unknown>;
24
- }
25
-
26
- export declare const SwaggerDescription: (descr: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
27
-
28
- export declare const SwaggerExclude: () => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
29
-
30
- export declare function SwaggerRequestBody(opt: TSwaggerResponseOpts): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
31
-
32
- export declare function SwaggerResponse(opts: TSwaggerResponseOpts): MethodDecorator;
33
-
34
- export declare function SwaggerResponse(code: number, opts: TSwaggerResponseOpts): MethodDecorator;
35
-
36
- export declare const SwaggerTag: (tag: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
37
-
38
- declare interface TEmpty {
39
- }
40
-
41
- declare type TFunction = Function;
42
-
43
- export declare interface TSwaggerMate {
44
- swaggerTags: string[];
45
- swaggerExclude: boolean;
46
- swaggerDescription: string;
47
- swaggerResponses: Record<number, Record<string, TSwaggerResponseConfigValue>>;
48
- swaggerRequestBody: Record<string, TSwaggerResponseConfigValue>;
49
- }
50
-
51
- declare interface TSwaggerResponseConfig {
52
- contentType?: string;
53
- description?: string;
54
- response: TSwaggerResponseConfigValue;
55
- }
56
-
57
- export declare type TSwaggerResponseConfigValue = TFunction | z.ZodType | TSwaggerSchema;
58
-
59
- export declare type TSwaggerResponseOpts = TSwaggerResponseConfigValue | TSwaggerResponseConfig;
60
-
61
- declare interface TSwaggerSchema {
62
- type?: string;
63
- $ref?: string;
64
- title?: string;
65
- description?: string;
66
- format?: string;
67
- default?: unknown;
68
- enum?: string[];
69
- nullable?: boolean;
70
- readOnly?: boolean;
71
- writeOnly?: boolean;
72
- example?: unknown;
73
- minLength?: number;
74
- maxLength?: number;
75
- pattern?: string;
76
- minimum?: number;
77
- maximum?: number;
78
- exclusiveMinimum?: number;
79
- exclusiveMaximum?: number;
80
- multipleOf?: number;
81
- items?: TSwaggerSchema | TSwaggerSchema[];
82
- minItems?: number;
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.11",
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.11",
40
- "@moostjs/event-http": "0.3.11"
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.11",
46
- "@wooksjs/http-static": "^0.4.11"
46
+ "@moostjs/zod": "0.3.12",
47
+ "@wooksjs/http-static": "^0.4.13"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/swagger-ui-dist": ""