Reputation: 262
Ive a method that takes an object. The object is dynamic and it can be constructed in 5 differents ways depending on how many children it has and which type of object it is. I want it to be clear how to build this object and also show which children types thay can be used together.
Example A:new Michael(id,name, Type.A, new Sara(id, name, ChildrenType.B));
Example B: new Sandra(id,name,Type. C, new Pheno(id, name,ChildrenType.D), new Leo(id, name,ChildrenType.E));
As i said before, the object is dymanic and can be build in different ways depending on which type the object has and how many children it has.
I thought that the best way to show all of this would be to have 5 different example bodys in swagger. But idk if it is possible? Is it and is this the best solution for this?
And im using java, if it makes any diff which languages i use.
Thanks!
Upvotes: 0
Views: 2273
Reputation: 6824
If you have a common interface for the payload, you can use a discriminator to choose the different concrete types that can be instantiated.
Upvotes: 0
Reputation: 5441
You can define only one example per mime type. However your can use externalDocs to redirect to another page with all your examples.
Upvotes: 3