Generated output and regeneration
Generation produces TypeScript source, not a standalone HTTP implementation. Compile decorator classes with experimentalDecorators: true; install the packages imported by the actual output.
Output families
| Output | Generation rules |
|---|---|
types.ts | Component schemas grouped by schema-name namespace; model types/enums and imported Wow types |
*ApiClient.ts | Ordinary tagged operations with operationId; operation tags must all be eligible API tags; wow/Actuator/resolved aggregate tags excluded |
commandClient.ts | Resolved aggregate command paths, body aliases, regular and stream command clients |
queryClient.ts | Aggregate QueryClientFactory, state/field types, domain-event union (never when empty) and event title enum |
boundedContext.ts | Context-alias constant for resolved contexts |
index.ts | Recursive exports for .ts files and nonempty subdirectories |
.fetcher-generator.json | Version 1 ownership manifest with SHA-256 hashes of generated .ts files |
Ordinary methods expose positional path arguments, a ParameterRequest (FormData for multipart; referenced JSON model when available), and optional attributes. Query/header/cookie data are carried in that request rather than expanded into one positional argument each. Path-level parameters are inherited; operation parameters override matching in/name. Missing operationId or no usable tags excludes an operation.
Return inference reads 200 only. JSON schema is preferred, then wildcard schema, then SSE. Wildcard string responses use text extraction; recognized SSE returns JsonServerSentEventStream, with any fallback when the event model cannot be inferred. Without an inferred body, the fallback is Promise<Response> with native Response extraction. A different 2xx code is not automatically equivalent. Generated methods rely on decorators replacing their throw autoGeneratedError(...) placeholder at runtime.
Runtime setup
pnpm add @ahoo-wang/fetcher @ahoo-wang/fetcher-decorator @ahoo-wang/fetcher-eventstream @ahoo-wang/fetcher-wow
pnpm exec fetcher-generator generate -i ./openapi.json -o ./src/generated -t ./tsconfig.json
pnpm exec tsc --noEmit -p ./tsconfig.jsonCreate the generated client with its ApiMetadata constructor, typically { fetcher }. Inspect the generated method name and signature rather than assuming a tag or operationId transformation. Configure the Fetcher baseURL for the target server; generation does not call the generated API. See declarative endpoints.
Ownership and failures
Files emitted again at the same path are replaced: keep hand-written customizations outside generated files. Stale files are deleted only if they were recorded in the prior manifest and their content hash is unchanged. Modified stale files and unrelated files are preserved; preservation does not make them part of the current generated API. Index rebuilding can still include source files present in the project.
An invalid manifest or a generated path escaping the output root throws. Saves are awaited before stale deletion and the new manifest, but the operation is not an atomic directory transaction: partial writes can remain after failure. Do not delete the manifest to force cleanup; use a dedicated output directory and review its diff after regeneration. Formatting/fixMissingImports does not prove the output type-checks: run the consumer compiler.
Implementation sources
packages/generator/src/utils/sourceFiles.ts:33
packages/generator/src/client/apiClientGenerator.ts:73
