OpenAPITools / OpenAPITools/openapi-generator

openapi codegen generating invalid variable names in equals method for model

Open
#14,245 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When the openAPI definition has special type names like ShoppingCartResponse«Customer», the equals() method that is generated for the models are invalid when the generation mode is spring / spring-boot

openapi-generator version

openapi-generator-cli-6.2.1.jar

OpenAPI declaration file content or url

https://gist.github.com/tvraghavan/1675e078b9b9d05bca5c22c2f6033e5b

Command line used for generation

java -jar ..\openapi-generator-cli-6.2.1.jar generate --skip-operation-example -g spring --library spring-boot -i local-shoppingcart.json

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Request enhancement to generate right variable names in the equals method or ability to override the code generation template to handle such scenarios

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 by reproducing the issue with the linked OpenAPI declaration and the shown openapi-generator-cli 6.2.1 Spring command. Inspect the Spring/Spring Boot model generation and equals-method templates, then verify that generated variable names are valid Java identifiers and add a regression test for the ShoppingCartResponse«Customer» case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.