Safeguard
Security Guides•

Generated API clients: five security myths and the facts

Is generated code safe by default, never edited, immune to scanners? Five common beliefs about generated API clients, checked against the docs.

Safeguard Security Team
3 min read

Generated clients are not automatically safe, their output is not frozen, and scanners should not skip them. Machine written code still carries the spec, the templates and the libraries the generator chose. Below are five common beliefs about OpenAPI generated code and what the generator documentation says about each.

Myth 1: Generated code is safe because it is machine written

Fact. A generator is a program with its own bugs and dependencies, and it faithfully turns your spec into code, including mistakes in the spec. It also adds libraries through templates, as the docs show with the Swagger annotations note. Generated code needs the same review and scanning as other code.

Myth 2: The output is the same every time

Fact. The output depends on the spec, the generator version, the templates, the config and any post process command. Change any of them and the output changes. Installing "latest" in CI makes the tool a moving part. See how to pin the generator.

Myth 3: Nobody edits generated files

Fact. People do, and the tool has a feature for it: the ignore file keeps chosen files from being overwritten. Those files stop receiving template fixes. See the ignore file post.

Myth 4: A custom template is just formatting

Fact. Templates are code that writes code. The docs example adds a logging library through a template change and a build file edit. One template line can put a new dependency or a behaviour change into every model. See custom templates.

Myth 5: Validation protects me from a bad spec

Fact. The validate command checks the document against the specification and can recommend improvements. It does not know your intent. A valid spec can name the wrong server or omit a security scheme. A skip validation flag exists in the CLI, so if it is set, even basic checking is off. Review spec diffs yourself.

Summary table

BeliefWhat to do instead
Machine written means safeScan and review generated code
Output is stablePin the tool and templates
Nobody edits itTrack ignored files and review them on upgrades
Templates are cosmeticReview template changes like source
Validation is enoughReview spec changes for intent

One more fact

Pinning the tool is not the same as pinning what it emits. The generated project declares libraries of its own, which need a lockfile and regular updates. See what a lockfile stops and what it cannot.

Where Safeguard fits

Safeguard offers SBOM and dependency scanning, reachability analysis and policy gates, which cover the dependency side of generated clients.

Quick check

Should I exclude generated code from scanning to cut noise?

Be careful. Dependency scanning should cover it. For static analysis, exclusions can be reasonable if you record the choice. See our post on SAST exclusions for generated code.

Is generated code less likely to have injection bugs?

It can be more consistent, but that depends on the template. Test it, do not assume.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.