[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Swagger securityDefinition


Hi guys

I’ve deployed Redhat SSO/ Key cloak and am successfully able to use it as a bearer-only client to verify tokens before executing webservices as defined by my restConfiguration

What I would like to do next is extend the swagger doc that gets generated to include securityDefinitions for documentation purposes like this:
   "securityDefinitions":{  
      "petstore_auth":{  
         "type":"oauth2",
         "authorizationUrl":"http://petstore.swagger.io/oauth/dialog";,
         "flow":"implicit",
         "scopes":{  
            "write:pets":"modify pets in your account",
            "read:pets":"read your pets"
         }
      },
      "api_key":{  
         "type":"apiKey",
         "name":"api_key",
         "in":"header"
      }
   }

Example from http://petstore.swagger.io/

I see I am able to give the restConfig it’s own apiComponent but do not see how to get something like:
        Swagger swagger = new Swagger().info(info);
        swagger.securityDefinition("petstore_auth",
                new OAuth2Definition()
                        .implicit("http://petstore.swagger.io/api/oauth/dialog";)
                        .scope("read:pets", "read your pets")
                        .scope("write:pets", "modify pets in your account"));
Into the component 

Has anyone done something like this before? The only clues I have found online is that someone suggested extending camel-swagger-java to achieve this. A kick in the direction of how to do that will also be welcome

Holding thumbs!

Thanks
Riaan


Sent from Mail for Windows 10