Direct answer
OpenAPI Generator produces API clients, server stubs, documentation, and configuration from an OpenAPI definition, and the output is shaped by a recipe: the input specification, the generator invocation, global properties, template overrides, and the output directory. A regenerated client diff is only reviewable when someone can trace each change back to one of those inputs. Hand patches to generated files are the failure mode this post is about preventing, because the next regeneration silently erases them. The concrete win is a generation recipe you can read and re-run, so a client change is an input decision rather than an edit to generated output. The concrete loss is that a recipe that produces compiling code is not proof the client is semantically correct against the live API.
The rule Claude Code’s own best practices state is blunt: do not edit the generated client. Change the spec, the configuration, or the template that produces it. This post is about making that rule practical for one workflow.
Why a hand-patched client costs two cycles
A hand patch works once. The generated client has a wrong type, an engineer edits the emitted file, tests pass, and the patch ships. Then someone regenerates from an updated spec and the patch is gone, along with the reasoning behind it.
Three costs follow. Review time doubles, because the patch has to be rediscovered and re-explained after every regeneration. Correctness risk goes up, because a patch that fixed one operation may have hidden a spec problem that affects others. Ownership gets blurry, because nobody can say whether the client directory is source or output.
Reading the recipe first is cheaper than repairing patches later. The generator’s own documentation describes generation of clients, server stubs, documentation, and configuration from an OpenAPI definition. None of that requires editing what it emits. This post stays on the recipe and the diff, and it does not turn template review into package-install safety guidance.
What OpenAPI Generator Produces
The generator is a family of generators selected by name. A client generator emits SDK code in a target language. A server generator emits stubs. Documentation generators emit reference material. Configuration generators emit client configuration files. All of them read the same input specification and all of them write to an output directory you choose.
| Generator kind | Typical output | Owned by |
|---|---|---|
| API client | Language-specific SDK | The generator, from your spec and config |
| Server stub | Server scaffolding and operation interfaces | The generator, from your spec and config |
| Documentation | HTML or Markdown reference | The generator, from your spec |
| Configuration | Client configuration files | The generator, from your spec |
Official, F047: The OpenAPI Generator project describes generation of API client libraries, server stubs, documentation, and configuration from an OpenAPI definition. The repository was fetched, but detailed documentation extraction was limited during research, so generator-specific options should be rechecked against the current documentation before relying on a fine detail.
The distinction that matters for review is output ownership. Generated output is a build artifact. Your spec, your configuration, and your template overrides are the source. The next section turns that into a readable recipe.
Read the Generation Recipe
A recipe is a written description of how a client directory is produced. A recipe has five parts: the input specification, the generator invocation, global properties, template overrides, and the output directory. Write it down before interpreting any diff.
openapi-generator-cli generate \
-i ./spec/openapi.yaml \
-g typescript-fetch \
-o ./src/generated/client \
--global-property models,apis \
-t ./templates/typescript-fetchDerived, F048: Recording the input specification, generator invocation, global properties, template overrides, and output directory before interpreting a diff is an editorial generation-recipe checklist. The customization documentation at openapi-generator.tech describes customization inputs; the checklist is a review method, not a claim that the emitted client is correct.
A recipe table is the artifact worth keeping.
| Recipe part | What it records | Where it lives |
|---|---|---|
| Input specification | Path to the OpenAPI document and its version | Repository, versioned |
| Generator invocation | Generator name, output directory, command | Script or CI step |
| Global properties | Which parts of the spec to generate | Command flags or config |
| Template overrides | Which templates replace defaults | Template directory, versioned |
| Output directory | Where generated files land | Command flag |
Read the table as an input inventory. Each row is something a reviewer can check against the diff. A change that cannot be traced to any row is a hand patch, and the recipe exists to make those visible.
Inventory Global Properties
Global properties tell the generator which parts of the specification to generate and which to skip. They are the cheapest lever for reducing noise in a diff, and they are also the easiest to forget when documenting a recipe.
| Global property intent | Effect on output | Review question |
|---|---|---|
| Generate models only | Emits model types, no API classes | Is the client expected to include operations? |
| Generate APIs only | Emits operation classes, may omit models | Will the emitted code compile without models? |
| Skip a named feature | Removes a section of output | Was the skip documented as intentional? |
| Generate supporting files | Emits README, config, utilities | Are supporting files part of the reviewed surface? |
The generator’s usage documentation describes invocation and configuration. Because detailed extraction was limited during research, treat the exact property names as something to verify against the current documentation rather than as a fixed list. The review habit carries over even when names differ: record which parts of the spec the command was asked to generate.
A global property change is a contract change. Turning off model generation for a client that consumers import types from breaks those consumers, and the break shows up in their builds rather than in the generation command. The TypeScript project references guide covers the same ownership question for build boundaries: know who reads a surface before changing what it emits.
Map Template Overrides
Template overrides replace the default templates the generator ships for a language. They are the mechanism for changing naming, imports, error handling, or file layout without forking the generator. They are also the part of the recipe most likely to be undocumented.
ls ./templates/typescript-fetch
# inventory which templates this workflow overridesAn override inventory lists each overridden template and the reason. A template override is a decision about generated output, and like any decision it needs a reason that survives the engineer who wrote it.
| Overridden template | Reason recorded | Risk if regenerated without it |
|---|---|---|
model.mustache |
Custom naming for a legacy field | Generated names drift from consumers |
api.mustache |
Custom error wrapper | Error handling diverges across operations |
README.mustache |
Project-specific usage notes | Documentation reverts to generic text |
The table works as divergence map. Each override is a place where your client differs from a default generator output, and the diff review has to treat those as intentional rather than as noise. The customization documentation at openapi-generator.tech/docs/customization is the reference for how overrides work; the reasons column is yours to fill in. The GraphQL Code Generator client presets guide covers the same discipline for a different generator: trace a generated type back to the input that produced it, and treat a preset or template change as the source of the diff.
Separate Config from Generated Output
The output directory is generated. The configuration that produces it is source. Keeping that separation visible in the repository is what makes regeneration safe.
| Path | Status | Change policy |
|---|---|---|
spec/openapi.yaml |
Source | Reviewed like code |
templates/ |
Source | Reviewed like code |
| Generation script or CI step | Source | Reviewed like code |
src/generated/client/ |
Generated | Do not edit; regenerate |
The generated directory should be readable as output at a glance. A comment at the top, a path convention, or a CI check that fails on hand edits are all ways to make the boundary real. The exact mechanism is a project decision; the boundary itself is not.
Official best-practices boundary: Claude Code’s best practices explicitly say not to edit the generated client. Change the spec, the configuration, or the template instead. The generated-code habit is the same one the C# source generators guide applies to compiler-emitted code, and it is the reason a generation recipe is worth writing down.
Regenerate from a Known Input
A reproducible regeneration starts from a known input. The spec is at a recorded version, the generator is invoked with a recorded command, and the output directory is clean of hand edits before the command runs.
git status --porcelain src/generated/client
# confirm the output directory has no uncommitted hand edits
openapi-generator-cli generate \
-i ./spec/openapi.yaml \
-g typescript-fetch \
-o ./src/generated/clientThe known-input rule is what makes a diff meaningful. A diff that mixes hand patches with regenerated output is not reviewable, because the reviewer cannot tell which lines came from the spec and which came from an edit nobody recorded.
| Precondition | Check | Why it matters |
|---|---|---|
| Spec version recorded | Spec is committed at a known state | The diff traces to a spec change |
| Output directory clean | No uncommitted edits in generated paths | Hand patches do not pollute the diff |
| Command recorded | Invocation matches the recipe | The same inputs produce the same output |
| Overrides present | Template directory matches the inventory | Missing overrides change output silently |
Regeneration is also the cheapest way to test a recipe change. Run it, inspect the diff, and the diff is the review. The Claude Code common workflows cover iterating an edit against a command, and a generation command is exactly that kind of loop.
Review the Output Diff
A generated diff review has one question per hunk: which input produced this change? The hunks that trace to a spec edit are expected. The hunks that trace to a config or template change are expected. The hunks that trace to nothing are hand patches and they need a decision before merge.
| Hunk pattern | Likely input | Review action |
|---|---|---|
| New or renamed model fields | Spec change | Confirm the spec change was reviewed |
| Import path changes | Output directory or template change | Confirm the path is intentional |
| Error handling changes | Template override | Confirm the override is in the inventory |
| Whitespace or formatting only | Generator version change | Confirm the generator version is recorded |
The last row is the one teams forget. A generator upgrade can produce a formatting-only diff across every file, which makes the next real change hard to review. Recording the generator version in the recipe is the cheap fix.
The pass condition is concrete: every hunk traces to a recorded input, and the client compiles against the consumers that import it. Compiling is necessary and it is not sufficient. This post does not claim regenerated code is semantically correct, because correctness against a live API is a runtime question that needs its own evidence.
When the output directory is part of the contract
The output directory looks like a build detail, and for consumers it is a contract. Import paths in a generated client are derived from where the generator writes the files, so moving the output directory changes what every consumer has to import.
Three consequences follow. A moved output directory is a breaking change for anyone importing the old paths, and the break appears in consumer builds rather than in the generation command. A path change mixed into a spec-change diff makes the spec change harder to review, because path churn drowns the signal. A path change that is not recorded in the recipe cannot be attributed during diff review, so the next reviewer has to guess.
| Output path change | Consumer effect | Review action |
|---|---|---|
| Directory renamed | Every import path changes | Treat as a breaking change and record it |
| Directory nested deeper | Import paths gain a segment | Confirm consumers updated their imports |
| Output split across directories | Imports point at two roots | Document both roots in the recipe |
| Path unchanged, contents changed | Imports stable | Review contents on their own |
Use the table as reminder that paths are part of the reviewed surface. A generation recipe that names the output directory is also naming the import paths consumers depend on, and a path decision made casually is a breaking change made casually. The same ownership reasoning applies to the generator version. A generator upgrade can change emitted idioms, which changes what the files look like without changing the paths. Recording the version alongside the output directory gives a reviewer two axes for attributing a diff: where the files are and which tool produced them. Both belong in the recipe, and both are cheap to write down once and expensive to reconstruct later.
Server stubs and documentation follow the same rule
The recipe discipline is not client-specific. Server stubs and documentation outputs are generated from the same specification, and they fail in the same way when someone patches the output instead of the input.
A server stub is scaffolding. The stub declares the operation interfaces the spec describes, and the implementation belongs to your project. Editing the stub to change behavior is editing a file the next regeneration replaces, and the replacement will not carry the behavior change. The stub is a contract surface, and the implementation is yours to write against it.
Documentation output is even easier to misread. A documentation generator emits reference material from the spec, and a hand edit to the generated docs disappears on the next run. If the docs are wrong, the spec is wrong, and fixing the spec fixes every output that reads it.
| Output kind | What you own | What the generator owns | Fix belongs in |
|---|---|---|---|
| Client SDK | Your usage of the SDK | The emitted SDK code | Spec, config, or template |
| Server stub | Operation implementations | The stub interfaces and scaffolding | Spec for the interface, your code for behavior |
| Documentation | Nothing, unless you post-process | The emitted reference text | Spec or a documentation template |
| Configuration files | Where you apply them | The emitted configuration | Spec or a config template |
Every row of the table is one rule applied four ways. The generated artifact is never the fix. The fix belongs at the input, and the input is one of the five recipe parts from earlier in this post. Teams that apply the rule once for clients and forget it for stubs and docs end up maintaining patches in three directories instead of one. The documentation case has a useful side effect. Because documentation is generated from the same spec as the client, a doc diff is a cheap way to confirm a spec change did what you intended. If the spec change was supposed to add a field, the doc output should show the field described. A doc diff that does not reflect the intended spec change is evidence the change landed in the wrong place, and it is cheaper to catch there than in a consumer build.
Generator setting to output effect map
A map of which settings shape which output is the review artifact worth keeping. The map turns a diff review from an investigation into a lookup.
| Setting | Shapes | Diff signature |
|---|---|---|
| Input specification | Models, operations, descriptions | Field-level changes in models and APIs |
| Generator name | Language and file layout | Wide structural changes |
| Global properties | Which sections exist | Added or removed file groups |
| Template overrides | Naming, imports, error handling | Localized, repeated per operation or model |
| Output directory | Paths and import statements | Path and import changes |
| Generator version | Formatting and emitted idioms | Wide, mostly cosmetic changes |
Approach the map as a diagnostic table. Match a diff signature to a setting before proposing a fix, and propose the fix at the setting rather than in the generated file. The sqlc query annotations guide applies the same rule to SQL generation: change the query or the annotation, not the emitted function.
The concrete win, loss, and implication
The concrete win is a client change you can attribute. When a reviewer asks why an operation signature changed, the answer is a spec commit, a config flag, or a template override with a recorded reason. An answer like that survives regeneration, because the reasoning lives in an input rather than in an emitted file.
The concrete loss is that a recipe goes stale. Generator versions change output, template overrides accumulate without documented reasons, and a spec evolves faster than the recipe is updated. A recipe written today describes today’s inputs, and the next generator upgrade can change what those inputs produce.
The practical implication is that generated output is a build artifact, not a source file. Teams that regenerate from a documented recipe spend less time re-applying lost patches. Teams that hand-edit generated clients keep paying the same cost every time the spec changes.
Working with Claude Code on a generated client
Give the agent three inputs: the change you want in the client, the commands it may run, and the definition of done. The definition of done excludes editing generated files. Ask for a regeneration against the current spec and a diff review that attributes each hunk to an input.
openapi-generator-cli generate -i ./spec/openapi.yaml -g typescript-fetch -o ./src/generated/client
# ask for a clean regeneration before reviewing any diff
git diff --stat src/generated/client
# ask for the diff shape nextReview the agent’s attribution claim. The agent can read the diff accurately and still propose editing a generated file, because that is the shortest path to a passing test. Deciding whether a change belongs in the spec, the config, or a template is a design decision, and the reviewer owns it. The Claude Code verification guide covers what to ask before accepting the change.
A generated-client change that turns into a wide reformat is worth pausing on. The Claude Code overengineering guide describes that pattern, and a generator upgrade is one of its common triggers. The Claude Code license compliance guide covers a separate question about generated code: what license applies to output produced from a spec you do not own.
Checklist before you accept a generated diff
| Check | Pass condition | If it fails |
|---|---|---|
| Recipe recorded | Spec, command, properties, overrides, output path written down | Write the recipe before reviewing |
| Spec change identified | The spec commit behind the diff is named | Trace the diff to a spec change |
| Config change identified | Any global property change is named | Check the invocation flags |
| Override change identified | Any template override change is in the inventory | Compare the template directory |
| Generator version recorded | The generator version is part of the recipe | Record it before the next upgrade |
| No hand patches | Every hunk traces to an input | Regenerate cleanly and re-review |
| Consumers compile | Projects importing the client type-check | Fix at the input, not the output |
| No correctness claim | Nobody claims the client is proven against the live API | Add a runtime check if correctness matters |
Data gap and future update
The OpenAPI Generator repository and wiki were fetched during research, and the customization and usage documentation pages are the references used for the recipe concepts. Detailed extraction was limited, so exact flag names, global property names, and template file names should be rechecked against the current documentation before relying on a fine detail. F048 is derived and labeled as an editorial checklist rather than a vendor guarantee.
No generation-time measurement, output-size number, or correctness rate is reported here, because none was measured. A future update quantifying how template overrides affect generated file size or compile time for a specific language would need a fixed generator version and a measured pass. No such data was collected.
Generator-specific behavior for languages this post does not name is also out of scope. Whether a given language generator honors an override in a documented way is a property of that generator, and this post does not generalize from one language’s templates to another’s.
Related reading on generated-code boundaries
Generated output is a recurring boundary in this batch. GraphQL Code Generator Client Presets covers tracing generated types back to schema and document inputs. sqlc Query Annotations covers aligning SQL and generated types at the query level. C# Source Generators covers reviewing compiler-emitted contracts, and Protocol Buffer Reserved Fields covers schema compatibility for generated bindings.
Build and dependency boundaries appear in TypeScript Project References, Cargo Build Scripts, and Conan CMakeDeps. Dependency selection appears in pnpm Peer Diagnostics, Gradle Constraints vs Dependencies, and Maven Optional Dependencies.
Framework maintenance and upgrade sequencing appear in Django Deprecation Runway, Rails Upgrade Sequence, and Angular Update Guide.
Input ownership extends past generated clients. Python Dependency Groups vs Extras covers classifying requirement buckets before moving them, which is the same classify-before-you-edit discipline applied to packaging metadata. Go Module Compatibility covers keeping an exported API change inside an import compatibility contract, and Cargo Feature Unification covers predicting which optional APIs a build exposes from the selected package set. NuGet Central Package Management covers centralizing versions so a generated client’s dependency expectations stay reviewable across projects.
More from this batch
- pnpm Peer Diagnostics: Read Resolution Reports Before Claude Code Pins
- TypeScript Project References: A Claude Code Boundary Guide
- GraphQL Code Generator Client Presets: Review Generated Boundaries
- Protocol Buffer Reserved Fields: A Claude Code Wire Compatibility Guide
- sqlc Query Annotations: Align SQL and Generated Types With Claude Code
- Django Deprecation Runway: Plan Framework Maintenance With Claude Code
- Rails Upgrade Sequence: Order Major Changes With Claude Code
- Angular Update Guide: Build a Migration Plan With Claude Code
- C# Source Generators: Review Generated Contracts With Claude Code
- Cargo Build Scripts: Define Generated-Artifact Contracts for Claude Code
One AI API Key option for OpenAI-format agents
Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.
OpenAI-format agents have a separate route: One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. Free IDs are a different client and request format, not a workaround for Claude Code authentication. Check the free model list before choosing an agent route, or read the quickstart for the request shape.
FAQ
Why not just edit the generated client?
The edit is overwritten the next time the generator runs, and the reasoning behind it disappears with it. The generator’s output is a build artifact. Changing the spec, the configuration, or the template that produces the output is the fix that survives regeneration. Claude Code’s best practices state this rule directly.
Does a clean regeneration prove the client is correct?
No. A clean regeneration proves the output traces to the recorded inputs. Whether the emitted client matches the live API’s behavior is a runtime question that needs its own evidence, and this post deliberately does not claim regenerated code is semantically correct.
How do I tell whether a diff hunk came from a template override?
Template override changes tend to repeat per operation or per model, because the same template renders each one. A hunk pattern that repeats across many generated files and matches an override in the inventory is a template change. A hunk that appears once is more likely a spec change.
What should I record when upgrading the generator?
Record the generator version in the recipe. A version change can produce a formatting-only diff across every file, which makes the next real change harder to review. Knowing the version that produced a given diff is the cheap way to keep that noise attributable.
What proves a generated-client change is complete?
Three conditions. Every diff hunk traces to a recorded input, the generated directory contains no hand edits, and the projects that import the client type-check. A green generation command alone is not a pass, because it says nothing about whether the emitted API matches what consumers expect.
More Claude Code troubleshooting
- Python Protocols vs ABCs: Preserve Interface Contracts With Claude Code
- Python TypedDict Boundaries: Stop Model Drift With Claude Code
- Python Stub Drift: Audit Third-Party Types With Claude Code
- Go Workspace Boundaries: Decide What Belongs in go.work
- Go Module Graph Pruning: Explain Indirect Dependencies With Claude Code
- Cargo Profile Boundaries: Keep Debug and Release Behavior Aligned
- Cargo Workspace Inheritance: Centralize Metadata Without Hiding Crates
- Gradle Capability Conflicts: Resolve Competing Components With Claude Code
- Gradle Variant Attributes: Match Consumers to the Right Artifact
- .NET Multi-Targeting: Separate Framework Dependencies for Claude Code
- CMake Presets: Give Claude Code Reproducible Configure Inputs
- CMake find_package vs FetchContent: Choose a Dependency Boundary
Sources
- Official: OpenAPI Generator Official Repository, describing generation of clients, server stubs, documentation, and configuration from an OpenAPI definition (F047).
- Official: OpenAPI Generator Wiki, reference for generator-specific options and workflow notes.
- Official: OpenAPI Generator FAQ, reference for common generation questions.
- Official: OpenAPI Generator Usage Documentation, reference for invocation and configuration.
- Official: OpenAPI Generator Customization Documentation, reference for template overrides and customization inputs (F048 context).