@tsed/swagger 8.0.0-alpha.9 → 8.0.0-beta.10
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/lib/esm/SwaggerModule.js +2 -1
- package/lib/esm/SwaggerModule.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/services/SwaggerService.js +11 -12
- package/lib/esm/services/SwaggerService.js.map +1 -1
- package/lib/esm/utils/readSpec.js +12 -0
- package/lib/esm/utils/readSpec.js.map +1 -0
- package/lib/types/SwaggerModule.d.ts +2 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/interfaces/SwaggerSettings.d.ts +4 -0
- package/lib/types/middlewares/cssMiddleware.d.ts +1 -1
- package/lib/types/middlewares/indexMiddleware.d.ts +1 -1
- package/lib/types/middlewares/jsMiddleware.d.ts +1 -1
- package/lib/types/middlewares/redirectMiddleware.d.ts +1 -1
- package/lib/types/services/SwaggerService.d.ts +2 -4
- package/lib/types/utils/readSpec.d.ts +1 -0
- package/package.json +18 -18
- package/readme.md +8 -7
package/lib/esm/SwaggerModule.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Configuration, Constant, Inject, InjectorService, Module, PlatformApplication } from "@tsed/common";
|
|
3
2
|
import { Env } from "@tsed/core";
|
|
3
|
+
import { Configuration, Constant, Inject, InjectorService, Module } from "@tsed/di";
|
|
4
4
|
import { normalizePath } from "@tsed/normalize-path";
|
|
5
|
+
import { PlatformApplication } from "@tsed/platform-http";
|
|
5
6
|
import { PlatformRouter, useContextHandler } from "@tsed/platform-router";
|
|
6
7
|
import Fs from "fs";
|
|
7
8
|
import { join } from "path";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwaggerModule.js","sourceRoot":"","sources":["../../src/SwaggerModule.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version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AC,CAAC;IACJ,CAAC;CACF,CAAA;AA9HC;IADC,MAAM,EAAE;8BACC,eAAe;+CAAC;AAG1B;IADC,MAAM,EAAE;8BACJ,mBAAmB;0CAAC;AAGzB;IADC,aAAa,EAAE;;oDACa;AAG7B;IADC,MAAM,EAAE;8BACO,cAAc;qDAAC;AAG/B;IADC,QAAQ,CAAC,KAAK,CAAC;;0CACP;AAGT;IADC,QAAQ,CAAC,6BAA6B,CAAC;;2DACV;AAjBnB,aAAa;IADzB,MAAM,EAAE;GACI,aAAa,CAgIzB"}
|
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { __decorate, __metadata
|
|
2
|
-
import {
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { constant, Injectable } from "@tsed/di";
|
|
3
|
+
import { Platform } from "@tsed/platform-http";
|
|
3
4
|
import { generateSpec } from "@tsed/schema";
|
|
4
5
|
import { includeRoute } from "../utils/includeRoute.js";
|
|
6
|
+
import { readSpec } from "../utils/readSpec.js";
|
|
5
7
|
let SwaggerService = class SwaggerService {
|
|
6
8
|
#specs = new Map();
|
|
7
|
-
constructor(
|
|
8
|
-
this.injectorService = injectorService;
|
|
9
|
+
constructor(platform) {
|
|
9
10
|
this.platform = platform;
|
|
10
|
-
this.configuration = configuration;
|
|
11
11
|
}
|
|
12
12
|
async getOpenAPISpec(conf) {
|
|
13
13
|
if (!this.#specs.has(conf.path)) {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const version = constant("version", "1.0.0");
|
|
15
|
+
const acceptMimes = constant("acceptMimes");
|
|
16
|
+
const specPath = conf.specPath;
|
|
16
17
|
const tokens = this.platform
|
|
17
18
|
.getMountedControllers()
|
|
18
19
|
.filter(({ routes, provider }) => [...routes.values()].some((route) => includeRoute(route, provider, conf)))
|
|
19
20
|
.map(({ route, provider }) => ({ token: provider.token, rootPath: route }));
|
|
20
|
-
const spec =
|
|
21
|
+
const spec = generateSpec({
|
|
21
22
|
tokens,
|
|
22
23
|
...conf,
|
|
23
|
-
specPath,
|
|
24
|
+
fileSpec: specPath ? await readSpec(specPath) : {},
|
|
24
25
|
version,
|
|
25
26
|
acceptMimes
|
|
26
27
|
});
|
|
@@ -31,9 +32,7 @@ let SwaggerService = class SwaggerService {
|
|
|
31
32
|
};
|
|
32
33
|
SwaggerService = __decorate([
|
|
33
34
|
Injectable(),
|
|
34
|
-
|
|
35
|
-
__metadata("design:paramtypes", [InjectorService,
|
|
36
|
-
Platform, Object])
|
|
35
|
+
__metadata("design:paramtypes", [Platform])
|
|
37
36
|
], SwaggerService);
|
|
38
37
|
export { SwaggerService };
|
|
39
38
|
//# sourceMappingURL=SwaggerService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwaggerService.js","sourceRoot":"","sources":["../../../src/services/SwaggerService.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"SwaggerService.js","sourceRoot":"","sources":["../../../src/services/SwaggerService.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAGvC,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,MAAM,GAAuC,IAAI,GAAG,EAAE,CAAC;IAEvD,YAAoB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IASnC,KAAK,CAAC,cAAc,CAAC,IAAqB;QAC/C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC7C,MAAM,WAAW,GAAG,QAAQ,CAAS,aAAa,CAAC,CAAC;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;YAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ;iBACzB,qBAAqB,EAAE;iBACvB,MAAM,CAAC,CAAC,EAAC,MAAM,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;iBACzG,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,QAAQ,CAAC,KAAa,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC;YAElF,MAAM,IAAI,GAAG,YAAY,CAAC;gBACxB,MAAM;gBACN,GAAG,IAAI;gBACP,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;gBAClD,OAAO;gBACP,WAAW;aACZ,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AApCY,cAAc;IAD1B,UAAU,EAAE;qCAImB,QAAQ;GAH3B,cAAc,CAoC1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export async function readSpec(path) {
|
|
2
|
+
const { default: fs } = await import("fs-extra");
|
|
3
|
+
if (fs.existsSync(path)) {
|
|
4
|
+
try {
|
|
5
|
+
return await fs.readJSON(path, { encoding: "utf8" });
|
|
6
|
+
}
|
|
7
|
+
catch (e) { }
|
|
8
|
+
}
|
|
9
|
+
/* istanbul ignore next */
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=readSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readSpec.js","sourceRoot":"","sources":["../../../src/utils/readSpec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,MAAM,EAAC,OAAO,EAAE,EAAE,EAAC,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IAChB,CAAC;IAED,0BAA0B;IAC1B,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Configuration, InjectorService, OnReady, OnRoutesInit, PlatformApplication } from "@tsed/common";
|
|
2
1
|
import { Env } from "@tsed/core";
|
|
2
|
+
import { Configuration, InjectorService } from "@tsed/di";
|
|
3
|
+
import { OnReady, OnRoutesInit, PlatformApplication } from "@tsed/platform-http";
|
|
3
4
|
import { SwaggerSettings } from "./interfaces/SwaggerSettings.js";
|
|
4
5
|
import { SwaggerService } from "./services/SwaggerService.js";
|
|
5
6
|
/**
|
package/lib/types/index.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export interface SwaggerSettingsBase {
|
|
|
62
62
|
* Write the `swagger.json` spec documentation on the specified path.
|
|
63
63
|
*/
|
|
64
64
|
outFile?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Sort paths by alphabetical order
|
|
67
|
+
*/
|
|
68
|
+
sortPaths?: boolean;
|
|
65
69
|
/**
|
|
66
70
|
* A function to generate the operationId.
|
|
67
71
|
*/
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Configuration, InjectorService, Platform } from "@tsed/common";
|
|
2
1
|
import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
|
|
2
|
+
import { Platform } from "@tsed/platform-http";
|
|
3
3
|
import { SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings } from "../interfaces/SwaggerSettings.js";
|
|
4
4
|
export declare class SwaggerService {
|
|
5
5
|
#private;
|
|
6
|
-
private injectorService;
|
|
7
6
|
private platform;
|
|
8
|
-
|
|
9
|
-
constructor(injectorService: InjectorService, platform: Platform, configuration: Configuration);
|
|
7
|
+
constructor(platform: Platform);
|
|
10
8
|
/**
|
|
11
9
|
* Generate Spec for the given configuration
|
|
12
10
|
* @returns {Spec}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readSpec(path: string): Promise<any>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/swagger",
|
|
3
3
|
"description": "Swagger package for Ts.ED framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.0.0-
|
|
5
|
+
"version": "8.0.0-beta.10",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -25,31 +25,31 @@
|
|
|
25
25
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tsed/normalize-path": "8.0.0-
|
|
29
|
-
"@tsed/openspec": "8.0.0-
|
|
28
|
+
"@tsed/normalize-path": "8.0.0-beta.10",
|
|
29
|
+
"@tsed/openspec": "8.0.0-beta.10",
|
|
30
30
|
"fs-extra": "11.2.0",
|
|
31
31
|
"micromatch": "4.0.8",
|
|
32
|
-
"swagger-ui-dist": ">=5.17.
|
|
32
|
+
"swagger-ui-dist": ">=5.17.14",
|
|
33
33
|
"tslib": "2.7.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@tsed/barrels": "8.0.0-
|
|
37
|
-
"@tsed/
|
|
38
|
-
"@tsed/
|
|
39
|
-
"@tsed/
|
|
40
|
-
"@tsed/
|
|
41
|
-
"@tsed/
|
|
42
|
-
"@tsed/
|
|
43
|
-
"@tsed/schema": "8.0.0-
|
|
44
|
-
"@tsed/typescript": "8.0.0-
|
|
45
|
-
"@types/swagger-ui-dist": "3.30.
|
|
46
|
-
"eslint": "9.
|
|
36
|
+
"@tsed/barrels": "8.0.0-beta.10",
|
|
37
|
+
"@tsed/core": "8.0.0-beta.10",
|
|
38
|
+
"@tsed/di": "8.0.0-beta.10",
|
|
39
|
+
"@tsed/json-mapper": "8.0.0-beta.10",
|
|
40
|
+
"@tsed/monorepo-utils": "2.3.9",
|
|
41
|
+
"@tsed/openspec": "8.0.0-beta.10",
|
|
42
|
+
"@tsed/platform-http": "8.0.0-beta.10",
|
|
43
|
+
"@tsed/schema": "8.0.0-beta.10",
|
|
44
|
+
"@tsed/typescript": "8.0.0-beta.10",
|
|
45
|
+
"@types/swagger-ui-dist": "3.30.5",
|
|
46
|
+
"eslint": "9.12.0",
|
|
47
47
|
"ts-node": "10.9.2",
|
|
48
48
|
"typescript": "5.4.5",
|
|
49
|
-
"vitest": "2.
|
|
49
|
+
"vitest": "2.1.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@tsed/
|
|
52
|
+
"@tsed/platform-http": "8.0.0-beta.10"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@tsed/common": {
|
|
@@ -64,6 +64,6 @@
|
|
|
64
64
|
"author": "Romain Lenzotti",
|
|
65
65
|
"license": "MIT",
|
|
66
66
|
"publishConfig": {
|
|
67
|
-
"tag": "
|
|
67
|
+
"tag": "beta"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/readme.md
CHANGED
|
@@ -40,7 +40,7 @@ npm install --save @tsed/swagger
|
|
|
40
40
|
Then add the following configuration in your Server:
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
|
-
import {Configuration} from "@tsed/
|
|
43
|
+
import {Configuration} from "@tsed/di";
|
|
44
44
|
import "@tsed/swagger"; // import swagger Ts.ED module
|
|
45
45
|
import {resolve} from "path";
|
|
46
46
|
|
|
@@ -90,7 +90,7 @@ Some options is available to configure Swagger-ui, Ts.ED and the default spec in
|
|
|
90
90
|
It also possible to create several swagger documentations with `doc` option:
|
|
91
91
|
|
|
92
92
|
```typescript
|
|
93
|
-
import {Configuration} from "@tsed/
|
|
93
|
+
import {Configuration} from "@tsed/di";
|
|
94
94
|
import "@tsed/swagger"; // import swagger Ts.ED module
|
|
95
95
|
|
|
96
96
|
@Configuration({
|
|
@@ -111,7 +111,7 @@ export class Server {}
|
|
|
111
111
|
Then use `@Docs` decorators on your controllers to specify where the controllers should be displayed.
|
|
112
112
|
|
|
113
113
|
```typescript
|
|
114
|
-
import {Controller} from "@tsed/
|
|
114
|
+
import {Controller} from "@tsed/di";
|
|
115
115
|
import {Docs} from "@tsed/swagger";
|
|
116
116
|
|
|
117
117
|
@Controller("/calendars")
|
|
@@ -133,7 +133,7 @@ JSON Object (see [converters section](https://tsed.io/docs/components/converters
|
|
|
133
133
|
This model can used on a method controller along with [@BodyParams](https://tsed.io/api/common/filters/decorators/BodyParams.html) or other decorators.
|
|
134
134
|
|
|
135
135
|
```typescript
|
|
136
|
-
import {JsonProperty, Title, Description, Example} from "@tsed/
|
|
136
|
+
import {JsonProperty, Title, Description, Example} from "@tsed/schema";
|
|
137
137
|
|
|
138
138
|
export class CalendarModel {
|
|
139
139
|
@Title("iD")
|
|
@@ -150,8 +150,9 @@ export class CalendarModel {
|
|
|
150
150
|
#### Endpoint documentation
|
|
151
151
|
|
|
152
152
|
```typescript
|
|
153
|
-
import {
|
|
154
|
-
import {
|
|
153
|
+
import {Controller} from "@tsed/di";
|
|
154
|
+
import {BodyParams, QueryParams} from "@tsed/platform-params";
|
|
155
|
+
import {Get, Post, Returns, ReturnsArray, Description, Summary, Deprecated, Security} from "@tsed/schema";
|
|
155
156
|
import {CalendarModel} from "../models/CalendarModel.js";
|
|
156
157
|
|
|
157
158
|
@Controller("/calendars")
|
|
@@ -199,7 +200,7 @@ To update the swagger.json you need to reload the server before.
|
|
|
199
200
|
It possible to import a Javascript in the Swagger-ui documentation. This script let you customize the swagger-ui instance.
|
|
200
201
|
|
|
201
202
|
```typescript
|
|
202
|
-
import {Configuration} from "@tsed/
|
|
203
|
+
import {Configuration} from "@tsed/di";
|
|
203
204
|
import "@tsed/swagger"; // import swagger Ts.ED module
|
|
204
205
|
|
|
205
206
|
@Configuration({
|