openapi-generator "Spec has 2 errors" validation failure in CI
OpenAPI Generator validates the document against the OpenAPI schema before generating. When it finds errors (a missing info.version, an invalid type, a malformed path), it prints "Spec has N errors" and stops rather than emitting code from an invalid spec.
What this error means
openapi-generator-cli fails with "Spec has 2 errors." followed by each issue, for example "attribute info.version is missing" or "attribute paths.'/x'.get.responses is not of type object".
Errors:
-attribute info.version is missing
-attribute paths.'/users'.get.responses is missing
Spec has 2 errors.Common causes
Required spec attributes are missing or wrong
The document omits a required field (like info.version or an operation's responses) or uses a wrong type, which violates the OpenAPI schema.
A hand-edited spec drifted from the schema
Manual edits introduced a structural mistake the validator catches but a quick read might miss.
How to fix it
Fix each reported validation error
- Read every line under "Errors:".
- Add the missing attributes or correct the types.
- Re-run
validateuntil the spec reports no errors, then generate.
info:
title: Users API
version: 1.0.0
paths:
/users:
get:
responses:
'200':
description: OKValidate as a gate before generation
Run validation as its own CI step so an invalid spec fails fast and clearly.
- run: openapi-generator-cli validate -i openapi.yaml
- run: openapi-generator-cli generate -i openapi.yaml -g go -o ./clientHow to prevent it
- Run
openapi-generator-cli validatebefore generating in CI. - Avoid
--skip-validate-specto hide real errors. - Edit specs with schema-aware tooling that flags mistakes.