Contributions
Re: Simple Discrimination
Thank you for replying. I was able to get it to work exactly as I expected, and the swagger yaml still ends up looking sane. So I am happy. The solutions are around the web, so I didn't want to sum up my solution here (I don't know if what I'm doing is too esoteric). If you wish, I can drop in a summary of what's need to tie it all together. You probably already are aware of it. In terms of the 3.0.0 branch of the generator, there seems to be a bug in the docs concerning this (at least).2KViews0likes1CommentSimple Discrimination
I am using `editor.swagger.io` to generate a java client. In that client, I am directly using the `JSON` class to deserialize a very simple JSON string, and to see what Swagger does. The challenge I am giving Swagger is simple discrimination. Here is my Swagger YAML. (Note this may not be a useful Swagger schema. It is just for experimentation) swagger: "2.0" info: title: "Minimal Example" version: "0.0.1" tags: [] paths: {} definitions: Decorator: type: object required: - type properties: type: type: string OinkDecorator: allOf: - $ref: '#/definitions/Decorator' - type: object required: - oink properties: oink: type: string FooDecorator: allOf: - $ref: '#/definitions/Decorator' - type: object required: - foo properties: foo: type: string FieldModel: type: object properties: decorators: type: array items: $ref: '#/definitions/OinkDecorator' And the JSON I am trying to deserialize: { "type" : "asdasd", "decorators" : [{ "type":"asqqweqwe", "oink": "adfasdf"}] } More info: So, I am trying to deserialize this JSON as a FieldModel. If I were to change the Swagger schema to NOT have two possible child fields (Oink and Foo), the deserialization happens as expected (e.g. I get a FieldModel which contains and Oink. However, as it appears above (even with a discriminator), what I can't seem to avoid is getting a FieldModel with a simple Map representation of the child. Does discrimination work in deserialization? Am I not employing it correctly? Any ideas are appreciated. Please and thank you.Solved2.1KViews0likes3Comments