Update the base class as below:
Animal:
type: object
required:
- className
properties:
className:
type: string
color:
type: string
default: 'red'
This made the the code generation work as expected. Thanks Ron!
Now the follow up question. In 2.1.2 ( the last version of generator I
used), the inheritance was specified by
allof
- $ref
construct and composition by '$ref'. Is 'discriminator' a relatively recent
thing? When was it introduced?
Thanks,
On Friday, March 10, 2017 at 7:16:21 PM UTC-8, Ron wrote:
>
> For the sake of others – Arkady and I talked about the issue on IRC.
>
> The solution for inheritance is to use the `discriminator` in the models.
>
> As it is described in the attached YAML, it’s ‘only’ composition.
>
>
>
>
>
> *From: *<[email protected] <javascript:>> on behalf of
> Arkady Trestman <[email protected] <javascript:>>
> *Reply-To: *"[email protected] <javascript:>" <
> [email protected] <javascript:>>
> *Date: *Friday, 10 March 2017 at 17:13
> *To: *Swagger <[email protected] <javascript:>>
> *Subject: *is inheritance broken in swagger-codegen-cli 2.2.1/2.2.2 for
> java spring
>
>
>
> I have the following yaml specification
>
>
>
> Cat:
>
> allOf:
>
> - $ref: '#/definitions/Animal'
>
> - type: object
>
> properties:
>
> declawed:
>
> type: boolean
>
> Animal:
>
> type: object
>
> properties:
>
> color:
>
> type: string
>
> default: 'red'
>
>
>
> which is not resulting in java code generated as
>
>
>
> public class Cat extends Animal { ... }
>
>
>
> Please advise,
>
> Arkady.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Swagger" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.