-
Notifications
You must be signed in to change notification settings - Fork 0
/
orval.config.ts
43 lines (41 loc) · 1.13 KB
/
orval.config.ts
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
import { defineConfig } from "orval";
function modifyRecursive(obj: object, fn: (obj: object) => boolean) {
for (const k in obj) {
if (typeof obj[k] == "object" && obj[k] !== null) {
const handled = fn(obj);
if (!handled) {
modifyRecursive(obj[k], fn);
}
}
}
}
export default defineConfig({
swapi: {
input: {
target: "src/petstore.yaml",
override: {
transformer: (api) => {
modifyRecursive(api, (value) => {
if ("type" in value && value.type === "object" && "properties" in value && value.properties) {
value["required"] = Object.keys(value.properties);
return true;
}
if ("parameters" in value && value.parameters && Array.isArray(value.parameters)) {
value.parameters.forEach((param) => (param.required = true));
return true;
}
return false;
});
return api;
},
},
},
output: {
target: "src/api",
client: "vue-query",
httpClient: "fetch",
mode: "tags-split",
mock: false,
},
},
});