import { createSwaggerSpec } from "next-swagger-doc"; import dynamic from "next/dynamic"; import "swagger-ui-react/swagger-ui.css"; const SwaggerUI = dynamic(import("swagger-ui-react"), { ssr: false }); function ApiDoc({ spec }) { return ; } let BASE_URL; const port = parseInt(process.env.PORT, 10) || 3000; if (process.browser) { BASE_URL = window.apiRoot; } else { BASE_URL = process.env.API_ROOT || `http://localhost:${port}`; } const WORDKEY = process.env.HASHKEY; const cache = {}; const API_PATH = "/api/data/v8.2/"; const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT; const tenantId = process.env.TENANT; export const getStaticProps = async () => { const spec = createSwaggerSpec({ layout: "StandaloneLayout", apiFolder: "pages/api", schemaFolders: ["models"], definition: { openapi: "3.0.3", info: { title: "PEDW API", version: "1.0", contact: { email: "rob@rdbsolutions.co.uk", }, }, docExpansion: "none", components: { schemas: { emailBody: { type: "object", properties: { reference: { type: "string", example: "PEDW-COMPLETE", }, templateId: { type: "string", example: "618e0463-b092-4733-a024-bf8a3bbde808", }, emailAddress: { type: "string", example: "rob@rdbtech.co.uk", }, personalisation: { type: "object", example: { caseReference: "CAS-TEST-TEST", emailAddress: "rob@rdbtech.co.uk", linkExpiry: "10 * 60", }, }, }, }, }, // securitySchemes: { // pedw_auth: { // type: "oauth2", // flows: { // clientCredentials: { // tokenUrl: `${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`, // scopes: // "https://" + // process.env.RELAYURI + // "/.default", // }, // }, // }, // api_key: { // type: "apiKey", // name: "api_key", // in: "header", // }, // }, }, }, }); //console.log(JSON.stringify(spec)); return { props: { spec, }, }; }; export default ApiDoc;