SecurityDefinition Use in Java Code

333 views
Skip to first unread message

Bryan Nelson

unread,
Apr 12, 2017, 2:21:09 PM4/12/17
to Swagger
Greetings,

I'm working on a JAX-RS rest-based Java application in which I currently have Swagger working using Java annotations.  I'm trying to get some authorization working using the ApiKey approach.  I have an annotation in one of my operations that looks like this:

@ApiOperation(value = "Retrieves information",
authorizations = {
@Authorization(value = "specificKey")}) 
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Events not found") })
        public Response getInfo(...) {
            // code
        }

My question is surrounding how I set up the overall Security Definition in my swagger json.  I haven't been able to find a full example of how this is accomplished.  It seems like this could be done with an @SwaggerDefinition annotation or by perhaps by using a Swagger object itself.  However, I'm unsure if either of this is the correct approach, and if so where should I put one of them given my current setup which uses a BeanConfig in my extended javax.ws.rs.core.Application class.  

Any help or examples would be very much appreciated.

Thanks for your time!
bryan

Arthur De Magalhaes

unread,
Apr 13, 2017, 5:02:40 PM4/13/17
to Swagger
Hey,  


The snippet is merged with my annotations, when running on WebSphere Liberty with the apiDiscovery-1.0 feature enabled.
Reply all
Reply to author
Forward
0 new messages