OpenAPITools / OpenAPITools/openapi-generator

[BUG] Generator overwriting/skipping shemas with same naming but different upper/lower cases

Open
#12,608 0 comments 0 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)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The actual reproduce-able sample is internal thus it is not easy for me to provide it as-is.
But I will the best I can to describe it.

Say we have 2 schemas: PavRequestBody and PAvRequestBody, both they look fine in swagger-ui.html and api-docs.json and api-docs.yaml
With separate entries in the schema section.

But the generated client bindings using openapi-generator (gradle-plugin) will not generate 2 model files accordingly (using java+retrofit2 but have tested also using a couple of other generators including some third party ones for Kotlin)
It will:

  1. If skipOverwrite.set(true), leave the second one unrecognized and be generating only the model class for the first one, yet APIs will have references towards both as they should have been. Thus symbol absence error is guaranteed later when we try to compile the generated binding codes.
  2. If skipOverwrite.set(false), the second one will be written directly into the same file where the first one was generated in. The file name left untouched, but the Java class name updated to the second one. Resulting in Java compilation filaure as well due to: top level class name should be the same as the Java source file name as we must know.

Intuitively shouldn't we be having
a PavRequestBody.java with public class PavRequestBody {...}
PLUS
a PAvRequestBody.java with public class PAvRequestBody {...}
?

The current implementation will generate either:
A correct PavRequestBody.java alone without any PAvRequestBody.java. (yet generated APIs still might be referring to both of them)
or
A file named PavRequestBody.java but containing public class PAvRquestBody.java

Either causes compilation failure.
Is it designed so or if it is a bug?

openapi-generator version

6.0.0

OpenAPI declaration file content or url
Generation Details
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 gradle-plugin using the Java/Retrofit2 generator and create a minimal spec containing PavRequestBody and PAvRequestBody schemas. Trace model filename and class-name handling, then verify that both distinct Java files are generated and compile without API references being skipped or overwritten.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.