openapi-generator "specified file ... is not valid JSON/YAML" in CI
OpenAPI Generator parses the input spec as JSON or YAML before anything else. A syntax error (bad indentation, a tab, an unquoted special character) makes the parser fail with a message that the file is not valid JSON/YAML, citing the line and column.
What this error means
openapi-generator-cli fails with a parser error such as "while scanning ... found character \"\\t\" that cannot start any token" or "is not valid JSON/YAML", with a line/column reference.
Exception in thread "main" com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException:
while scanning for the next token
found character '\t' that cannot start any token
in 'reader', line 12, column 1Common causes
A YAML syntax error in the spec
A tab character, inconsistent indentation, or an unquoted value containing a special character makes the YAML unparseable.
A truncated or wrong-format file
The file was partially written, has a BOM, or is actually a different format than the extension implies.
How to fix it
Validate and fix the spec syntax
- Run the generator validator or a YAML linter to get the exact line.
- Replace tabs with spaces and quote values with special characters.
- Re-run generation once the file parses cleanly.
openapi-generator-cli validate -i openapi.yamlLint YAML in CI before generation
Catch malformed specs with a fast lint step so the generator never sees broken input.
- run: npx yaml-lint openapi.yaml
- run: openapi-generator-cli generate -i openapi.yaml -g go -o ./clientHow to prevent it
- Lint or validate the spec before each generation run.
- Configure editors to use spaces, never tabs, in YAML.
- Quote string values that contain
:,#, or leading symbols.