feat(medusa-oas-cli,oas-github-ci): new options + added download of OAS in api reference (#5453)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { CodeTabs } from "docs-ui"
|
||||
import Space from "@/components/Space"
|
||||
import DownloadFull from "@/components/DownloadFull"
|
||||
|
||||
### Just Getting Started?
|
||||
|
||||
@@ -28,4 +29,10 @@ Check out the [quickstart guide](https://docs.medusajs.com/create-medusa-app).
|
||||
}
|
||||
}
|
||||
]}
|
||||
/>
|
||||
/>
|
||||
|
||||
### Download Full Reference
|
||||
|
||||
Download this reference as an OpenApi YAML file. You can import this file to tools like Postman and start sending requests directly to your Medusa backend.
|
||||
|
||||
<DownloadFull />
|
||||
@@ -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"`,
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user