OpenAPITools / OpenAPITools/openapi-generator
[BUG] Fix parentVars and emptyVars in Swift 5 generator
Nobody has claimed this yet.
- 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? - In case of ClassC > ClassB > ClassA, ClassC's
parentVarsdoesn't contain properties of ClassB, only of ClassA. - [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating Swift 5, the parentVars property was wrongly set for multi-level inheritance (Class C > Class B > Class A). Also emptyVars was never set.
openapi-generator version
5.1.1
OpenAPI declaration file content or url
{
"swagger": "2.0",
"info": {
"version": "1.0.5",
"title": "Swagger Petstore"
},
"paths": {
},
"definitions": {
"ClassA": {
"discriminator": "@type",
"type": "object",
"properties": {
"propertyA": {
"type": "string"
}
}
},
"ClassB": {
"allOf": [
{
"$ref": "#/definitions/ClassA"
},
{
"type": "object",
"discriminator": "@type",
"properties": {
"propertyB": {
"type": "string"
},
"propertyA": {
"type": "string"
}
}
}
]
},
"ClassC": {
"allOf": [
{
"$ref": "#/definitions/ClassB"
},
{
"type": "object",
"properties": {
"propertyA": {
"type": "string"
},
"propertyB": {
"type": "string"
},
"propertyC": {
"type": "string"
}
}
}
]
}
}
}
Generation Details
When running OAG with debugModels flag, the mentioned values are wrongly shown, because they're wrongly set.
Steps to reproduce
Run OAG with the above posted JSON as input and debugModels flag enabled.
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/9244
Suggest a fix
Fixed in https://github.com/OpenAPITools/openapi-generator/pull/9244
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
Start by running OpenAPI Generator with the supplied JSON input, the Swift 5 generator, and the debugModels flag. Inspect the Swift 5 generator's handling of multi-level inheritance; done means Class C's parentVars includes Class B properties and emptyVars is populated, with regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 20/100