Skip to content

Commit 51ecbd5

Browse files
committed
Add dark swagger docs
1 parent 45ef0d9 commit 51ecbd5

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

backend/api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"build": "yarn compile && yarn dist:clean && yarn dist:copy",
1212
"build:fast": "yarn compile && yarn dist:copy",
1313
"clean": "rm -rf lib && (cd ../../common && rm -rf lib) && (cd ../shared && rm -rf lib) && (cd ../email && rm -rf lib)",
14-
"compile": "tsc -b && tsc-alias && (cd ../../common && tsc-alias) && (cd ../shared && tsc-alias) && (cd ../email && tsc-alias)",
14+
"compile": "tsc -b && tsc-alias && (cd ../../common && tsc-alias) && (cd ../shared && tsc-alias) && (cd ../email && tsc-alias) && cp -r src/public/ lib/",
1515
"debug": "nodemon -r tsconfig-paths/register --watch src -e ts --watch ../../common/src --watch ../shared/src --exec \"yarn build && node --inspect-brk src/serve.ts\"",
1616
"dist": "yarn dist:clean && yarn dist:copy",
1717
"dist:clean": "rm -rf dist && mkdir -p dist/common/lib dist/backend/shared/lib dist/backend/api/lib dist/backend/email/lib",
18-
"dist:copy": "rsync -a --delete ../../common/lib/ dist/common/lib && rsync -a --delete ../shared/lib/ dist/backend/shared/lib && rsync -a --delete ../email/lib/ dist/backend/email/lib && rsync -a --delete ./lib/* dist/backend/api/lib && cp ../../yarn.lock dist && cp package.json dist && cp package.json dist/backend/api",
18+
"dist:copy": "rsync -a --delete ../../common/lib/ dist/common/lib && rsync -a --delete ../shared/lib/ dist/backend/shared/lib && rsync -a --delete ../email/lib/ dist/backend/email/lib && rsync -a --delete ./lib/* dist/backend/api/lib && cp ../../yarn.lock dist && cp package.json dist && cp package.json dist/backend/api",
1919
"watch": "tsc -w",
2020
"verify": "yarn --cwd=../.. verify",
2121
"verify:dir": "npx eslint . --max-warnings 0",

backend/api/src/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import {z, ZodFirstPartyTypeKind, ZodTypeAny} from "zod";
6767
import {getUser} from "api/get-user";
6868
import {IS_LOCAL} from "common/envs/constants";
6969
import {localSendTestEmail} from "api/test";
70+
import path from "node:path";
7071

7172
// const corsOptions: CorsOptions = {
7273
// origin: ['*'], // Only allow requests from this domain
@@ -500,10 +501,13 @@ app.get(
500501
rootPath,
501502
swaggerUi.setup(swaggerDocument, {
502503
customSiteTitle: 'Compass API Docs',
504+
customCssUrl: '/swagger.css',
503505
}),
504506
)
505507
app.use(rootPath, swaggerUi.serve)
506508

509+
app.use(express.static(path.join(__dirname, 'public')));
510+
507511
app.use(allowCorsUnrestricted, (req, res) => {
508512
if (req.method === 'OPTIONS') {
509513
res.status(200).send()

backend/api/src/public/swagger.css

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@media (prefers-color-scheme: dark) {
2+
body {
3+
background-color: #1e1e1e !important;
4+
color: #ffffff !important;
5+
}
6+
.swagger-ui p,
7+
h1,
8+
h2,
9+
h3,
10+
h4,
11+
h5,
12+
h6,
13+
label,
14+
.btn,
15+
.parameter__name,
16+
.parameter__type,
17+
.parameter__in,
18+
.response-control-media-type__title,
19+
table thead tr td,
20+
table thead tr th,
21+
.tab li,
22+
.response-col_links,
23+
.opblock-summary-description {
24+
color: #ffffff !important;
25+
}
26+
.swagger-ui .topbar, .opblock-body select, textarea {
27+
background-color: #2b2b2b !important;
28+
color: #ffffff !important;
29+
}
30+
.swagger-ui .opblock {
31+
background-color: #2c2c2c !important;
32+
border-color: #fff !important;
33+
}
34+
.swagger-ui .opblock .opblock-summary-method {
35+
background-color: #1f1f1f !important;
36+
color: #fff !important;
37+
}
38+
.swagger-ui .opblock .opblock-section-header {
39+
background: #1f1f1f !important;
40+
color: #fff !important;
41+
}
42+
.swagger-ui .responses-wrapper {
43+
background-color: #1f1f1f !important;
44+
}
45+
.swagger-ui .response-col_status {
46+
color: #fff !important;
47+
}
48+
.swagger-ui .scheme-container {
49+
background-color: #1f1f1f !important;
50+
}
51+
.swagger-ui .modal-ux, input {
52+
background-color: #1f1f1f !important;
53+
color: #fff !important;
54+
}
55+
.swagger-ui svg path {
56+
fill: white !important;
57+
}
58+
.swagger-ui .close-modal svg {
59+
color: #1e90ff !important;
60+
}
61+
a {
62+
color: #1e90ff !important;
63+
}
64+
}

0 commit comments

Comments
 (0)