@tsed/swagger 7.79.4 → 7.80.0

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.
@@ -1,4 +1,4 @@
1
1
  import getAbsoluteFSPath from "swagger-ui-dist/absolute-path.js";
2
2
  export const SWAGGER_UI_DIST = getAbsoluteFSPath();
3
- export const ROOT_DIR = import.meta.dirname;
3
+ export const ROOT_DIR = __dirname;
4
4
  //# sourceMappingURL=constants.js.map
@@ -0,0 +1,31 @@
1
+ import { Configuration, InjectorService, OnReady, OnRoutesInit, PlatformApplication } from "@tsed/common";
2
+ import { Env } from "@tsed/core";
3
+ import { SwaggerSettings } from "./interfaces/SwaggerSettings.js";
4
+ import { SwaggerService } from "./services/SwaggerService.js";
5
+ /**
6
+ * @ignore
7
+ */
8
+ export declare class SwaggerModule implements OnRoutesInit, OnReady {
9
+ injector: InjectorService;
10
+ app: PlatformApplication;
11
+ configuration: Configuration;
12
+ swaggerService: SwaggerService;
13
+ env: Env;
14
+ disableRoutesSummary: boolean;
15
+ private loaded;
16
+ get settings(): SwaggerSettings[];
17
+ /**
18
+ *
19
+ */
20
+ $onRoutesInit(): void;
21
+ $onReady(): void;
22
+ generateSpecFiles(): Promise<void[]>;
23
+ private getUrls;
24
+ /**
25
+ *
26
+ * @param conf
27
+ * @param urls
28
+ */
29
+ private createRouter;
30
+ private middlewareSwaggerJson;
31
+ }
@@ -0,0 +1,2 @@
1
+ export declare const SWAGGER_UI_DIST: string;
2
+ export declare const ROOT_DIR: string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Set the type documentation for this class.
3
+ *
4
+ * See [swagger documentation](/tutorials/swagger.html)
5
+ *
6
+ * @decorator
7
+ * @swagger
8
+ * @param docs
9
+ */
10
+ export declare function Docs(...docs: string[]): Function;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Disable documentation for the class and his endpoint.
3
+ *
4
+ * ````typescript
5
+ * @Controller('/')
6
+ * export class Ctrl {
7
+ *
8
+ * @Get('/')
9
+ * @Hidden()
10
+ * hiddenRoute(){
11
+ *
12
+ * }
13
+ * }
14
+ *
15
+ * @Controller('/')
16
+ * @Hidden()
17
+ * export class Ctrl {
18
+ * @Get('/')
19
+ * hiddenRoute() {
20
+ *
21
+ * }
22
+ * @Get('/2')
23
+ * hiddenRoute2() {
24
+ *
25
+ * }
26
+ * }
27
+ * ```
28
+ *
29
+ * @decorator
30
+ * @swagger
31
+ */
32
+ export declare function Hidden(): Function;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "./constants.js";
5
+ export * from "./decorators/docs.js";
6
+ export * from "./decorators/hidden.js";
7
+ export * from "./interfaces/interfaces.js";
8
+ export * from "./interfaces/SwaggerSettings.js";
9
+ export * from "./middlewares/cssMiddleware.js";
10
+ export * from "./middlewares/indexMiddleware.js";
11
+ export * from "./middlewares/jsMiddleware.js";
12
+ export * from "./middlewares/redirectMiddleware.js";
13
+ export * from "./services/SwaggerService.js";
14
+ export * from "./SwaggerModule.js";
15
+ export * from "./utils/includeRoute.js";
16
+ export * from "./utils/matchPath.js";
@@ -0,0 +1,96 @@
1
+ import { OpenSpec2, OpenSpec3, OpenSpecVersions, OS2Versions, OS3Versions } from "@tsed/openspec";
2
+ export interface SwaggerUIOptions {
3
+ configUrl?: string;
4
+ url?: string;
5
+ urls?: {
6
+ url: string;
7
+ name: string;
8
+ primaryName?: string;
9
+ }[];
10
+ layout?: string;
11
+ validatorUrl?: string;
12
+ oauth?: any;
13
+ authorize?: any;
14
+ [key: string]: any;
15
+ }
16
+ export interface SwaggerSettingsBase {
17
+ /**
18
+ * The url subpath to access to the documentation.
19
+ */
20
+ path: string;
21
+ /**
22
+ * Specify the spec version you want to generate.
23
+ */
24
+ specVersion?: OpenSpecVersions;
25
+ /**
26
+ * Swagger file name. By default swagger.json
27
+ */
28
+ fileName?: string;
29
+ /**
30
+ * Hidden documentation. Use this to hide documentation link in the dropdown.
31
+ */
32
+ hidden?: string;
33
+ /**
34
+ * The documentation key used by `@Docs` decorator to create several swagger documentations.
35
+ */
36
+ doc?: string;
37
+ /**
38
+ * The path to the CSS file.
39
+ */
40
+ cssPath?: string;
41
+ /**
42
+ * The path to the JS file.
43
+ */
44
+ jsPath?: string;
45
+ /**
46
+ * The path to the ejs file to create html page.
47
+ */
48
+ viewPath?: string | false;
49
+ /**
50
+ * SwaggerUI options. See (https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md)
51
+ */
52
+ options?: SwaggerUIOptions;
53
+ /**
54
+ * Display the search field in the navbar.
55
+ */
56
+ showExplorer?: boolean;
57
+ /**
58
+ * Load the base spec documentation from the specified path.
59
+ */
60
+ specPath?: string;
61
+ /**
62
+ * Write the `swagger.json` spec documentation on the specified path.
63
+ */
64
+ outFile?: string;
65
+ /**
66
+ * A function to generate the operationId.
67
+ */
68
+ operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;
69
+ /**
70
+ * A pattern to generate the operationId. Format of operationId field (%c: class name, %m: method name).
71
+ */
72
+ operationIdPattern?: string;
73
+ /**
74
+ *
75
+ */
76
+ disableSpec?: boolean;
77
+ /**
78
+ * Include only controllers whose paths match the pattern list provided.
79
+ */
80
+ pathPatterns?: string[];
81
+ }
82
+ export interface SwaggerOS2Settings extends SwaggerSettingsBase {
83
+ specVersion?: OS2Versions;
84
+ /**
85
+ * OpenSpec 2
86
+ */
87
+ spec?: Partial<OpenSpec2>;
88
+ }
89
+ export interface SwaggerOS3Settings extends SwaggerSettingsBase {
90
+ specVersion?: OS3Versions;
91
+ /**
92
+ * OpenSpec 3
93
+ */
94
+ spec?: Partial<OpenSpec3>;
95
+ }
96
+ export type SwaggerSettings = SwaggerOS2Settings | SwaggerOS3Settings;
@@ -0,0 +1,8 @@
1
+ import { SwaggerSettings } from "./SwaggerSettings.js";
2
+ declare global {
3
+ namespace TsED {
4
+ interface Configuration {
5
+ swagger: SwaggerSettings[];
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ /**
3
+ * @ignore
4
+ * @param path
5
+ */
6
+ export declare function cssMiddleware(path: string): (ctx: PlatformContext) => void;
@@ -0,0 +1,10 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { SwaggerSettings } from "../interfaces/SwaggerSettings.js";
3
+ /**
4
+ * @ignore
5
+ * @param viewPath
6
+ * @param conf
7
+ */
8
+ export declare function indexMiddleware(viewPath: string, conf: SwaggerSettings & {
9
+ urls: string[];
10
+ }): (ctx: PlatformContext) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ /**
3
+ * @ignore
4
+ * @param path
5
+ */
6
+ export declare function jsMiddleware(path: string): (ctx: PlatformContext) => void;
@@ -0,0 +1,6 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ /**
3
+ * @ignore
4
+ * @param path
5
+ */
6
+ export declare function redirectMiddleware(path: string): (ctx: PlatformContext) => void;
@@ -0,0 +1,17 @@
1
+ import { Configuration, InjectorService, Platform } from "@tsed/common";
2
+ import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
3
+ import { SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings } from "../interfaces/SwaggerSettings.js";
4
+ export declare class SwaggerService {
5
+ #private;
6
+ private injectorService;
7
+ private platform;
8
+ private configuration;
9
+ constructor(injectorService: InjectorService, platform: Platform, configuration: Configuration);
10
+ /**
11
+ * Generate Spec for the given configuration
12
+ * @returns {Spec}
13
+ */
14
+ getOpenAPISpec(conf: SwaggerOS3Settings): Promise<OpenSpec3>;
15
+ getOpenAPISpec(conf: SwaggerOS2Settings): Promise<OpenSpec2>;
16
+ getOpenAPISpec(conf: SwaggerSettings): Promise<OpenSpec2>;
17
+ }
@@ -0,0 +1,3 @@
1
+ import { Provider } from "@tsed/di";
2
+ import { SwaggerSettings } from "../interfaces/SwaggerSettings.js";
3
+ export declare function includeRoute(route: string, provider: Provider, conf: SwaggerSettings): boolean;
@@ -0,0 +1 @@
1
+ export declare function matchPath(path: string, patterns?: string[]): boolean;
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@tsed/swagger",
3
- "version": "7.79.4",
4
3
  "description": "Swagger package for Ts.ED framework",
4
+ "type": "commonjs",
5
+ "version": "7.80.0",
5
6
  "source": "./src/index.ts",
6
7
  "main": "./lib/cjs/index.js",
7
8
  "module": "./lib/esm/index.js",
8
9
  "typings": "./lib/types/index.d.ts",
9
10
  "exports": {
10
- "types": "./lib/types/index.d.ts",
11
- "import": "./lib/esm/index.js",
12
- "require": "./lib/cjs/index.js",
13
- "default": "./lib/esm/index.js"
11
+ ".": {
12
+ "types": "./lib/types/index.d.ts",
13
+ "import": "./lib/esm/index.js",
14
+ "default": "./lib/cjs/index.js"
15
+ }
14
16
  },
15
17
  "scripts": {
16
18
  "clean": "rm -rf lib",
@@ -18,35 +20,36 @@
18
20
  "copy:views": "cp -r ./views ./lib/views",
19
21
  "barrels": "barrels",
20
22
  "start": "ts-node test/app/index.ts",
21
- "test": "jest --max-workers=2 && jest-coverage-thresholds-bumper",
22
- "build:ts": "tsc --build tsconfig.json && tsc --build tsconfig.esm.json"
23
+ "test": "vitest run",
24
+ "build:ts": "tsc --build tsconfig.json",
25
+ "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
23
26
  },
24
27
  "dependencies": {
25
- "@tsed/normalize-path": "7.79.4",
26
- "@tsed/openspec": "7.79.4",
28
+ "@tsed/normalize-path": "7.80.0",
29
+ "@tsed/openspec": "7.80.0",
27
30
  "fs-extra": "11.2.0",
28
31
  "micromatch": "4.0.5",
29
32
  "swagger-ui-dist": ">=5.17.1",
30
33
  "tslib": "2.6.1"
31
34
  },
32
35
  "devDependencies": {
33
- "@tsed/barrels": "7.79.4",
34
- "@tsed/common": "7.79.4",
35
- "@tsed/core": "7.79.4",
36
- "@tsed/di": "7.79.4",
37
- "@tsed/json-mapper": "7.79.4",
36
+ "@tsed/barrels": "7.80.0",
37
+ "@tsed/common": "7.80.0",
38
+ "@tsed/core": "7.80.0",
39
+ "@tsed/di": "7.80.0",
40
+ "@tsed/json-mapper": "7.80.0",
38
41
  "@tsed/monorepo-utils": "2.3.2",
39
- "@tsed/openspec": "7.79.4",
40
- "@tsed/schema": "7.79.4",
41
- "@tsed/typescript": "7.79.4",
42
+ "@tsed/openspec": "7.80.0",
43
+ "@tsed/schema": "7.80.0",
44
+ "@tsed/typescript": "7.80.0",
42
45
  "@types/swagger-ui-dist": "3.30.4",
43
46
  "eslint": "^8.57.0",
44
- "jest": "^29.7.0",
45
47
  "ts-node": "10.9.2",
46
- "typescript": "4.9.5"
48
+ "typescript": "4.9.5",
49
+ "vitest": "2.0.4"
47
50
  },
48
51
  "peerDependencies": {
49
- "@tsed/common": "7.79.4"
52
+ "@tsed/common": "7.80.0"
50
53
  },
51
54
  "peerDependenciesMeta": {
52
55
  "@tsed/common": {
@@ -0,0 +1,21 @@
1
+ // @ts-ignore
2
+ import {presets} from "@tsed/vitest/presets";
3
+ import {defineConfig} from "vitest/config";
4
+
5
+ export default defineConfig(
6
+ {
7
+ ...presets,
8
+ test: {
9
+ ...presets.test,
10
+ coverage: {
11
+ ...presets.test.coverage,
12
+ thresholds: {
13
+ statements: 0,
14
+ branches: 0,
15
+ functions: 0,
16
+ lines: 0
17
+ }
18
+ }
19
+ }
20
+ }
21
+ );
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }