I use open API to generate code from Swagger in a node server. Up until yesterday, it worked. The BE team deployed an update to the swagger, and now the generation fails with the error:
Error: Command failed:
npx openapi-generator-cli generate -g typescript-axios -i http://opt-my-service.edge2-ingress.capitol.is/v3/api-docs/MYORG -o /Users/itaytur/Documents/GitHub/graphql-service/src/integrations/generated/opt-my-service --skip-validate-spec --type-mappings=set=Array -p enumNameSuffix=,withoutPrefixEnums=false,supportsES6=true,apiPackage=apis,modelPackage=models,useSingleRequestParameter=true
Exception in thread "main" java.lang.RuntimeException: Issues with the OpenAPI input. Possible causes: invalid/missing spec, malformed JSON/YAML files, etc.
The service it fails upon constantly changes, but the error stays the same.
The generation fails when I run it against the environment where BE pushes the change. It works if I run the generation in an environment where the update hasn't been deployed yet.
I upgraded the npm package:
"@openapitools/openapi-generator-cli": "2.16.2"
I changed the generator-cli version in the openapitools.json
to 7.11.0.
Now it looks like this:
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.11.0"
}
}
But none of that works.
The solution:
openapitools.json
.The generation creates the openapitools.json,
and for some reason, it fixed the issue.