OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Spring][4.3.0] allOf -> syntax error on generated code

Open
#5,891 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

syntax error on generated code

openapi-generator version

4.3.0, 4.2.3, 4.2.0

OpenAPI declaration file content or url
 schemas:
    Foo:
      type: object
      properties:
        name:
          type: string
    Bar:
      allOf:
        - $ref: '#/components/schemas/Foo'
      type: object
      properties:
        status:
          type: string

generates

 @Override
  public int hashCode() {
    return Objects.hash(statussuper.hashCode());
  }

which causes the JDK 12 compiler:
.../Bar.java:59: error: cannot find symbol
return Objects.hash(statussuper.hashCode());
^
symbol: variable statussuper
location: class Bar

the generated code misses a 'komma'

Command line used for generation

generatorName = "spring"
configOptions = [ java12: "true", library: "spring-boot", dateLibrary: "java12",
delegatePattern:"true", unhandledException: "true"
]

Steps to reproduce
Related issues/PRs
Suggest a fix

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

Start with the supplied OpenAPI declaration and Spring generator configuration, then reproduce the generation and inspect the generated Bar.java hashCode method. Done means the generated Java code compiles and no longer references the malformed statussuper expression.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend
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.