Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3439
Closed
Open
Issue created Jul 24, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

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

Assignee
Assign to
Time tracking