scalatra/scalatra — pull request #415 by ahaid (2014-08-14 22:53:51+00:00)
Title: Added a HashMap called properties to the SwaggerEngine trait for configuring previously hardcoded values

The first iteration of these properties is for setting baseUrl paramters. First two properties are baseUrl.includeContextPath (default true) and baseUrl.includeServletPath (default false). Those properties are used when calling fullUrl which uses the UrlGenerator to fetch the baseUrl of the swagger doc.

To set properties from scalatra, configure the bootstrap file as follows:

class ScalatraBootstrap extends LifeCycle {
implicit val swagger = new Swagger
override def init(context: ServletContext) {
context.initParameters("swagger.api.basepath") = "http:/mydomain"
// This will set one of the new properties in the SwaggerEngine
swagger.properties("baseUrl.includeContextPath") = false
/* attach the resource listing */
context mount (new ResourcesApp, "/api-docs/*")
/* attach controllers */
context mount (new MyController(), "/my", "my")
}
}