OpenAPITools / OpenAPITools/openapi-generator

[BUG] Invalid code: missing comma in hashCode()

Open
#6,487 7 comments 3 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

Description

When I create code from the spec below, the result's hashCode() looks like this:

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

so there is a missing comma between foo and super.hashCode().

openapi-generator version

It works fine with 4.2.2 and fails with 4.2.3 and 4.3.0

OpenAPI declaration file content or url
swagger: "2.0"
info:
  title: Issue
  version: "1.0.0"

paths:
  "/childs":
    get:
      summary: get list of childs
      operationId: listChilds
      produces:
      - application/json
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/Child'

definitions:

    Parent:
      type: object
      properties:
        bar:
          type: string

    Child:
      allOf:
      - $ref: '#/definitions/Parent'
      - type: object
      properties:
        foo:
          type: boolean
How to build
openApiGenerate {
    generatorName = "java"
    inputSpec = "$project.rootDir/networking-client-lib/specs/plugin_interface.yaml".toString()
    outputDir = "$buildDir/java".toString()
    modelPackage = "foo.bar"
    configOptions = [
            booleanGetterPrefix: "is"
    ]
    systemProperties = [
            models: ""
    ]
}

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 issue with the supplied Swagger 2.0 declaration and the Gradle openApiGenerate entry point using the Java generator. Compare generated output between versions 4.2.2 and 4.2.3; done means the Child model's generated hashCode() preserves a comma between inherited and local properties.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.