forked from loafle/openapi-generator-original
updated sample
This commit is contained in:
parent
02b5a929ac
commit
b7ed61b8f9
@ -24,6 +24,8 @@ libraryDependencies ++= Seq(
|
||||
"javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided;container;test;runtime"
|
||||
)
|
||||
|
||||
resolvers += Resolver.url("local-ivy", new URL("file://" + Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)
|
||||
|
||||
resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
|
||||
|
||||
ivyXML := <dependencies>
|
||||
|
@ -7,65 +7,73 @@ import org.scalatra.swagger._
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
class PetApi(implicit val swagger: Swagger) extends ScalatraServlet with SwaggerBase with SwaggerSupport {
|
||||
class PetApi (implicit val swagger: Swagger) extends ScalatraServlet with SwaggerBase with SwaggerSupport {
|
||||
protected def buildFullUrl(path: String) = "http://petstore.swagger.wordnik.com/api/%s" format path
|
||||
|
||||
get("/:petId",
|
||||
summary("Find pet by ID"),
|
||||
nickname("getPetById"),
|
||||
responseClass("Pet"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/pet.{format}/{petId}"),
|
||||
notes("Returns a pet based on ID"),
|
||||
parameters(
|
||||
Parameter("petId", "ID of pet that needs to be fetched",
|
||||
dataType = DataType.String,
|
||||
paramType = ParamType.Path))) {
|
||||
}
|
||||
paramType = ParamType.Path)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
post("/",
|
||||
summary("Add a new pet to the store"),
|
||||
nickname("addPet"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/pet.{format}"),
|
||||
notes(""),
|
||||
parameters(
|
||||
Parameter("body", "Pet object that needs to be added to the store",
|
||||
dataType = DataType("Pet"),
|
||||
paramType = ParamType.Body))) {
|
||||
}
|
||||
paramType = ParamType.Body)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
put("/",
|
||||
summary("Update an existing pet"),
|
||||
nickname("updatePet"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/pet.{format}"),
|
||||
notes(""),
|
||||
parameters(
|
||||
Parameter("body", "Pet object that needs to be updated in the store",
|
||||
dataType = DataType("Pet"),
|
||||
paramType = ParamType.Body))) {
|
||||
}
|
||||
paramType = ParamType.Body)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
get("/findByStatus",
|
||||
summary("Finds Pets by status"),
|
||||
nickname("findPetsByStatus"),
|
||||
responseClass("List[Pet]"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/pet.{format}/findByStatus"),
|
||||
notes("Multiple status values can be provided with comma seperated strings"),
|
||||
parameters(
|
||||
Parameter("status", "Status values that need to be considered for filter",
|
||||
paramType = ParamType.Query,
|
||||
required = true,
|
||||
allowMultiple = true,
|
||||
allowableValues = "LIST[available,pending,sold]", defaultValue = Some("available"),
|
||||
dataType = DataType("String")))) {
|
||||
}
|
||||
allowableValues = AllowableValues("LIST[available,pending,sold]"),defaultValue = Some("available"),
|
||||
dataType = DataType("String"))
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
get("/findByTags",
|
||||
summary("Finds Pets by tags"),
|
||||
nickname("findPetsByTags"),
|
||||
responseClass("List[Pet]"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/pet.{format}/findByTags"),
|
||||
notes("Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing."),
|
||||
parameters(
|
||||
Parameter("tags", "Tags to filter by",
|
||||
@ -73,7 +81,9 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet with Swagger
|
||||
required = true,
|
||||
allowMultiple = true,
|
||||
defaultValue = None,
|
||||
dataType = DataType("String")))) {
|
||||
}
|
||||
dataType = DataType("String"))
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,43 +7,49 @@ import org.scalatra.swagger._
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
class StoreApi(implicit val swagger: Swagger) extends ScalatraServlet with SwaggerBase with SwaggerSupport {
|
||||
class StoreApi (implicit val swagger: Swagger) extends ScalatraServlet with SwaggerBase with SwaggerSupport {
|
||||
protected def buildFullUrl(path: String) = "http://petstore.swagger.wordnik.com/api/%s" format path
|
||||
|
||||
get("/order/:orderId",
|
||||
summary("Find purchase order by ID"),
|
||||
nickname("getOrderById"),
|
||||
responseClass("Order"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/store.{format}/order/{orderId}"),
|
||||
notes("For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors"),
|
||||
parameters(
|
||||
Parameter("orderId", "ID of pet that needs to be fetched",
|
||||
dataType = DataType.String,
|
||||
paramType = ParamType.Path))) {
|
||||
}
|
||||
paramType = ParamType.Path)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
delete("/order/:orderId",
|
||||
summary("Delete purchase order by ID"),
|
||||
nickname("deleteOrder"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/store.{format}/order/{orderId}"),
|
||||
notes("For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors"),
|
||||
parameters(
|
||||
Parameter("orderId", "ID of the order that needs to be deleted",
|
||||
dataType = DataType.String,
|
||||
paramType = ParamType.Path))) {
|
||||
}
|
||||
paramType = ParamType.Path)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
post("/order",
|
||||
summary("Place an order for a pet"),
|
||||
nickname("placeOrder"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/store.{format}/order"),
|
||||
notes(""),
|
||||
parameters(
|
||||
Parameter("body", "order placed for purchasing the pet",
|
||||
dataType = DataType("Order"),
|
||||
paramType = ParamType.Body))) {
|
||||
}
|
||||
paramType = ParamType.Body)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,92 +7,102 @@ import org.scalatra.swagger._
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
class UserApi(implicit val swagger: Swagger) extends ScalatraServlet with SwaggerBase with SwaggerSupport {
|
||||
class UserApi (implicit val swagger: Swagger) extends ScalatraServlet with SwaggerBase with SwaggerSupport {
|
||||
protected def buildFullUrl(path: String) = "http://petstore.swagger.wordnik.com/api/%s" format path
|
||||
|
||||
post("/createWithArray",
|
||||
summary("Creates list of users with given input array"),
|
||||
nickname("createUsersWithArrayInput"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}/createWithArray"),
|
||||
notes(""),
|
||||
parameters(
|
||||
Parameter("body", "List of user object",
|
||||
dataType = DataType("Array[User]"),
|
||||
paramType = ParamType.Body))) {
|
||||
}
|
||||
paramType = ParamType.Body)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
post("/",
|
||||
summary("Create user"),
|
||||
nickname("createUser"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}"),
|
||||
notes("This can only be done by the logged in user."),
|
||||
parameters(
|
||||
Parameter("body", "Created user object",
|
||||
dataType = DataType("User"),
|
||||
paramType = ParamType.Body))) {
|
||||
}
|
||||
paramType = ParamType.Body)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
post("/createWithList",
|
||||
summary("Creates list of users with given list input"),
|
||||
nickname("createUsersWithListInput"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}/createWithList"),
|
||||
notes(""),
|
||||
parameters(
|
||||
Parameter("body", "List of user object",
|
||||
dataType = DataType("List[User]"),
|
||||
paramType = ParamType.Body))) {
|
||||
}
|
||||
paramType = ParamType.Body)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
put("/:username",
|
||||
summary("Updated user"),
|
||||
nickname("updateUser"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}/{username}"),
|
||||
notes("This can only be done by the logged in user."),
|
||||
parameters(
|
||||
Parameter("username", "name that need to be deleted",
|
||||
dataType = DataType.String,
|
||||
paramType = ParamType.Path)
|
||||
Parameter ("username", "name that need to be deleted",
|
||||
dataType = DataType("String"),
|
||||
paramType = ParamType.Body),
|
||||
,
|
||||
Parameter("body", "Updated user object",
|
||||
dataType = DataType("User"),
|
||||
paramType = ParamType.Body))) {
|
||||
}
|
||||
paramType = ParamType.Body)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
delete("/:username",
|
||||
summary("Delete user"),
|
||||
nickname("deleteUser"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}/{username}"),
|
||||
notes("This can only be done by the logged in user."),
|
||||
parameters(
|
||||
Parameter("username", "The name that needs to be deleted",
|
||||
dataType = DataType.String,
|
||||
paramType = ParamType.Path))) {
|
||||
}
|
||||
paramType = ParamType.Path)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
get("/:username",
|
||||
summary("Get user by user name"),
|
||||
nickname("getUserByName"),
|
||||
responseClass("User"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}/{username}"),
|
||||
notes(""),
|
||||
parameters(
|
||||
Parameter("username", "The name that needs to be fetched. Use user1 for testing.",
|
||||
dataType = DataType.String,
|
||||
paramType = ParamType.Path))) {
|
||||
}
|
||||
paramType = ParamType.Path)
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
get("/login",
|
||||
summary("Logs user into the system"),
|
||||
nickname("loginUser"),
|
||||
responseClass("String"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}/login"),
|
||||
notes(""),
|
||||
parameters(
|
||||
Parameter("username", "The user name for login",
|
||||
@ -100,22 +110,26 @@ class UserApi(implicit val swagger: Swagger) extends ScalatraServlet with Swagge
|
||||
required = true,
|
||||
allowMultiple = false,
|
||||
defaultValue = None,
|
||||
dataType = DataType("String")),
|
||||
dataType = DataType("String"))
|
||||
,
|
||||
Parameter("password", "The password for login in clear text",
|
||||
paramType = ParamType.Query,
|
||||
required = true,
|
||||
allowMultiple = false,
|
||||
defaultValue = None,
|
||||
dataType = DataType("String")))) {
|
||||
}
|
||||
dataType = DataType("String"))
|
||||
|
||||
)) {
|
||||
}
|
||||
|
||||
get("/logout",
|
||||
summary("Logs out current logged in user session"),
|
||||
nickname("logoutUser"),
|
||||
responseClass("void"),
|
||||
endpoint("{TBD}"),
|
||||
endpoint("/user.{format}/logout"),
|
||||
notes(""),
|
||||
parameters()) {
|
||||
}
|
||||
parameters(
|
||||
)) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user