Skip to content

Commit

Permalink
feat: implement openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw committed Aug 25, 2024
1 parent a3520e4 commit 482c490
Show file tree
Hide file tree
Showing 17 changed files with 14,987 additions and 638 deletions.
2 changes: 2 additions & 0 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"react-simple-code-editor": "^0.14.1",
"sass": "^1.77.8",
"superjson": "2.2.1",
"swagger-ui-react": "^5.17.7",
"use-deep-compare-effect": "^1.8.1"
},
"devDependencies": {
Expand All @@ -78,6 +79,7 @@
"@types/prismjs": "^1.26.4",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"@types/swagger-ui-react": "^4.18.3",
"concurrently": "^8.2.2",
"eslint": "^9.9.1",
"node-loader": "^2.0.0",
Expand Down
5 changes: 5 additions & 0 deletions apps/nextjs/src/app/[locale]/manage/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export default async function ManageLayout({ children }: PropsWithChildren) {
icon: IconBrandDocker,
href: "/manage/tools/docker",
},
{
label: t("items.tools.items.api"),
icon: IconPlug,
href: "/manage/tools/api",
},
{
label: t("items.tools.items.logs"),
icon: IconLogs,
Expand Down
28 changes: 28 additions & 0 deletions apps/nextjs/src/app/[locale]/manage/tools/api/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { getScopedI18n } from "@homarr/translation/server";

// workaround for CSS that cannot be processed by next.js, https://github.com/swagger-api/swagger-ui/issues/10045
import "./swagger-ui-dark.css";
import "./swagger-ui-overrides.css";
import "./swagger-ui.css";

import { headers } from "next/headers";
import SwaggerUI from "swagger-ui-react";

import { openApiDocument } from "@homarr/api";
import { extractBaseUrlFromHeaders } from "@homarr/common";

import { createMetaTitle } from "~/metadata";

export async function generateMetadata() {
const t = await getScopedI18n("management");

return {
title: createMetaTitle(t("metaTitle")),
};
}

export default function ApiPage() {
const document = openApiDocument(extractBaseUrlFromHeaders(headers()));

return <SwaggerUI spec={document} />;
}
Loading

0 comments on commit 482c490

Please sign in to comment.