fix scalatra path with basepath (#1425) (#3448)

This commit is contained in:
Yi 2016-07-26 02:49:33 -04:00 committed by wing328
parent 30c2503f9f
commit b3403015fd
6 changed files with 17 additions and 17 deletions

View File

@ -12,7 +12,7 @@ class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
implicit val system = ActorSystem("appActorSystem")
try {
{{#apiInfo}}{{#apis}}context mount (new {{classname}}, "/{{baseName}}/*")
{{#apiInfo}}{{#apis}}context mount (new {{classname}}, "{{basePathWithoutHost}}/{{baseName}}/*")
{{/apis}}{{/apiInfo}}
context mount (new ResourcesApp, "/api-docs/*")
} catch {

View File

@ -23,7 +23,7 @@ class {{classname}} (implicit val swagger: Swagger) extends ScalatraServlet
protected implicit val jsonFormats: Formats = DefaultFormats
protected val applicationDescription: String = "{{classname}}"
override protected val applicationName: Option[String] = Some("{{baseName}}")
override protected val applicationName: Option[String] = Some("{{basePathWithoutHost}}/{{baseName}}")
before() {
contentType = formats("json")

View File

@ -34,9 +34,9 @@ class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
implicit val system = ActorSystem("appActorSystem")
try {
context mount (new PetApi, "/Pet/*")
context mount (new StoreApi, "/Store/*")
context mount (new UserApi, "/User/*")
context mount (new PetApi, "/v2/Pet/*")
context mount (new StoreApi, "/v2/Store/*")
context mount (new UserApi, "/v2/User/*")
context mount (new ResourcesApp, "/api-docs/*")
} catch {

View File

@ -46,7 +46,7 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet
protected implicit val jsonFormats: Formats = DefaultFormats
protected val applicationDescription: String = "PetApi"
override protected val applicationName: Option[String] = Some("Pet")
override protected val applicationName: Option[String] = Some("/v2/Pet")
before() {
contentType = formats("json")
@ -89,7 +89,7 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet
get("/pet/findByStatus", operation(findPetsByStatusOperation)) {
val statusString = params.getAs[String]("status")
val status = if ("csv".equals("default")) {
val status = if ("multi".equals("default")) {
statusString match {
case Some(str) => str.split(",")
case None => List()
@ -108,7 +108,7 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet
get("/pet/findByTags", operation(findPetsByTagsOperation)) {
val tagsString = params.getAs[String]("tags")
val tags = if ("csv".equals("default")) {
val tags = if ("multi".equals("default")) {
tagsString match {
case Some(str) => str.split(",")
case None => List()

View File

@ -44,7 +44,7 @@ class StoreApi(implicit val swagger: Swagger) extends ScalatraServlet
protected implicit val jsonFormats: Formats = DefaultFormats
protected val applicationDescription: String = "StoreApi"
override protected val applicationName: Option[String] = Some("Store")
override protected val applicationName: Option[String] = Some("/v2/Store")
before() {
contentType = formats("json")
@ -53,7 +53,7 @@ class StoreApi(implicit val swagger: Swagger) extends ScalatraServlet
val deleteOrderOperation = (apiOperation[Unit]("deleteOrder")
summary "Delete purchase order by ID"
parameters (pathParam[String]("orderId").description(""))
parameters (pathParam[Long]("orderId").description(""))
)
delete("/store/order/{orderId}", operation(deleteOrderOperation)) {

View File

@ -44,7 +44,7 @@ class UserApi(implicit val swagger: Swagger) extends ScalatraServlet
protected implicit val jsonFormats: Formats = DefaultFormats
protected val applicationDescription: String = "UserApi"
override protected val applicationName: Option[String] = Some("User")
override protected val applicationName: Option[String] = Some("/v2/User")
before() {
contentType = formats("json")