forked from loafle/openapi-generator-original
parent
30c2503f9f
commit
b3403015fd
@ -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 {
|
||||
|
@ -16,14 +16,14 @@ import org.scalatra.servlet.{FileUploadSupport, MultipartConfig, SizeConstraintE
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
class {{classname}} (implicit val swagger: Swagger) extends ScalatraServlet
|
||||
class {{classname}} (implicit val swagger: Swagger) extends ScalatraServlet
|
||||
with FileUploadSupport
|
||||
with JacksonJsonSupport
|
||||
with SwaggerSupport {
|
||||
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")
|
||||
@ -51,4 +51,4 @@ class {{classname}} (implicit val swagger: Swagger) extends ScalatraServlet
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ 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 {
|
||||
case e: Throwable => e.printStackTrace()
|
||||
|
@ -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()
|
||||
@ -181,4 +181,4 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet
|
||||
println("file: " + 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)) {
|
||||
@ -95,4 +95,4 @@ class StoreApi(implicit val swagger: Swagger) extends ScalatraServlet
|
||||
println("body: " + body)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
@ -151,4 +151,4 @@ class UserApi(implicit val swagger: Swagger) extends ScalatraServlet
|
||||
println("body: " + body)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user