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
  • #3293
Closed
Open
Issue created Jul 08, 2019 by Administrator@rootContributor

[BUG] Java generated code compilation failure

Created by: rgala

When model name contains single digit or digits only, for example "1", it will generate Model1.java class with the following equals method:

@Override
public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Model1 1 = (Model1) o;
    return Objects.equals(this.error, 1.error);
  }

The compilation of Model1 1 = (Model1) o;

fails because the java variable name cannot start with digits. It should be escaped like it happens for model names starting with digits and having letters too, for example 5abff9bf gets renamed to _5abff9bf.

The

if (name.matches("^[A-Z0-9_]*$")) { regex in AbstractJavaCodegen class should not match digits only names.

Assignee
Assign to
Time tracking