From 12496167dd10f0c37da637c5ae3de7b6389db34f Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 22 Jan 2025 11:06:07 -0500 Subject: [PATCH] Adding redoc / tsoa generated API docs. --- .gitmodules | 2 +- Dockerfile | 8 +++++--- lemmy-js-client | 2 +- src/server/index.tsx | 6 +++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9a2adb9..f69f383 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,7 +13,7 @@ [submodule "lemmy-js-client"] path = lemmy-js-client url = https://github.com/LemmyNet/lemmy-js-client - branch = release/v0.19 + branch = tsoa_1 [submodule "lemmy-stats-crawler"] path = lemmy-stats-crawler url = https://github.com/LemmyNet/lemmy-stats-crawler.git diff --git a/Dockerfile b/Dockerfile index 611bb3d..be6c493 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN tar -xzf mdbook.tar.gz COPY lemmy-docs ./lemmy-docs RUN ./mdbook build lemmy-docs -d ../docs -# Build the typedoc API docs +# Build the typedoc lemmy-js-client docs, and swagger.json FROM node:20-alpine AS api WORKDIR /app COPY lemmy-js-client lemmy-js-client @@ -22,6 +22,7 @@ WORKDIR /app/lemmy-js-client RUN corepack enable pnpm RUN pnpm i RUN pnpm run docs +RUN pnpm tsoa # Build the isomorphic app FROM node:20-alpine AS builder @@ -48,9 +49,10 @@ COPY joinlemmy-translations joinlemmy-translations COPY lemmy-translations lemmy-translations COPY src src -# Copy the docs and API +# Copy the rust docs, lemmy-js-client docs, and OpenAPI docs. COPY --from=docs /app/docs ./src/assets/docs -COPY --from=api /app/lemmy-js-client/docs ./src/assets/api +COPY --from=api /app/lemmy-js-client/docs ./src/assets/lemmy-js-client-docs +COPY --from=api /app/lemmy-js-client/redoc-static.html ./src/assets/api.html RUN pnpm i RUN pnpm prebuild:prod diff --git a/lemmy-js-client b/lemmy-js-client index 5b3c7eb..2b7ef3d 160000 --- a/lemmy-js-client +++ b/lemmy-js-client @@ -1 +1 @@ -Subproject commit 5b3c7ebcfa7bc9598254999b72b9ec89007bd51e +Subproject commit 2b7ef3dc1c82ddcebbae3b9247cfd76166a61f80 diff --git a/src/server/index.tsx b/src/server/index.tsx index d8649ed..5ccfdde 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -26,7 +26,11 @@ server.use(express.json() as RequestHandler); server.use(express.urlencoded({ extended: false }) as RequestHandler); server.use("/static", express.static(path.resolve("./dist"))); server.use("/docs", express.static(path.resolve("./dist/assets/docs"))); -server.use("/api", express.static(path.resolve("./dist/assets/api"))); +server.use("/api", express.static(path.resolve("./dist/assets/api.html"))); +server.use( + "/lemmy-js-client-docs", + express.static(path.resolve("./dist/assets/lemmy-js-client-docs")), +); server.use( "/context.json", cors,