OpenAPITools / OpenAPITools/openapi-generator

[BUG] Null Reference Exception when using --model-name-suffix for fsharp-giraffe-server generator

Open
#9,623 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bleeding Edge Issue: Bug Server: F#
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

When running this commande openapi-generator generate -i api.yml -g fsharp-giraffe-server --dry-run --model-name-suffix "Dto" I get the following exception:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.Map.put(Object, Object)" because "models" is null
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:512)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:875)
        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:441)
        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)

When I run it with any other generator, I don't get the exception:
openapi-generator generate -i api.yml -g aspnetcore --dry-run --model-name-suffix "Dto"

When I run it without --model-name-suffix, I don't get the exception:
openapi-generator generate -i api.yml -g fsharp-giraffe-server --dry-run

@nmfisher Could it be that this option is not supported yet for the F# generator?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the command with the fsharp-giraffe-server generator and --model-name-suffix, then trace the failure from org.openapitools.codegen.DefaultGenerator.generateModels at line 512 through the generator configuration. Compare this path with the aspnetcore run and the no-suffix run. Done means the F# generator no longer raises the NullPointerException, or its unsupported-option behavior is explicitly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp, java
Domain
api, backend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.