Inherited properties are duplicated
See original GitHub issueThe polymorphism implemented in PR #1152 seems to not work correctly. Properties defined in the parent type are also present in the subtype but according to the oas 3.0 spec only additional properties should be in the subtype.
@ApiModel(subTypes = {Car.class})
class Vehicle {
private String make;
}
@ApiModel(parent = Vehicle.class)
class Car extends Vehicle {
private int seatingCapacity;
}
actual output:
{
"Car": {
"title": "Car",
"allOf": [
{
"$ref": "#/definitions/Vehicle"
},
{
"type": "object",
"properties": {
"make": {
"type": "string"
},
"seatingCapacity": {
"type": "integer",
"format": "int32"
}
},
"title": "Car"
}
]
}
}
expected output (without make property inherited from vehicle):
{
"Car": {
"title": "Car",
"allOf": [
{
"$ref": "#/definitions/Vehicle"
},
{
"type": "object",
"properties": {
"seatingCapacity": {
"type": "integer",
"format": "int32"
}
},
"title": "Car"
}
]
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (6 by maintainers)
Top Results From Across the Web
Avoid duplicate actions for base class properties
Create a function to check for base type errors and call that function inside other two types. Something like:
Read more >Inheritance is a hammer. Eliminating code duplication is not a ...
I'm telling you that inheritance is one tool in your toolbelt, and it has its uses. But it isn't the right tool for...
Read more >Duplicate inherited attributes during Hybris5 migration
Hello, I'm working on the migration of an Hybris 4.8 to an Hybris 5.0 Shop. In the old shop the type AbstractPage is...
Read more >About the Duplicate Properties wizard - Pega Community
As a best practice for runtime performance, avoid having multiple properties in one class inheritance chain that have the same Property Name key...
Read more >Acquiring Duplicate Documents of your Inherited Property
Services. Acquiring Duplicate Documents of Your Inherited Property. Ancestral Real Estate & Inheritance Advisory · Apostilization & Attestation of Documents ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bob-walters absolutely!
@cy-ddg There is a plan to do it as part of #3070
I’m facing the same problem. It’s a bit annoying, because swagger-codegen-cli for csharp creates deditcated properties in the derived model objects, which hide the same properties in the base object (which is wrong for obvious reasons), and the generated code can’t compile as it doesn’t initialize those properties in the base constructors of those objects. One could argue, that it’s a problem in swagger-codegen, however, I do also think that the properties shouldn’t be duplicated. by the way, using the swagger-maven-plugin to generate the api specification from the swagger annotations at compile time, those properties aren’t duplicated. (the maven plugin has different issues though that also create faulty api specs, but in a different way…)