OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java] OpenApi3 to Angular model - generation with oneOf
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
While generating angular model based on openapi3 json specification, the entity of model generated for types marked as "oneOf" has wrong name including "oneOf" prefix. But this type is not available because it is generated in separated file with proper name without this prefix.
OpenApi Generator:
openapi-generator-cli-4.0.3.jar
Initial c# class:
public class ProfileDetail
{
public ProfileData TypicalCustomerProfile { get; set; }
public ProfileData OutlierCustomerProfile { get; set; }
}
Input OpenApi3 JSON definition:
"ProfileDetail": {
"type": "object",
"additionalProperties": false,
"properties": {
"typicalCustomerProfile": {
"nullable": true,
"oneOf": [
{
"$ref": "#/components/schemas/ProfileData"
}
]
},
"outlierCustomerProfile": {
"nullable": true,
"oneOf": [
{
"$ref": "#/components/schemas/ProfileData"
}
]
}
}
},
Generated model - incorrect:
import { OneOfProfileData } from './oneOfProfileData';
export interface ProfileDetail {
typicalCustomerProfile?: OneOfProfileData | null;
outlierCustomerProfile?: OneOfProfileData | null;
}
Expected:
import { ProfileData } from './ProfileData';
export interface ProfileDetail {
typicalCustomerProfile?: ProfileData | null;
outlierCustomerProfile?: ProfileData | null;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with openapi-generator-cli-4.0.3.jar using the supplied OpenAPI3 ProfileDetail schema and Angular generation. Inspect the Angular generator's handling of oneOf models, then verify that the generated ProfileDetail imports and references ProfileData rather than OneOfProfileData, with no oneOf-prefixed file reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, java, openapi, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100