-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathorval.config.ts
More file actions
60 lines (53 loc) · 1.68 KB
/
orval.config.ts
File metadata and controls
60 lines (53 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import path from "node:path";
import { defineConfig } from "orval";
const apiPath = path.join(__dirname, "src", "api");
const schemasPath = path.join(apiPath, "schemas");
const indexPath = path.join(apiPath, "index.ts");
const apiClientPath = path.join(__dirname, "src", "api-client.ts");
export default defineConfig({
api: {
output: {
mode: "split",
target: indexPath,
schemas: schemasPath,
clean: true,
mock: true,
formatter: "biome",
override: {
header: false,
mutator: {
path: apiClientPath,
name: "customFetch",
},
transformer: (val) => {
let operationName = val.operationName?.replace(/controller/i, "");
// Remove redundant prefixes to clean up function names
if (operationName) {
operationName = operationName
.replace(/^yields/i, "")
.replace(/^actions/i, "")
.replace(/^transactions/i, "")
.replace(/^networks/i, "")
.replace(/^providers/i, "")
.replace(/^health/i, "");
// Ensure the first letter is lowercase
operationName =
operationName.charAt(0).toLowerCase() + operationName.slice(1);
// Handle special cases where removing prefix leaves empty or awkward names
if (operationName === "health" || operationName === "") {
operationName = "health";
}
}
return {
...val,
operationName,
};
},
},
},
input: {
target:
"https://docs.yield.xyz/openapi/appsyield-apiswagger-docsopenapi.yaml",
},
},
});