Skip to content

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

OutputGeneration rules
types.tsComponent schemas grouped by schema-name namespace; model types/enums and imported Wow types
*ApiClient.tsOrdinary tagged operations with operationId; operation tags must all be eligible API tags; wow/Actuator/resolved aggregate tags excluded
commandClient.tsResolved aggregate command paths, body aliases, regular and stream command clients
queryClient.tsAggregate QueryClientFactory, state/field types, domain-event union (never when empty) and event title enum
boundedContext.tsContext-alias constant for resolved contexts
index.tsRecursive exports for .ts files and nonempty subdirectories
.fetcher-generator.jsonVersion 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

bash
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.json

Create 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

packages/generator/src/client/queryClientGenerator.ts:35

packages/generator/src/model/modelGenerator.ts:33

Released under the Apache License 2.0.