[BUG][CLI][GENERATOR] NullPointer when not setting outputDir
Created by: Fjolnir-Dvorak
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
The openapi-generator-cli will throw a NullPointerException when the flag o
is omitted.
openapi-generator version
master commit no. 2c4fdd07
OpenAPI declaration file content or url
Example Petstore is sufficient
Command line used for generation
openapi-generator generate \
-g spring \
--library spring-cloud \
--additional-properties "java8=true" \
--additional-properties "dateLibrary=java8" \
--additional-properties "hideGenerationTimestamp=true" \
--additional-properties "fullJavaUtil=true" \
-i petstore-swagger-or-anything-else.json \
--artifact-id demo \
--api-package de.mo.demo.api \
--model-package de.mo.demo.model
Steps to reproduce
The above statement will throw following NullPointer:
Exception in thread "main" java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at org.openapitools.codegen.ignore.CodegenIgnoreProcessor.<init>(CodegenIgnoreProcessor.java:63)
at org.openapitools.codegen.ignore.CodegenIgnoreProcessor.<init>(CodegenIgnoreProcessor.java:52)
at org.openapitools.codegen.DefaultGenerator.opts(DefaultGenerator.java:96)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:399)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
Exception in thread "main" java.lang.NullPointerException
This Nullpointer will vanish if you add the flag o
to the command :
openapi-generator generate \
-g spring \
--library spring-cloud \
--additional-properties "java8=true" \
--additional-properties "dateLibrary=java8" \
--additional-properties "hideGenerationTimestamp=true" \
--additional-properties "fullJavaUtil=true" \
-i petstore-swagger-or-anything-else.json \
--artifact-id demo \
--api-package de.mo.demo.api \
--model-package de.mo.demo.model \
-o ./
Related issues/PRs
Found nothing
Suggest a fix
I am looking into it and will hopefully provide a pull request shortly.