fix(medusa-oas-cli): fix tool not working in Medusa backends (#6812)

* fix(medusa-oas-cli): fix tool not working in custom projects

* fix changeset message

---------

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
Shahed Nasser
2024-03-26 09:33:06 +02:00
committed by GitHub
parent 509ddf9a56
commit e005987adf
6 changed files with 263 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
import { existsSync, readFileSync } from "fs"
import { NextResponse } from "next/server"
import path from "path"
import { Version } from "../../../../types/openapi"
type DownloadParams = {
params: {
@@ -9,8 +10,16 @@ type DownloadParams = {
}
export function GET(request: Request, { params }: DownloadParams) {
const { searchParams } = new URL(request.url)
const { area } = params
const filePath = path.join(process.cwd(), `specs/${area}/openapi.full.yaml`)
const version =
process.env.NEXT_PUBLIC_VERSIONING === "true"
? (searchParams.get("version") as Version) || "1"
: "1"
const filePath = path.join(
process.cwd(),
`${version === "1" ? "specs" : "specs-v2"}/${area}/openapi.full.yaml`
)
if (!existsSync(filePath)) {
return new NextResponse(null, {