swagger-play icon indicating copy to clipboard operation
swagger-play copied to clipboard

Basic Auth Support

Open yeryomenkom opened this issue 7 years ago • 1 comments

How can I add in the root of generated json file this part? "securityDefinitions":{ "basic_auth":{ "type":"basic", "name":"basic" } }

yeryomenkom avatar Jan 13 '17 01:01 yeryomenkom

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)
  }
}

dwickern avatar Mar 14 '17 21:03 dwickern