feat(medusa-oas-cli,oas-github-ci): new options + added download of OAS in api reference (#5453)

This commit is contained in:
Shahed Nasser
2023-10-31 09:05:48 +02:00
committed by GitHub
parent 03959c3e3a
commit c1b97050ab
9 changed files with 50130 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
import { existsSync, readFileSync } from "fs"
import { NextResponse } from "next/server"
import path from "path"
type DownloadParams = {
params: {
area: string
}
}
export function GET(request: Request, { params }: DownloadParams) {
const { area } = params
const filePath = path.join(process.cwd(), `specs/${area}/openapi.full.yaml`)
if (!existsSync(filePath)) {
return new NextResponse(null, {
status: 404,
})
}
const fileContent = readFileSync(filePath)
return new Response(fileContent, {
headers: {
"Content-Type": "application/x-yaml",
"Content-Disposition": `attachment; filename="openapi.yaml"`,
},
})
}