-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
The following spec is valid:
{
"interfaces": {
"shape": {
"fields": [
{ "name": "sides", "type": "integer", "description": "Indicates the number of sides a shape has"}
]
}
},
"unions": {
"shape": {
"interfaces": ["shape"],
"discriminator": "type",
"types": [
{ "type": "shape_circle", "discriminator_value": "circle"},
{ "type": "shape_square", "discriminator_value": "square"},
{ "type": "shape_triangle", "discriminator_value": "triangle"},
]
}
},
"models": {
"shape_circle": {
"description": "This is a circle.",
"fields": [
{ "name": "radius", "type": "decimal" }
]
},
"shape_square": {
"description": "This is a square.",
"fields": [
{ "name": "length", "type": "decimal" }
{ "name": "height", "type": "decimal" }
]
},
"shape_triangle": {
"description": "This is a triangle.",
"fields": [
{ "name": "triangle_type", "type": "TriangleTypeEnum" }
]
},
}
}However, when running the apibuilder command on this spec, the generated classes will extend the trait Shape, but not generate the overridden field for sides. The example of this output would look something like:
class Circle needs to be abstract. Missing implementation for:
def sides: Integer // inherited from trait Shape
final case class Circle(radius: Decimal) extends Shape
The workaround for this has been to explicitly add the interface fields to the models fields array, however we should most likely consider this spec json invalid before we even get to code generation.
Metadata
Metadata
Assignees
Labels
No labels