8000 json schema inheritance using allOf generates empty child classes · Issue #50 · fralken/sbt-swagger-codegen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
json schema inheritance using allOf generates empty child classes #50
Open
@dwunsch
Description
@dwunsch

this description

"Person" : {
    "type" : "object",
   "discriminator": ...,
    "properties" : { ... }
},
"Company" : {
    "allOf" : [
        {
            "$ref" : "#/definitions/Person"
        },
        {
            "type" : "object",
            "properties" : { ... }
        } 
    ]
}

generates a working Person case class, but Company is generated as

case object Company

even if Company does have its own properties.

the Model in this case turns out to be a ComposedModel which, although it does not have properties itself, it does have a getAllOf method, so just accumulating properties is easy.

more difficult here is handling the discriminator: Person should really be a sealed trait (?) and Company an implementation of that trait. sadly, how exactly the discriminator property can be used to find out which subtype of Person to deserialize is not properly defined yet, see OAI/OpenAPI-Specification#403 .

for now i propose to generate Person as before and have subtypes like Company include the discriminator field, so the user is responsible to set the correct value ther manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0