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
  • #4069
Closed
Open
Issue created Oct 05, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] Generator creates invalid code on validated schema when an enum contains ~=

Created by: aidanhs

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

A schema for Jira validates but cannot be used for generation (crashing with "Please make sure that your schema is correct!"). This worked with the last 3.X.Y release, but I'd like to use 4.X.Y as it has some fixes for Rust bindings.

openapi-generator version

4.1.3

It's a regression that appears to have been present since 4.0. Before that did not have the same problem.

OpenAPI declaration file content or url

https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json

Command line used for generation
java -jar openapi-generator-cli.jar generate -i jira-v3.swagger-v3.json -g rust -o abc
Steps to reproduce
$ cd $(mktemp -d)
$ VER=4.1.3 && wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/$VER/openapi-generator-cli-$VER.jar -O openapi-generator-cli.jar
[...]
$ curl -sSL https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json > jira-v3.swagger-v3.json
$ java -jar openapi-generator-cli.jar validate -i jira-v3.swagger-v3.json --recommend
Validating spec (jira-v3.swagger-v3.json)
Warnings: 
        -Unused model: RichText
        -Unused model: JqlQueryUnitaryOperand
        -Unused model: FieldValueClause
        -Unused model: JqlQueryClauseTimePredicate
        -Unused model: avatarUrls
        -Unused model: ListOperand
        -Unused model: IconBean
        -Unused model: CompoundClause
        -Unused model: FieldChangedClause
        -Unused model: KeywordOperand
        -Unused model: JqlQueryClauseOperand
        -Unused model: ValueOperand
        -Unused model: FunctionOperand
        -Unused model: FieldWasClause

[info] Spec has 14 recommendation(s).
$ rm -rf abc && mkdir abc && java -jar openapi-generator-cli.jar generate -i jira-v3.swagger-v3.json -g rust -o abc
[main] INFO  o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: rust (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'rust' 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
[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
[main] WARN  o.o.codegen.DefaultCodegen - Unknown type found in the schema: object
[main] WARN  o.o.codegen.DefaultCodegen - Unknown type found in the schema: object
[main] INFO  o.o.codegen.DefaultGenerator - Model JqlQueryClause not generated since it's a free-form object
[main] INFO  o.o.codegen.DefaultGenerator - Model ConnectModule not generated since it's a free-form object
[main] INFO  o.o.codegen.DefaultGenerator - Model ConnectModules not generated since it's an alias to map (without property) and `generateAliasAsModel` is set to false (default)
[main] INFO  o.o.codegen.DefaultGenerator - Model ListWrapperCallbackApplicationRole not generated since it's a free-form object
Exception in thread "main" java.lang.RuntimeException: Could not process model 'FieldValueClause'.Please make sure that your schema is correct!
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:472)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:923)
        at org.openapitools.codegen.cmd.Generate.run(Generate.java:416)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
Caused by: java.lang.NullPointerException
        at org.openapitools.codegen.DefaultCodegen.updateCodegenPropertyEnum(DefaultCodegen.java:4304)
        at org.openapitools.codegen.DefaultCodegen.postProcessModelsEnum(DefaultCodegen.java:385)
        at org.openapitools.codegen.languages.RustClientCodegen.postProcessModels(RustClientCodegen.java:156)
        at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1233)
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:467)
        ... 3 more
Related issues/PRs

I see a number of issues mentioning updateCodegenPropertyEnum but nothing recent or relating to a crash, and a few mentioning "Please make sure that your schema is correct", but that seems to be a generic error.

Suggest a fix

I note that it's crashing on a model that is recommended for removal, so I'll try that and see if it helps.

Assignee
Assign to
Time tracking