[BUG][JAVA] Referenced components with same name not distinguished when one starts with lowercase
Bug Report Checklist
- [x ] Have you provided a full/minimal spec to reproduce the issue?
- [ x] Have you validated the input using an OpenAPI validator (example)?
- [ x] Have you tested with the latest master to confirm the issue still exists?
- [x ] Have you searched for related issues/PRs?
- [x ] What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The generator does not generate classes correctly when there are referenced components with the same name but one of them starts with lowercase and the other one with uppercase.
Here is an example
cat.yaml
schemas:
Cat:
type: object
properties:
age:
type: integer
color:
type: string
sound:
$ref: '#/components/schemas/sound'
sound:
type: string
enum: [MEOUW, MRRR]dog.yaml
schemas:
Dog:
type: object
properties:
age:
type: integer
color:
type: string
sound:
$ref: '#/components/schemas/Sound'
Sound:
type: string
enum: [WOOF, RRRR]pet-shop.yaml
paths:
/cat/{catId}:
get:
operationId: getCat
description: Gets a cat
parameters:
- in: path
name: catId
description: Id of the cat
schema:
type: integer
required: true
responses:
'200':
description: 'OK'
content:
application/json:
schema:
$ref: 'cat.yaml#/components/schemas/Cat'
/dog/{dogId}:
get:
operationId: getDog
description: Gets a dog
parameters:
- in: path
name: dogId
description: Id of the dog
schema:
type: integer
required: true
responses:
'200':
description: 'OK'
content:
application/json:
schema:
$ref: 'dog.yaml#/components/schemas/Dog'When we run the generate-sources for pet-shop.yaml only one SoundDto.java enum is generated - the one that starts with lowercase and cosequently the DogDto contains an enum [MEOUW, MRRR].
If both enums are called Sound or sound, then the generator correctly generates two enums - SoundDto and Sound1Dto, but when one starts with lowercase and the other with uppercase, the lowercase takes precedence and as a result the Dog object gets an incorrect type for it's sound property.
The expected behavior is that the generator recognizes these are two different types and generates two different classes
openapi-generator version
7.11.0 but is also reproducible with earlier versions (6.6.0). Last known version that worked was 4.3.1 but there might be more versions that worked between 4.3.1 and 6.6.0
Steps to reproduce
Attached is the example project, it can be reproduced by running maven
Source: OpenAPITools/openapi-generator