Hey Ron, it was my fault. I made an error in my swagger definition that caused no syntax error and the generated subclass had the correct extension but were empty. Now I correced my mistake and the subclasses are generated correctly. Now I have another iussue. I am using specification 2.0 and also generated a java client out of my swagger definition. I have a call that returns an array of *MyModel*. But it also contains data of type *MyExtendedModel1* and *MyExtendedModel2*. When the client recieves the data it only instantiates classes of type *MyModel* and no subclasses. Although the JSON stream contains the information about the subclasses. Is there any possibility that also subclasses are instantiated on client side with v. 2.0? Or should I use version 3.0? The spec. looks like that there this issue is solved. Do I have to migrate my swagger defintion (I couldn't find any docs about it) or can I just use version 3.0 without any changes?
Thanks Am Montag, 9. Oktober 2017 10:07:43 UTC+2 schrieb Philipp: > > There is a big bug in code generation for Java JAX-RS (serverside) when > extended models are used. For example I have a Sawgger definition like this: > ... > MyModel: > type: object > discriminator: type > properties: > type: > type: string > enum: > - MyExtendedModel1 > - MyExtendedModel2 > status: > type: string > id: > type: integer > > MyExtendedModel1: > type: object > allOf: > - $ref: '#/definitions/MyModel' > properties: > name: > type: string > > MyExtendedModel2: > type: object > allOf: > - $ref: '#/definitions/MyModel' > properties: > address: > type: string > ... > > > The generation generates 3 classes: *MyModel*, *MyExtendedModel1 extends > MyModel*, *MyExtendedModel2 extends MyModel*. That is correct. The class > *MyModel* has all attributes how they are defined in Swagger. > The Error is in extended classes *MyExtendedModel1 *and *MyExtendedModel2. > *They have no attributes (*name* for class *MyExtendedModel1* is missing > and *address* for class *MyExtendedModel2*), neither the *equals()*, > *hashCode()* or *toString()* method refers to the super class *MyModel*. > -- 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.
