Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: generate swagger.json on build (#293)

authored by

Maximilian Kaske and committed by
GitHub
380c3e32 466c3bdb

+26 -35
+3
apps/api/.gitignore
··· 33 33 # typescript 34 34 *.tsbuildinfo 35 35 next-env.d.ts 36 + 37 + # generated on build time 38 + /public/swagger.json
+19
apps/api/next-swagger-doc.json
··· 1 + { 2 + "apiFolder": "src/app", 3 + "definition": { 4 + "openapi": "3.0.0", 5 + "info": { 6 + "title": "OpenStatus API", 7 + "version": "1.0" 8 + }, 9 + "components": { 10 + "securitySchemes": { 11 + "ApiKeyAuth": { 12 + "type": "apiKey", 13 + "name": "x-openstatus-key" 14 + } 15 + } 16 + }, 17 + "security": [{ "ApiKeyAuth": [] }] 18 + } 19 + }
+3 -2
apps/api/package.json
··· 4 4 "private": true, 5 5 "scripts": { 6 6 "dev": "next dev", 7 - "build": "next build", 7 + "build": "pnpm gen:swagger && next build", 8 8 "start": "next start", 9 - "lint": "next lint" 9 + "lint": "next lint", 10 + "gen:swagger": "next-swagger-doc-cli next-swagger-doc.json" 10 11 }, 11 12 "dependencies": { 12 13 "@openstatus/db": "workspace:^",
apps/api/public/.gitkeep

This is a binary file and will not be displayed.

-8
apps/api/src/app/openapi/route.ts
··· 1 - import { getApiDocs } from "@/lib/swagger"; 2 - 3 - export const dynamic = "force-dynamic"; 4 - 5 - export async function GET(_: Request) { 6 - const data = await getApiDocs(); 7 - return new Response(JSON.stringify(data), { status: 200 }); 8 - }
-24
apps/api/src/lib/swagger.ts
··· 1 - import { createSwaggerSpec } from "next-swagger-doc"; 2 - 3 - export const getApiDocs = async () => { 4 - const spec = createSwaggerSpec({ 5 - apiFolder: "src/app/v1", 6 - definition: { 7 - openapi: "3.0.0", 8 - info: { 9 - title: "OpenStatus API", 10 - version: "1.0", 11 - }, 12 - components: { 13 - securitySchemes: { 14 - ApiKeyAuth: { 15 - type: "apiKey", 16 - name: "x-openstatus-key", 17 - }, 18 - }, 19 - }, 20 - security: [{ ApiKeyAuth: [] }], 21 - }, 22 - }); 23 - return spec; 24 - };
+1 -1
apps/docs/pages/rest-api/openapi.mdx
··· 3 3 import { useData } from "nextra/data"; 4 4 5 5 export const getStaticProps = async ({ params }) => { 6 - const res = await fetch("https://api.openstatus.dev/openapi"); 6 + const res = await fetch("https://api.openstatus.dev/swagger.json"); 7 7 const spec = await res.json(); 8 8 return { 9 9 props: {