swagger-play
swagger-play copied to clipboard
Basic Auth Support
How can I add in the root of generated json file this part?
"securityDefinitions":{ "basic_auth":{ "type":"basic", "name":"basic" } }
I had the same issue. You can subclass the SwaggerBaseApiController with your own getResources:
class MyApiController extends SwaggerBaseApiController {
def getResources = Action {
request =>
implicit val requestHeader: RequestHeader = request
val host = requestHeader.host
val resourceListing = getResourceListing(host)
resourceListing.addSecurityDefinition("basic_auth", new BasicAuthDefinition)
val responseStr = returnXml(request) match {
case true => toXmlString(resourceListing)
case false => toJsonString(resourceListing)
}
returnValue(request, responseStr)
}
}