fix:sample/plate 之前的开发
This commit is contained in:
37
frontend/openapi-ts.config.ts
Normal file
37
frontend/openapi-ts.config.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { defineConfig } from "@hey-api/openapi-ts";
|
||||
import { config } from "dotenv";
|
||||
import { existsSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const envPath = resolve(process.cwd(), ".env");
|
||||
if (existsSync(envPath)) {
|
||||
config({ path: envPath });
|
||||
}
|
||||
|
||||
const envLocalPath = resolve(process.cwd(), ".env.local");
|
||||
if (existsSync(envLocalPath)) {
|
||||
config({ path: envLocalPath });
|
||||
}
|
||||
|
||||
const apiBaseUrl =
|
||||
process.env.API_BASE_URL ||
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL ||
|
||||
"http://localhost:8081";
|
||||
|
||||
const openApiUrl =
|
||||
process.env.OPENAPI_URL ||
|
||||
process.env.REACT_APP_OPENAPI_URL ||
|
||||
`${apiBaseUrl.replace(/\/$/, "")}/brapi/v2/openapi.json`;
|
||||
|
||||
export default defineConfig({
|
||||
client: "@hey-api/client-fetch",
|
||||
input: openApiUrl,
|
||||
output: "./src/lib/api",
|
||||
schemas: {
|
||||
name: "types.gen.ts"
|
||||
},
|
||||
services: {
|
||||
name: "sdk.gen.ts"
|
||||
},
|
||||
clientName: "client.gen.ts"
|
||||
});
|
||||
Reference in New Issue
Block a user