-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi-ts.config.ts
27 lines (26 loc) · 1.12 KB
/
openapi-ts.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
import { defineConfig } from "@hey-api/openapi-ts";
export default defineConfig({
client: "@hey-api/client-fetch",
input: "http://host.docker.internal:8000/openapi.json",
output: { path: "src/api", lint: "biome", format: "biome" },
services: {
asClass: true,
// Really jank unfortunately, there is no way to preprocess input,
// so we have to find the index of '-' in the generated name and take the subslice from that index onwards
// Now almost all routes have nice names (except auth, but it was extra jank to begin with)
methodNameBuilder: (operation) => {
const str = operation.name.substring(
operation.id
?.replace(/\s/g, "") // Whitespaces are stripped in the final name, which we need to account for
.indexOf("-") ?? 0 + 1, // If the operation is category-less (which some are for some reason), we take the whole string
operation.name.length,
);
return str[0].toLowerCase() + str.substring(1); // First letter shold be lowercase, but since we stripped the first word we do this manually
},
},
types: {
dates: "types",
enums: "typescript",
},
plugins: ["@tanstack/react-query"],
});