import { Router } from "express";
import swaggerUi from "swagger-ui-express";
import { swaggerSpec } from "../config/swagger";
/**
* Swagger documentation routes
* @category Routes
*/
const router = Router();
/**
* Serve Swagger UI
* GET /api-docs
* This endpoint is accessible without authentication
*/
router.use("/", swaggerUi.serve);
router.get("/", swaggerUi.setup(swaggerSpec, {
customCss: ".swagger-ui .topbar { display: none }",
customSiteTitle: "K12 Backend Core API Documentation",
}));
/**
* Serve Swagger JSON spec
* GET /api-docs/json
* This endpoint returns the raw OpenAPI specification
*/
router.get("/json", (_req, res) => {
res.setHeader("Content-Type", "application/json");
res.send(swaggerSpec);
});
export { router as swaggerRoutes };
Source