Openapi-generator: [BUG] Missing configuration is silently ignored

Created on 21 Nov 2019  路  2Comments  路  Source: OpenAPITools/openapi-generator

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [ ] Have you validated the input using an OpenAPI validator (example)?
  • [x] What's the version of OpenAPI Generator used?
  • [x] Have you search for related issues/PRs?
  • [ ] What's the actual output vs expected output?
  • [ ] [Optional] Bounty to sponsor the fix (example)
Description

If a configuration file is not present, the generator logs an error but doesn't return error code:

$ openapi-generator generate --input-spec api.yaml --generator-name cpp-qt5-client --config unexisting-config-file.yaml
[main] ERROR o.o.c.config.CodegenConfigurator - Unable to deserialize config file: cpp-qt5-petstore.json
java.io.FileNotFoundException: cpp-qt5-petstore.json (No such file or directory)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
    at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:766)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2903)
    at org.openapitools.codegen.config.CodegenConfigurator.fromFile(CodegenConfigurator.java:97)
    at org.openapitools.codegen.cmd.Generate.run(Generate.java:261)
    at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
[main] ERROR o.o.c.config.CodegenConfigurator - Unable to deserialize config file: cpp-qt5-petstore.json
java.io.FileNotFoundException: cpp-qt5-petstore.json (No such file or directory)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
    at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:766)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2903)
    at org.openapitools.codegen.config.CodegenConfigurator.fromFile(CodegenConfigurator.java:97)
    at org.openapitools.codegen.cmd.Generate.run(Generate.java:261)
    at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: cpp-qt5-client (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'cpp-qt5-client' is considered stable.
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one
...
openapi-generator version

4.2.1

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml

Command line used for generation
openapi-generator generate --input-spec api.yaml --generator-name cpp-qt5-client --config unexisting-config-file.yaml
Steps to reproduce

Just try to generate passing an unexisting configuration file

Related issues/PRs

4558

Suggest a fix
Bug

Most helpful comment

I already filed https://github.com/OpenAPITools/openapi-generator/pull/4557 so moving forward an exception will be thrown instead of just logging an error.

All 2 comments

I already filed https://github.com/OpenAPITools/openapi-generator/pull/4557 so moving forward an exception will be thrown instead of just logging an error.

Closed via #4557

Was this page helpful?
0 / 5 - 0 ratings