@tsed/scalar 8.3.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.
- package/lib/esm/ScalarModule.js +37 -0
- package/lib/esm/ScalarModule.js.map +1 -0
- package/lib/esm/constants.js +3 -0
- package/lib/esm/constants.js.map +1 -0
- package/lib/esm/exports.js +2 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +9 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/ScalarSettings.js +2 -0
- package/lib/esm/interfaces/ScalarSettings.js.map +1 -0
- package/lib/esm/middlewares/indexMiddleware.js +23 -0
- package/lib/esm/middlewares/indexMiddleware.js.map +1 -0
- package/lib/types/ScalarModule.d.ts +8 -0
- package/lib/types/constants.d.ts +1 -0
- package/lib/types/exports.d.ts +1 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/interfaces/ScalarSettings.d.ts +6 -0
- package/lib/types/middlewares/indexMiddleware.d.ts +2 -0
- package/lib/views/assets/scalar.css +96 -0
- package/lib/views/scalar.ejs +19 -0
- package/package.json +64 -0
- package/readme.md +214 -0
- package/src/ScalarModule.spec.ts +60 -0
- package/src/ScalarModule.ts +46 -0
- package/src/constants.ts +3 -0
- package/src/exports.ts +1 -0
- package/src/index.ts +8 -0
- package/src/interfaces/ScalarSettings.ts +9 -0
- package/src/middlewares/indexMiddleware.ts +30 -0
- package/views/assets/scalar.css +96 -0
- package/views/scalar.ejs +19 -0
- package/vitest.config.mts +21 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { constant, injectable, ProviderType } from "@tsed/di";
|
|
3
|
+
import { OpenAPIBaseModule } from "@tsed/openapi-utils";
|
|
4
|
+
import { useContextHandler } from "@tsed/platform-router";
|
|
5
|
+
import { ROOT_DIR } from "./constants.js";
|
|
6
|
+
import { indexMiddleware } from "./middlewares/indexMiddleware.js";
|
|
7
|
+
export class ScalarModule extends OpenAPIBaseModule {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.name = "Scalar";
|
|
11
|
+
this.rootDir = ROOT_DIR;
|
|
12
|
+
}
|
|
13
|
+
get settings() {
|
|
14
|
+
const settings = constant("scalar", []).filter((o) => !!o);
|
|
15
|
+
return settings.map((conf) => {
|
|
16
|
+
return Object.assign({
|
|
17
|
+
disableSpec: false,
|
|
18
|
+
_integration: "tsed",
|
|
19
|
+
cdn: "https://cdn.jsdelivr.net/npm/@scalar/api-reference",
|
|
20
|
+
path: "/",
|
|
21
|
+
fileName: "openapi.json",
|
|
22
|
+
cssPath: join(ROOT_DIR, "views/assets/scalar.css"),
|
|
23
|
+
viewPath: join(ROOT_DIR, "views/scalar.ejs")
|
|
24
|
+
}, conf);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
createRouter(conf) {
|
|
28
|
+
const { viewPath } = conf;
|
|
29
|
+
const router = super.createRouter(conf);
|
|
30
|
+
if (viewPath) {
|
|
31
|
+
router.get("/", useContextHandler(indexMiddleware(viewPath, conf)));
|
|
32
|
+
}
|
|
33
|
+
return router;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
injectable(ScalarModule).type(ProviderType.MODULE);
|
|
37
|
+
//# sourceMappingURL=ScalarModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScalarModule.js","sourceRoot":"","sources":["../../src/ScalarModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/B,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAEjE,MAAM,OAAO,YAAa,SAAQ,iBAAiB;IAAnD;;QACW,SAAI,GAAG,QAAQ,CAAC;QAChB,YAAO,GAAG,QAAQ,CAAC;IA+B9B,CAAC;IA7BC,IAAI,QAAQ;QACV,MAAM,QAAQ,GAAG,QAAQ,CAAmB,QAAQ,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE7E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,OAAO,MAAM,CAAC,MAAM,CAClB;gBACE,WAAW,EAAE,KAAK;gBAClB,YAAY,EAAE,MAAM;gBACpB,GAAG,EAAE,oDAAoD;gBACzD,IAAI,EAAE,GAAG;gBACT,QAAQ,EAAE,cAAc;gBACxB,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,yBAAyB,CAAC;gBAClD,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC;aAC7C,EACD,IAAI,CACL,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAES,YAAY,CAAC,IAAoB;QACzC,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QACxB,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,UAAU,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAE1B,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC"}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by @tsed/barrels.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./constants.js";
|
|
5
|
+
export * from "./exports.js";
|
|
6
|
+
export * from "./interfaces/ScalarSettings.js";
|
|
7
|
+
export * from "./middlewares/indexMiddleware.js";
|
|
8
|
+
export * from "./ScalarModule.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScalarSettings.js","sourceRoot":"","sources":["../../../src/interfaces/ScalarSettings.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { context } from "@tsed/di";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
export function indexMiddleware(viewPath, conf) {
|
|
5
|
+
return async () => {
|
|
6
|
+
const ctx = context();
|
|
7
|
+
const { path, options = {}, cssPath, cdn, fileName } = conf;
|
|
8
|
+
const opts = {
|
|
9
|
+
_integration: "tsed",
|
|
10
|
+
spec: {
|
|
11
|
+
url: `${path}/${fileName}`
|
|
12
|
+
},
|
|
13
|
+
...options
|
|
14
|
+
};
|
|
15
|
+
ctx.response.body(await ctx.response.render(viewPath, {
|
|
16
|
+
cssPath: join(path, basename(cssPath)),
|
|
17
|
+
cdn,
|
|
18
|
+
serializedOptions: JSON.stringify(opts).split('"').join("""),
|
|
19
|
+
options: opts
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=indexMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/indexMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AACjC,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAI1B,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,IAAoB;IACpE,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;QACtB,MAAM,EAAC,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;QAE1D,MAAM,IAAI,GAAG;YACX,YAAY,EAAE,MAAM;YACpB,IAAI,EAAE;gBACJ,GAAG,EAAE,GAAG,IAAI,IAAI,QAAQ,EAAE;aAC3B;YACD,GAAG,OAAO;SACX,CAAC;QAEF,GAAG,CAAC,QAAQ,CAAC,IAAI,CACf,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE;YAClC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;YACtC,GAAG;YACH,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;YACjE,OAAO,EAAE,IAAI;SACd,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OpenAPIBaseModule } from "@tsed/openapi-utils";
|
|
2
|
+
import { ScalarSettings } from "./interfaces/ScalarSettings.js";
|
|
3
|
+
export declare class ScalarModule extends OpenAPIBaseModule {
|
|
4
|
+
readonly name = "Scalar";
|
|
5
|
+
readonly rootDir: string;
|
|
6
|
+
get settings(): any[];
|
|
7
|
+
protected createRouter(conf: ScalarSettings): import("@tsed/platform-router").PlatformRouter;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ROOT_DIR: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Docs } from "@tsed/openapi-utils";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* basic theme */
|
|
2
|
+
.light-mode {
|
|
3
|
+
--scalar-color-1: #353535;
|
|
4
|
+
--scalar-color-2: #555555;
|
|
5
|
+
--scalar-color-3: #aeaeae;
|
|
6
|
+
--scalar-color-accent: #259dff;
|
|
7
|
+
|
|
8
|
+
--scalar-background-1: #fff;
|
|
9
|
+
--scalar-background-2: #f7f7f7;
|
|
10
|
+
--scalar-background-3: #dadada;
|
|
11
|
+
--scalar-background-accent: #E0F5FF;
|
|
12
|
+
|
|
13
|
+
--scalar-border-color: rgba(0, 0, 0, 0.1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.dark-mode {
|
|
17
|
+
--scalar-color-1: rgba(255, 255, 255, 0.9);
|
|
18
|
+
--scalar-color-2: rgba(255, 255, 255, 0.62);
|
|
19
|
+
--scalar-color-3: rgba(255, 255, 255, 0.44);
|
|
20
|
+
--scalar-color-accent: #8ab4f8;
|
|
21
|
+
|
|
22
|
+
--scalar-background-1: #1a1a1a;
|
|
23
|
+
--scalar-background-2: #252525;
|
|
24
|
+
--scalar-background-3: #323232;
|
|
25
|
+
--scalar-background-accent: #8ab4f81f;
|
|
26
|
+
|
|
27
|
+
--scalar-border-color: rgba(255, 255, 255, 0.1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Document Sidebar */
|
|
31
|
+
.light-mode .t-doc__sidebar {
|
|
32
|
+
--scalar-sidebar-background-1: var(--scalar-background-1);
|
|
33
|
+
--scalar-sidebar-item-hover-color: currentColor;
|
|
34
|
+
--scalar-sidebar-item-hover-background: var(--scalar-background-2);
|
|
35
|
+
--scalar-sidebar-item-active-background: var(--scalar-background-accent);
|
|
36
|
+
--scalar-sidebar-border-color: var(--scalar-border-color);
|
|
37
|
+
--scalar-sidebar-color-1: var(--scalar-color-1);
|
|
38
|
+
--scalar-sidebar-color-2: var(--scalar-color-2);
|
|
39
|
+
--scalar-sidebar-color-active: var(--scalar-color-accent);
|
|
40
|
+
--scalar-sidebar-search-background: transparent;
|
|
41
|
+
--scalar-sidebar-search-border-color: var(--scalar-border-color);
|
|
42
|
+
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.dark-mode .sidebar {
|
|
46
|
+
--scalar-sidebar-background-1: var(--scalar-background-1);
|
|
47
|
+
--scalar-sidebar-item-hover-color: currentColor;
|
|
48
|
+
--scalar-sidebar-item-hover-background: var(--scalar-background-2);
|
|
49
|
+
--scalar-sidebar-item-active-background: var(--scalar-background-accent);
|
|
50
|
+
--scalar-sidebar-border-color: var(--scalar-border-color);
|
|
51
|
+
--scalar-sidebar-color-1: var(--scalar-color-1);
|
|
52
|
+
--scalar-sidebar-color-2: var(--scalar-color-2);
|
|
53
|
+
--scalar-sidebar-color-active: var(--scalar-color-accent);
|
|
54
|
+
--scalar-sidebar-search-background: transparent;
|
|
55
|
+
--scalar-sidebar-search-border-color: var(--scalar-border-color);
|
|
56
|
+
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* advanced */
|
|
60
|
+
.light-mode {
|
|
61
|
+
--scalar-button-1: rgb(49 53 56);
|
|
62
|
+
--scalar-button-1-color: #fff;
|
|
63
|
+
--scalar-button-1-hover: rgb(28 31 33);
|
|
64
|
+
|
|
65
|
+
--scalar-color-green: #669900;
|
|
66
|
+
--scalar-color-red: #dc4a68;
|
|
67
|
+
--scalar-color-yellow: #edbe20;
|
|
68
|
+
--scalar-color-blue: #0277aa;
|
|
69
|
+
--scalar-color-orange: #fb892c;
|
|
70
|
+
--scalar-color-purple: #5203d1;
|
|
71
|
+
|
|
72
|
+
--scalar-scrollbar-color: rgba(0, 0, 0, 0.18);
|
|
73
|
+
--scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.dark-mode {
|
|
77
|
+
--scalar-button-1: #f6f6f6;
|
|
78
|
+
--scalar-button-1-color: #000;
|
|
79
|
+
--scalar-button-1-hover: #e7e7e7;
|
|
80
|
+
|
|
81
|
+
--scalar-color-green: #00b648;
|
|
82
|
+
--scalar-color-red: #dc1b19;
|
|
83
|
+
--scalar-color-yellow: #ffc90d;
|
|
84
|
+
--scalar-color-blue: #4eb3ec;
|
|
85
|
+
--scalar-color-orange: #ff8d4d;
|
|
86
|
+
--scalar-color-purple: #b191f9;
|
|
87
|
+
|
|
88
|
+
--scalar-scrollbar-color: rgba(255, 255, 255, 0.24);
|
|
89
|
+
--scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:root {
|
|
93
|
+
--scalar-radius: 3px;
|
|
94
|
+
--scalar-radius-lg: 3px;
|
|
95
|
+
--scalar-radius-xl: 3px;
|
|
96
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Scalar API Reference</title>
|
|
5
|
+
<meta charset="utf-8"/>
|
|
6
|
+
<meta
|
|
7
|
+
name="viewport"
|
|
8
|
+
content="width=device-width, initial-scale=1"/>
|
|
9
|
+
<link>
|
|
10
|
+
<link rel="stylesheet" href="<%= cssPath %>" />
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<script
|
|
14
|
+
id="api-reference"
|
|
15
|
+
type="application/json"
|
|
16
|
+
data-configuration="<%= serializedOptions %>"></script>
|
|
17
|
+
<script src="<%= cdn %>"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsed/scalar",
|
|
3
|
+
"description": "Scalar package for Ts.ED framework",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "8.3.0",
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"main": "./lib/esm/index.js",
|
|
8
|
+
"module": "./lib/esm/index.js",
|
|
9
|
+
"typings": "./lib/types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"@tsed/source": "./src/index.ts",
|
|
13
|
+
"types": "./lib/types/index.d.ts",
|
|
14
|
+
"import": "./lib/esm/index.js",
|
|
15
|
+
"default": "./lib/esm/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rm -rf lib",
|
|
20
|
+
"build": "yarn clean && yarn barrels && yarn build:ts && yarn copy:views",
|
|
21
|
+
"copy:views": "cp -r ./views ./lib/views",
|
|
22
|
+
"barrels": "barrels",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"start": "node --import @swc-node/register/esm-register test/app/index.ts",
|
|
25
|
+
"build:ts": "tsc --build tsconfig.json",
|
|
26
|
+
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@scalar/types": "^0.0.23",
|
|
30
|
+
"@tsed/normalize-path": "8.3.0",
|
|
31
|
+
"@tsed/openapi-utils": "8.3.0",
|
|
32
|
+
"@tsed/openspec": "8.3.0",
|
|
33
|
+
"tslib": "2.7.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@tsed/barrels": "8.3.0",
|
|
37
|
+
"@tsed/core": "8.3.0",
|
|
38
|
+
"@tsed/di": "8.3.0",
|
|
39
|
+
"@tsed/json-mapper": "8.3.0",
|
|
40
|
+
"@tsed/openspec": "8.3.0",
|
|
41
|
+
"@tsed/platform-http": "8.3.0",
|
|
42
|
+
"@tsed/schema": "8.3.0",
|
|
43
|
+
"@tsed/swagger": "8.3.0",
|
|
44
|
+
"@tsed/typescript": "8.3.0",
|
|
45
|
+
"eslint": "9.12.0",
|
|
46
|
+
"typescript": "5.4.5",
|
|
47
|
+
"vitest": "2.1.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@tsed/platform-http": "8.3.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"@tsed/platform-http": {
|
|
54
|
+
"optional": false
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"repository": "https://github.com/tsedio/tsed",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/tsedio/tsed/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/specs/scalar",
|
|
62
|
+
"author": "Romain Lenzotti",
|
|
63
|
+
"license": "MIT"
|
|
64
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<p style="text-align: center" align="center">
|
|
2
|
+
<a href="https://tsed.dev" target="_blank"><img src="https://tsed.dev/tsed-og.png" width="200" alt="Ts.ED logo"/></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h1>Scalar</h1>
|
|
7
|
+
|
|
8
|
+
[](https://github.com/tsedio/tsed/actions?query=workflow%3A%22Build+%26+Release%22)
|
|
9
|
+
[](https://github.com/tsedio/tsed/blob/master/CONTRIBUTING.md)
|
|
10
|
+
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
11
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
12
|
+
[](https://github.com/prettier/prettier)
|
|
13
|
+
[](https://github.com/sponsors/romakita)
|
|
14
|
+
[](https://opencollective.com/tsed)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<a href="https://tsed.io/">Website</a>
|
|
20
|
+
<span> • </span>
|
|
21
|
+
<a href="https://tsed.io/getting-started/">Getting started</a>
|
|
22
|
+
<span> • </span>
|
|
23
|
+
<a href="https://slack.tsed.io">Slack</a>
|
|
24
|
+
<span> • </span>
|
|
25
|
+
<a href="https://twitter.com/TsED_io">Twitter</a>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<hr />
|
|
29
|
+
|
|
30
|
+
A package of Ts.ED framework. See website: https://tsed.io/#/tutorials/scalar
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install --save @tsed/scalar
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then add the following configuration in your Server:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import {Configuration} from "@tsed/di";
|
|
42
|
+
import "@tsed/scalar"; // import scalar Ts.ED module
|
|
43
|
+
import {resolve} from "path";
|
|
44
|
+
|
|
45
|
+
@Configuration({
|
|
46
|
+
scalar: [
|
|
47
|
+
{
|
|
48
|
+
path: "/v3/docs",
|
|
49
|
+
specVersion: "3.0.1"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
export class Server {}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> The path option for swagger will be used to expose the documentation (ex: http://localhost:8000/docs).
|
|
57
|
+
|
|
58
|
+
Normally, Swagger-ui is ready. You can start your server and check if it work fine.
|
|
59
|
+
|
|
60
|
+
> Note: Ts.ED will print the swagger url in the console.
|
|
61
|
+
|
|
62
|
+
### Swagger options
|
|
63
|
+
|
|
64
|
+
Some options is available to configure Swagger-ui, Ts.ED and the default spec information.
|
|
65
|
+
|
|
66
|
+
| Key | Example | Description |
|
|
67
|
+
| -------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| path | `/api-doc` | The url subpath to access to the documentation. |
|
|
69
|
+
| specVersion | `3.0.1` | The spec version. |
|
|
70
|
+
| doc | `hidden-doc` | The documentation key used by `@Docs` decorator to create several swagger documentations. |
|
|
71
|
+
| cssPath | `${rootDir}/spec/style.css` | The path to the CSS file. |
|
|
72
|
+
| spec | `{"openapi": "3.0.1"}` | The default information spec. |
|
|
73
|
+
| hidden | `true` | Hide the documentation in the dropdown explorer list. |
|
|
74
|
+
| options | Scalar options | SwaggerUI options. See (https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md) |
|
|
75
|
+
| operationIdFormatter | `(name: string, propertyKey: string, path: string) => string` | A function to generate the operationId. |
|
|
76
|
+
| operationIdPattern | `%c_%m` | A pattern to generate the operationId. Format of operationId field (%c: class name, %m: method name). |
|
|
77
|
+
|
|
78
|
+
### Multi documentations
|
|
79
|
+
|
|
80
|
+
It also possible to create several swagger documentations with `doc` option:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import {Configuration} from "@tsed/di";
|
|
84
|
+
import "@tsed/scalar"; // import swagger Ts.ED module
|
|
85
|
+
|
|
86
|
+
@Configuration({
|
|
87
|
+
scalar: [
|
|
88
|
+
{
|
|
89
|
+
path: "/api-docs-v1",
|
|
90
|
+
doc: "api-v1"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
path: "/api-docs-v2",
|
|
94
|
+
doc: "api-v2"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
export class Server {}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Then use `@Docs` decorators on your controllers to specify where the controllers should be displayed.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import {Controller} from "@tsed/di";
|
|
105
|
+
import {Docs} from "@tsed/swagger";
|
|
106
|
+
|
|
107
|
+
@Controller("/calendars")
|
|
108
|
+
@Docs("api-v2") // display this controllers only for api-docs-v2
|
|
109
|
+
export class CalendarCtrlV2 {}
|
|
110
|
+
// OR
|
|
111
|
+
@Controller("/calendars")
|
|
112
|
+
@Docs("api-v2", "api-v1") // display this controllers for api-docs-v2 and api-docs-v1
|
|
113
|
+
export class CalendarCtrl {}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Examples
|
|
117
|
+
|
|
118
|
+
#### Model documentation
|
|
119
|
+
|
|
120
|
+
One of the feature of Ts.ED is the model definition to serialize or deserialize a
|
|
121
|
+
JSON Object (see [converters section](https://tsed.io/docs/components/converters.html)).
|
|
122
|
+
|
|
123
|
+
This model can used on a method controller along with [@BodyParams](https://tsed.io/api/common/filters/decorators/BodyParams.html) or other decorators.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import {JsonProperty, Title, Description, Example} from "@tsed/schema";
|
|
127
|
+
|
|
128
|
+
export class CalendarModel {
|
|
129
|
+
@Title("iD")
|
|
130
|
+
@Description("Description of calendar model id")
|
|
131
|
+
@Example("Example value")
|
|
132
|
+
@JsonProperty()
|
|
133
|
+
public id: string;
|
|
134
|
+
|
|
135
|
+
@JsonProperty()
|
|
136
|
+
public name: string;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Endpoint documentation
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import {Controller} from "@tsed/di";
|
|
144
|
+
import {BodyParams, QueryParams} from "@tsed/platform-params";
|
|
145
|
+
import {Get, Post, Returns, ReturnsArray, Description, Summary, Deprecated, Security} from "@tsed/schema";
|
|
146
|
+
import {CalendarModel} from "../models/CalendarModel.js";
|
|
147
|
+
|
|
148
|
+
@Controller("/calendars")
|
|
149
|
+
export class Calendar {
|
|
150
|
+
@Get("/:id")
|
|
151
|
+
@Summary("Summary of this route")
|
|
152
|
+
@Description("Description of this route")
|
|
153
|
+
@Returns(CalendarModel)
|
|
154
|
+
@Returns(404, {description: "Not found"})
|
|
155
|
+
async getCalendar(@QueryParams("id") id: string): Promise<CalendarModel> {
|
|
156
|
+
//...
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@Get("/v0/:id")
|
|
160
|
+
@Deprecated()
|
|
161
|
+
@Description("Deprecated route, use /rest/calendars/:id instead of.")
|
|
162
|
+
@Returns(CalendarModel)
|
|
163
|
+
@Returns(404, {description: "Not found"})
|
|
164
|
+
getCalendarDeprecated(@QueryParams("id") id: string): Promise<CalendarModel> {
|
|
165
|
+
//...
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@Get("/")
|
|
169
|
+
@Description("Description of this route")
|
|
170
|
+
@ReturnsArray(CalendarModel)
|
|
171
|
+
getCalendars(): Promise<CalendarModel[]> {
|
|
172
|
+
// ...
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@Post("/")
|
|
176
|
+
@Security("calendar_auth", "write:calendar", "read:calendar")
|
|
177
|
+
@Returns(CalendarModel)
|
|
178
|
+
async createCalendar(@BodyParams() body: any): Promise<CalendarModel> {
|
|
179
|
+
//...
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Documentation
|
|
185
|
+
|
|
186
|
+
See our documentation https://tsed.io/#/api/index
|
|
187
|
+
|
|
188
|
+
## Contributors
|
|
189
|
+
|
|
190
|
+
Please read [contributing guidelines here](https://tsed.io/contributing.html).
|
|
191
|
+
|
|
192
|
+
<a href="https://github.com/tsedio/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
193
|
+
|
|
194
|
+
## Backers
|
|
195
|
+
|
|
196
|
+
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
197
|
+
|
|
198
|
+
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
|
|
199
|
+
|
|
200
|
+
## Sponsors
|
|
201
|
+
|
|
202
|
+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
The MIT License (MIT)
|
|
207
|
+
|
|
208
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
209
|
+
|
|
210
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
211
|
+
|
|
212
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
213
|
+
|
|
214
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {logger} from "@tsed/di";
|
|
2
|
+
import {application} from "@tsed/platform-http";
|
|
3
|
+
import {PlatformTest} from "@tsed/platform-http/testing";
|
|
4
|
+
import {PlatformRouter} from "@tsed/platform-router";
|
|
5
|
+
|
|
6
|
+
import {ScalarModule} from "./ScalarModule.js";
|
|
7
|
+
|
|
8
|
+
vi.mock("node:fs/promises");
|
|
9
|
+
|
|
10
|
+
describe("SwaggerModule", () => {
|
|
11
|
+
beforeEach(() =>
|
|
12
|
+
PlatformTest.create({
|
|
13
|
+
httpPort: 8080,
|
|
14
|
+
httpsPort: 8081,
|
|
15
|
+
scalar: [
|
|
16
|
+
{
|
|
17
|
+
path: "/doc",
|
|
18
|
+
cssPath: "/cssPath/style.css",
|
|
19
|
+
jsPath: "/jsPath/script.js",
|
|
20
|
+
viewPath: "/viewsPath",
|
|
21
|
+
outFile: "/openapi.json"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
afterEach(PlatformTest.reset);
|
|
27
|
+
|
|
28
|
+
describe("$onRoutesInit", () => {
|
|
29
|
+
it("should add middlewares", async () => {
|
|
30
|
+
const mod = await PlatformTest.invoke<ScalarModule>(ScalarModule);
|
|
31
|
+
|
|
32
|
+
vi.spyOn(application(), "get").mockReturnValue(undefined as never);
|
|
33
|
+
vi.spyOn(application(), "use").mockReturnValue(undefined as never);
|
|
34
|
+
vi.spyOn(PlatformRouter.prototype as any, "get").mockReturnValue(undefined);
|
|
35
|
+
vi.spyOn(PlatformRouter.prototype as any, "statics").mockReturnValue(undefined);
|
|
36
|
+
|
|
37
|
+
mod.$onRoutesInit();
|
|
38
|
+
mod.$onRoutesInit();
|
|
39
|
+
|
|
40
|
+
expect(application().use).toHaveBeenCalledWith("/doc", expect.any(Function));
|
|
41
|
+
expect(application().use).toHaveBeenCalledWith("/doc", expect.any(PlatformRouter));
|
|
42
|
+
expect(PlatformRouter.prototype.get).toHaveBeenCalledWith("/openapi.json", expect.any(Function));
|
|
43
|
+
expect(PlatformRouter.prototype.get).toHaveBeenCalledWith("/style.css", expect.any(Function));
|
|
44
|
+
expect(PlatformRouter.prototype.get).toHaveBeenCalledWith("/script.js", expect.any(Function));
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("$onReady", () => {
|
|
49
|
+
it("should display the right log", async () => {
|
|
50
|
+
const mod = await PlatformTest.invoke<ScalarModule>(ScalarModule);
|
|
51
|
+
|
|
52
|
+
vi.spyOn(logger(), "info");
|
|
53
|
+
|
|
54
|
+
mod.$onReady();
|
|
55
|
+
|
|
56
|
+
expect(logger().info).toHaveBeenCalledWith("[default] OpenAPI JSON is available on https://0.0.0.0:8081/doc/openapi.json");
|
|
57
|
+
expect(logger().info).toHaveBeenCalledWith("[default] Scalar UI is available on https://0.0.0.0:8081/doc/");
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {join} from "node:path";
|
|
2
|
+
|
|
3
|
+
import {constant, injectable, ProviderType} from "@tsed/di";
|
|
4
|
+
import {OpenAPIBaseModule} from "@tsed/openapi-utils";
|
|
5
|
+
import {useContextHandler} from "@tsed/platform-router";
|
|
6
|
+
|
|
7
|
+
import {ROOT_DIR} from "./constants.js";
|
|
8
|
+
import {ScalarSettings} from "./interfaces/ScalarSettings.js";
|
|
9
|
+
import {indexMiddleware} from "./middlewares/indexMiddleware.js";
|
|
10
|
+
|
|
11
|
+
export class ScalarModule extends OpenAPIBaseModule {
|
|
12
|
+
readonly name = "Scalar";
|
|
13
|
+
readonly rootDir = ROOT_DIR;
|
|
14
|
+
|
|
15
|
+
get settings() {
|
|
16
|
+
const settings = constant<ScalarSettings[]>("scalar", []).filter((o) => !!o);
|
|
17
|
+
|
|
18
|
+
return settings.map((conf) => {
|
|
19
|
+
return Object.assign(
|
|
20
|
+
{
|
|
21
|
+
disableSpec: false,
|
|
22
|
+
_integration: "tsed",
|
|
23
|
+
cdn: "https://cdn.jsdelivr.net/npm/@scalar/api-reference",
|
|
24
|
+
path: "/",
|
|
25
|
+
fileName: "openapi.json",
|
|
26
|
+
cssPath: join(ROOT_DIR, "views/assets/scalar.css"),
|
|
27
|
+
viewPath: join(ROOT_DIR, "views/scalar.ejs")
|
|
28
|
+
},
|
|
29
|
+
conf
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected createRouter(conf: ScalarSettings) {
|
|
35
|
+
const {viewPath} = conf;
|
|
36
|
+
const router = super.createRouter(conf);
|
|
37
|
+
|
|
38
|
+
if (viewPath) {
|
|
39
|
+
router.get("/", useContextHandler(indexMiddleware(viewPath, conf)));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return router;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
injectable(ScalarModule).type(ProviderType.MODULE);
|
package/src/constants.ts
ADDED
package/src/exports.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Docs} from "@tsed/openapi-utils";
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import type {ReferenceConfiguration} from "@scalar/types/legacy";
|
|
3
|
+
import type {OpenApiSettings} from "@tsed/openapi-utils";
|
|
4
|
+
|
|
5
|
+
export type ScalarSettings = OpenApiSettings &
|
|
6
|
+
ReferenceConfiguration & {
|
|
7
|
+
cdn?: string;
|
|
8
|
+
options?: ReferenceConfiguration;
|
|
9
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {basename} from "node:path";
|
|
2
|
+
|
|
3
|
+
import {context} from "@tsed/di";
|
|
4
|
+
import {join} from "path";
|
|
5
|
+
|
|
6
|
+
import {ScalarSettings} from "../interfaces/ScalarSettings.js";
|
|
7
|
+
|
|
8
|
+
export function indexMiddleware(viewPath: string, conf: ScalarSettings) {
|
|
9
|
+
return async () => {
|
|
10
|
+
const ctx = context();
|
|
11
|
+
const {path, options = {}, cssPath, cdn, fileName} = conf;
|
|
12
|
+
|
|
13
|
+
const opts = {
|
|
14
|
+
_integration: "tsed",
|
|
15
|
+
spec: {
|
|
16
|
+
url: `${path}/${fileName}`
|
|
17
|
+
},
|
|
18
|
+
...options
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
ctx.response.body(
|
|
22
|
+
await ctx.response.render(viewPath, {
|
|
23
|
+
cssPath: join(path, basename(cssPath)),
|
|
24
|
+
cdn,
|
|
25
|
+
serializedOptions: JSON.stringify(opts).split('"').join("""),
|
|
26
|
+
options: opts
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* basic theme */
|
|
2
|
+
.light-mode {
|
|
3
|
+
--scalar-color-1: #353535;
|
|
4
|
+
--scalar-color-2: #555555;
|
|
5
|
+
--scalar-color-3: #aeaeae;
|
|
6
|
+
--scalar-color-accent: #259dff;
|
|
7
|
+
|
|
8
|
+
--scalar-background-1: #fff;
|
|
9
|
+
--scalar-background-2: #f7f7f7;
|
|
10
|
+
--scalar-background-3: #dadada;
|
|
11
|
+
--scalar-background-accent: #E0F5FF;
|
|
12
|
+
|
|
13
|
+
--scalar-border-color: rgba(0, 0, 0, 0.1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.dark-mode {
|
|
17
|
+
--scalar-color-1: rgba(255, 255, 255, 0.9);
|
|
18
|
+
--scalar-color-2: rgba(255, 255, 255, 0.62);
|
|
19
|
+
--scalar-color-3: rgba(255, 255, 255, 0.44);
|
|
20
|
+
--scalar-color-accent: #8ab4f8;
|
|
21
|
+
|
|
22
|
+
--scalar-background-1: #1a1a1a;
|
|
23
|
+
--scalar-background-2: #252525;
|
|
24
|
+
--scalar-background-3: #323232;
|
|
25
|
+
--scalar-background-accent: #8ab4f81f;
|
|
26
|
+
|
|
27
|
+
--scalar-border-color: rgba(255, 255, 255, 0.1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Document Sidebar */
|
|
31
|
+
.light-mode .t-doc__sidebar {
|
|
32
|
+
--scalar-sidebar-background-1: var(--scalar-background-1);
|
|
33
|
+
--scalar-sidebar-item-hover-color: currentColor;
|
|
34
|
+
--scalar-sidebar-item-hover-background: var(--scalar-background-2);
|
|
35
|
+
--scalar-sidebar-item-active-background: var(--scalar-background-accent);
|
|
36
|
+
--scalar-sidebar-border-color: var(--scalar-border-color);
|
|
37
|
+
--scalar-sidebar-color-1: var(--scalar-color-1);
|
|
38
|
+
--scalar-sidebar-color-2: var(--scalar-color-2);
|
|
39
|
+
--scalar-sidebar-color-active: var(--scalar-color-accent);
|
|
40
|
+
--scalar-sidebar-search-background: transparent;
|
|
41
|
+
--scalar-sidebar-search-border-color: var(--scalar-border-color);
|
|
42
|
+
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.dark-mode .sidebar {
|
|
46
|
+
--scalar-sidebar-background-1: var(--scalar-background-1);
|
|
47
|
+
--scalar-sidebar-item-hover-color: currentColor;
|
|
48
|
+
--scalar-sidebar-item-hover-background: var(--scalar-background-2);
|
|
49
|
+
--scalar-sidebar-item-active-background: var(--scalar-background-accent);
|
|
50
|
+
--scalar-sidebar-border-color: var(--scalar-border-color);
|
|
51
|
+
--scalar-sidebar-color-1: var(--scalar-color-1);
|
|
52
|
+
--scalar-sidebar-color-2: var(--scalar-color-2);
|
|
53
|
+
--scalar-sidebar-color-active: var(--scalar-color-accent);
|
|
54
|
+
--scalar-sidebar-search-background: transparent;
|
|
55
|
+
--scalar-sidebar-search-border-color: var(--scalar-border-color);
|
|
56
|
+
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* advanced */
|
|
60
|
+
.light-mode {
|
|
61
|
+
--scalar-button-1: rgb(49 53 56);
|
|
62
|
+
--scalar-button-1-color: #fff;
|
|
63
|
+
--scalar-button-1-hover: rgb(28 31 33);
|
|
64
|
+
|
|
65
|
+
--scalar-color-green: #669900;
|
|
66
|
+
--scalar-color-red: #dc4a68;
|
|
67
|
+
--scalar-color-yellow: #edbe20;
|
|
68
|
+
--scalar-color-blue: #0277aa;
|
|
69
|
+
--scalar-color-orange: #fb892c;
|
|
70
|
+
--scalar-color-purple: #5203d1;
|
|
71
|
+
|
|
72
|
+
--scalar-scrollbar-color: rgba(0, 0, 0, 0.18);
|
|
73
|
+
--scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.dark-mode {
|
|
77
|
+
--scalar-button-1: #f6f6f6;
|
|
78
|
+
--scalar-button-1-color: #000;
|
|
79
|
+
--scalar-button-1-hover: #e7e7e7;
|
|
80
|
+
|
|
81
|
+
--scalar-color-green: #00b648;
|
|
82
|
+
--scalar-color-red: #dc1b19;
|
|
83
|
+
--scalar-color-yellow: #ffc90d;
|
|
84
|
+
--scalar-color-blue: #4eb3ec;
|
|
85
|
+
--scalar-color-orange: #ff8d4d;
|
|
86
|
+
--scalar-color-purple: #b191f9;
|
|
87
|
+
|
|
88
|
+
--scalar-scrollbar-color: rgba(255, 255, 255, 0.24);
|
|
89
|
+
--scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:root {
|
|
93
|
+
--scalar-radius: 3px;
|
|
94
|
+
--scalar-radius-lg: 3px;
|
|
95
|
+
--scalar-radius-xl: 3px;
|
|
96
|
+
}
|
package/views/scalar.ejs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Scalar API Reference</title>
|
|
5
|
+
<meta charset="utf-8"/>
|
|
6
|
+
<meta
|
|
7
|
+
name="viewport"
|
|
8
|
+
content="width=device-width, initial-scale=1"/>
|
|
9
|
+
<link>
|
|
10
|
+
<link rel="stylesheet" href="<%= cssPath %>" />
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<script
|
|
14
|
+
id="api-reference"
|
|
15
|
+
type="application/json"
|
|
16
|
+
data-configuration="<%= serializedOptions %>"></script>
|
|
17
|
+
<script src="<%= cdn %>"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -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
|
+
);
|