Repository navigation
Expand file tree
/
Copy pathopenapi-ts.config.ts
More file actions
45 lines (44 loc) · 1.7 KB
/
Copy pathopenapi-ts.config.ts
File metadata and controls
45 lines (44 loc) · 1.7 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
import { defineConfig } from "@hey-api/openapi-ts";
// Generates the Discord HTTP API client into `src/generated/` from the vendored
// OpenAPI document (`bun run generate:openapi`). The public surface
// (`createDiscordClient`, error handling, auth, rate-limit retry) lives in the
// hand-written `src/index.ts`; everything operation-specific below is fully
// generated and gitignored.
export default defineConfig({
input: "../../specs/discord-api.openapi.json",
output: {
path: "src/generated",
// tsdown + Biome own formatting/linting of the published bundle; keep
// codegen output raw and deterministic (no prettier/eslint post-processing).
postProcess: [],
},
plugins: [
{
name: "@hey-api/client-fetch",
// Build-time default base URL. Auth header + rate-limit retry are applied
// at runtime by `createDiscordClient`.
runtimeConfigPath: "./src/hey-api.ts",
// Discord returns proper HTTP error codes; throw on them so the error
// interceptor can surface a typed `DiscordApiError`.
throwOnError: true,
},
"@hey-api/typescript",
{
name: "@hey-api/sdk",
// Tree-shakeable standalone functions (one per Discord operation).
operations: { strategy: "flat" },
// Return the response body directly instead of the `{ data, error }` envelope.
responseStyle: "data",
// Validate request bodies and responses at runtime using the generated Zod schemas.
validator: "zod",
},
{
name: "zod",
dates: {
// Emit z.iso.datetime({ offset: true }) so validation accepts Discord's
// timestamps with timezone offsets (e.g. +00:00), not just `Z`.
offset: true,
},
},
],
});