Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException when encountering nullable enums #32

Open
relsunkaev opened this issue Oct 15, 2021 · 0 comments
Open

java.lang.NullPointerException when encountering nullable enums #32

relsunkaev opened this issue Oct 15, 2021 · 0 comments

Comments

@relsunkaev
Copy link

relsunkaev commented Oct 15, 2021

Description

Cannot generate models with nullable enums. The normal openapi-generator tool with the default python generator does not encounter this error (tried with both v4.1.2 and v.5.2.1).

Minimal Reproducible Example

openapi: 3.0.0
info:
  description: TestAPI
  version: "0.0.1"
  title: MRE API Definition
paths:
  /inventory:
    get:
      responses:
        '200':
          description: result
          content:
            application/json:
              schema:
                type: object
                properties:
                  value:
                    type: string
                    nullable: true
                    enum:
                    - value1
                    - value2
                    - null

Traceback

Storing intermediate outputs in /Users/user/repos/personal/fastapi_client/tmp.TvRoVuZrA; it will be removed if generation is successful
[main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: python (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'python' is considered experimental.
[main] INFO  o.o.c.l.AbstractPythonCodegen - Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE="/usr/local/bin/yapf -i"' (Linux/Mac)
[main] INFO  o.o.c.l.AbstractPythonCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] INFO  o.o.c.l.PythonLegacyClientCodegen - Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE="/usr/local/bin/yapf -i"' (Linux/Mac)
[main] INFO  o.o.c.l.PythonLegacyClientCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] INFO  o.o.c.languages.PythonClientCodegen - generateAliasAsModel is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
Exception in thread "main" java.lang.RuntimeException: Could not generate model 'inline_response_200'
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:544)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:899)
	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)
Caused by: java.lang.NullPointerException: Null context for variable 'this' on line 25
	at com.samskivert.mustache.Template.getValueIn(Template.java:288)
	at com.samskivert.mustache.Template.getValue(Template.java:224)
	at com.samskivert.mustache.Template.getValueOrDefault(Template.java:279)
	at com.samskivert.mustache.Mustache$VariableSegment.execute(Mustache.java:802)
	at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
	at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:866)
	at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
	at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:881)
	at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
	at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:870)
	at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
	at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:866)
	at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
	at com.samskivert.mustache.Mustache$InvertedSegment.execute(Mustache.java:906)
	at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
	at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:881)
	at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
	at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:866)
	at com.samskivert.mustache.Template.executeSegs(Template.java:157)
	at com.samskivert.mustache.Template.execute(Template.java:134)
	at com.samskivert.mustache.Template.execute(Template.java:125)
	at org.openapitools.codegen.templating.MustacheEngineAdapter.compileTemplate(MustacheEngineAdapter.java:65)
	at org.openapitools.codegen.TemplateManager.write(TemplateManager.java:163)
	at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:1041)
	at org.openapitools.codegen.DefaultGenerator.generateModel(DefaultGenerator.java:382)
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:535)
	... 4 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant