Forum Discussion

Jarle's avatar
New Contributor
4 years ago

One Endpoint, multiple examples/Responses? (Java Annotations)

Hey, I'm using Swagger to document my Java API. This is using a Jersey resources/Jackson JSON objects and I want to document it using annotations in the code. The 3 swagger libraries I'm using are:

swagger-core, swagger-jaxrs2, swagger-models. 


The issue I keep running into is that I sometimes want to document different implementations for an endpoint but I'm not sure how to go about it.


To give a straigthforward example, I have the endpoint "/login" which takes the Jackson/POJO object "LoginAuthJson". The issue is that in this case a login can be initiated either by a Facebook user (where the object will contain a facebook ID and a token from facebook), or it can be a login from a registered email user (in which case the body contains an email and a password.). So I want to somehow be able to show example bodies for both facebook and email login separately. 


Any suggestion on how I can do something like this? 



Edit: so I have gotten the schema to work sort of like I Want using oneOf, but that doesn't seem to work for examples ğŸ˜ž 

No RepliesBe the first to reply