Skip to content
Latchkey

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".

openapi-generator
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

  1. Read every line under "Errors:".
  2. Add the missing attributes or correct the types.
  3. Re-run validate until the spec reports no errors, then generate.
openapi.yaml
info:
  title: Users API
  version: 1.0.0
paths:
  /users:
    get:
      responses:
        '200':
          description: OK

Validate as a gate before generation

Run validation as its own CI step so an invalid spec fails fast and clearly.

.github/workflows/ci.yml
- run: openapi-generator-cli validate -i openapi.yaml
- run: openapi-generator-cli generate -i openapi.yaml -g go -o ./client

How to prevent it

  • Run openapi-generator-cli validate before generating in CI.
  • Avoid --skip-validate-spec to hide real errors.
  • Edit specs with schema-aware tooling that flags mistakes.

Frequently asked questions

What causes ""Spec has N errors""?
The document omits a required field (like info.version or an operation's responses) or uses a wrong type, which violates the OpenAPI schema.
How do I fix "Spec has N errors"?
Fix each reported validation error

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card