|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import React, { useState, useEffect } from "react"; |
| 4 | +import dynamic from "next/dynamic"; |
| 5 | +import CircularProgress from "@mui/material/CircularProgress"; |
| 6 | +import "swagger-ui-react/swagger-ui.css"; |
| 7 | + |
| 8 | +const SwaggerUI = dynamic(() => import("swagger-ui-react"), { ssr: false }); |
| 9 | + |
| 10 | +type SwaggerSpec = typeof import("../api/swagger").default; |
| 11 | + |
| 12 | +export default function SwaggerPage() { |
| 13 | + const [swaggerSpec, setSwaggerSpec] = useState<SwaggerSpec | null>(null); |
| 14 | + |
| 15 | + useEffect(() => { |
| 16 | + import("../api/swagger").then((module) => { |
| 17 | + setSwaggerSpec(module.default); |
| 18 | + }); |
| 19 | + }, []); |
| 20 | + |
| 21 | + if (!swaggerSpec) { |
| 22 | + return ( |
| 23 | + <div |
| 24 | + style={{ |
| 25 | + display: "flex", |
| 26 | + justifyContent: "center", |
| 27 | + alignItems: "center", |
| 28 | + height: "100vh", |
| 29 | + backgroundColor: "#ffffff", |
| 30 | + }} |
| 31 | + > |
| 32 | + <CircularProgress /> |
| 33 | + </div> |
| 34 | + ); |
| 35 | + } |
| 36 | + |
| 37 | + return ( |
| 38 | + <div |
| 39 | + style={{ |
| 40 | + height: "100vh", |
| 41 | + backgroundColor: "#ffffff", |
| 42 | + padding: "20px", |
| 43 | + }} |
| 44 | + > |
| 45 | + <style> |
| 46 | + {` |
| 47 | + /* Set all Swagger UI backgrounds to white */ |
| 48 | + .swagger-ui, |
| 49 | + .swagger-ui .topbar, |
| 50 | + .swagger-ui .opblock-section-header, |
| 51 | + .swagger-ui .model-box, |
| 52 | + .swagger-ui .model { |
| 53 | + background-color: #ffffff !important; |
| 54 | + } |
| 55 | +
|
| 56 | + /* Remove border shadows for cleaner design */ |
| 57 | + .swagger-ui .opblock { |
| 58 | + box-shadow: none !important; |
| 59 | + } |
| 60 | +
|
| 61 | + /* Ensure text colors remain visible */ |
| 62 | + .swagger-ui .opblock-summary { |
| 63 | + color: #fff !important; |
| 64 | + } |
| 65 | + `} |
| 66 | + </style> |
| 67 | + <SwaggerUI spec={swaggerSpec} /> |
| 68 | + </div> |
| 69 | + ); |
| 70 | +} |
0 commit comments