Skip to content

Commit

Permalink
Updated samples
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronp committed Oct 21, 2024
1 parent 04475e5 commit c5f0dff
Show file tree
Hide file tree
Showing 27 changed files with 2,272 additions and 2,219 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.10.0-SNAPSHOT
7.10.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi" : "3.1.0",
"openapi" : "3.0.0",
"info" : {
"description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
"license" : {
Expand Down Expand Up @@ -381,7 +381,8 @@
"additionalProperties" : {
"format" : "int32",
"type" : "integer"
}
},
"type" : "object"
}
}
},
Expand Down Expand Up @@ -838,6 +839,7 @@
}
},
"title" : "Pet Order",
"type" : "object",
"xml" : {
"name" : "Order"
}
Expand All @@ -855,6 +857,7 @@
}
},
"title" : "Pet category",
"type" : "object",
"xml" : {
"name" : "Category"
}
Expand Down Expand Up @@ -891,6 +894,7 @@
}
},
"title" : "a User",
"type" : "object",
"xml" : {
"name" : "User"
}
Expand All @@ -907,6 +911,7 @@
}
},
"title" : "Pet Tag",
"type" : "object",
"xml" : {
"name" : "Tag"
}
Expand Down Expand Up @@ -954,6 +959,7 @@
},
"required" : [ "name", "photoUrls" ],
"title" : "a Pet",
"type" : "object",
"xml" : {
"name" : "Pet"
}
Expand All @@ -972,7 +978,8 @@
"type" : "string"
}
},
"title" : "An uploaded response"
"title" : "An uploaded response",
"type" : "object"
},
"updatePetWithForm_request" : {
"properties" : {
Expand All @@ -984,7 +991,8 @@
"description" : "Updated status of the pet",
"type" : "string"
}
}
},
"type" : "object"
},
"uploadFile_request" : {
"properties" : {
Expand All @@ -997,7 +1005,8 @@
"format" : "binary",
"type" : "string"
}
}
},
"type" : "object"
}
},
"securitySchemes" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
//> using scala "3.3.1"
//> using lib "com.lihaoyi::cask:0.9.2"
//> using lib "com.lihaoyi::scalatags:0.8.2"
/** OpenAPI Petstore This is a sample server Petstore server. For this sample, you can use the api
* key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/

// this file was generated from app.mustache
package cask.groupId.server
Expand All @@ -20,33 +21,35 @@ import scala.util.Try
import _root_.sample.cask.model.*
import _root_.sample.cask.api.*

/** This trait encapsulates the business logic (services) and the http routes which handle the http
* requests sent to those services.
*
* There are default 'not implemented' implementations for the service.
*
* If you wanted fine-grained control over the routes and services, you could extend the
* cask.MainRoutes and mix in this trait by using this:
*
* ```
* override def allRoutes = appRoutes
* ```
*
* More typically, however, you would extend the 'BaseApp' class
*/
/**
* This trait encapsulates the business logic (services) and the
* http routes which handle the http requests sent to those services.
*
* There are default 'not implemented' implementations for the service.
*
* If you wanted fine-grained control over the routes and services, you could
* extend the cask.MainRoutes and mix in this trait by using this:
*
* ```
* override def allRoutes = appRoutes
* ```
*
* More typically, however, you would extend the 'BaseApp' class
*/
trait AppRoutes {
def appPetService: PetService[Try] = PetService()
def routeForPet: PetRoutes = PetRoutes(appPetService)
def appPetService : PetService[Try] = PetService()
def routeForPet : PetRoutes = PetRoutes(appPetService)

def appStoreService: StoreService[Try] = StoreService()
def routeForStore: StoreRoutes = StoreRoutes(appStoreService)
def appStoreService : StoreService[Try] = StoreService()
def routeForStore : StoreRoutes = StoreRoutes(appStoreService)

def appUserService: UserService[Try] = UserService()
def routeForUser: UserRoutes = UserRoutes(appUserService)
def appUserService : UserService[Try] = UserService()
def routeForUser : UserRoutes = UserRoutes(appUserService)

def appRoutes = Seq(
routeForPet,
routeForStore,
routeForUser
)

def appRoutes = Seq(
routeForPet ,
routeForStore ,
routeForUser
)
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
//> using scala "3.3.1"
//> using lib "com.lihaoyi::cask:0.9.2"
//> using lib "com.lihaoyi::scalatags:0.8.2"
/** OpenAPI Petstore This is a sample server Petstore server. For this sample, you can use the api
* key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/


// this file was generated from app.mustache
package cask.groupId.server
Expand All @@ -20,36 +22,39 @@ import scala.util.Try
import _root_.sample.cask.model.*
import _root_.sample.cask.api.*

/** This class was created with the intention of being extended by some runnable object, passing in
* the custom business logic services
*/
/**
* This class was created with the intention of being extended by some runnable object,
* passing in the custom business logic services
*/
class BaseApp(
override val appPetService: PetService[Try] = PetService(),
override val appStoreService: StoreService[Try] = StoreService(),
override val appUserService: UserService[Try] = UserService(),
override val port: Int = sys.env.get("PORT").map(_.toInt).getOrElse(8080)
) extends cask.MainRoutes
with AppRoutes {
override val appPetService : PetService[Try] = PetService(),

override val appStoreService : StoreService[Try] = StoreService(),

override val appUserService : UserService[Try] = UserService(),
override val port : Int = sys.env.get("PORT").map(_.toInt).getOrElse(8080)) extends cask.MainRoutes with AppRoutes {

/** routes for the UI
* Subclasses can override to turn this off
*/
def openApiRoute: Option[cask.Routes] = Option(OpenApiRoutes(port))

/** routes for the UI Subclasses can override to turn this off
*/
def openApiRoute: Option[cask.Routes] = Option(OpenApiRoutes(port))
override def allRoutes = appRoutes ++ openApiRoute

override def allRoutes = appRoutes ++ openApiRoute

override def host: String = "0.0.0.0"
override def host: String = "0.0.0.0"

def start() = locally {
initialize()
println(box(s""" 🚀 browse to localhost:$port 🚀
def start() = locally {
initialize()
println(box(s""" 🚀 browse to localhost:$port 🚀
| host : $host
| port : $port
| verbose : $verbose
| debugMode : $debugMode
|""".stripMargin))

// if java.awt.Desktop.isDesktopSupported then {
// java.awt.Desktop.getDesktop.browse(new java.net.URI(s"http://localhost:${port}"))
// }
}
// if java.awt.Desktop.isDesktopSupported then {
// java.awt.Desktop.getDesktop.browse(new java.net.URI(s"http://localhost:${port}"))
// }
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
//> using scala "3.3.1"
//> using dep "com.lihaoyi::cask:0.9.2"
//> using dep "com.lihaoyi::scalatags:0.8.2"
/** OpenAPI Petstore This is a sample server Petstore server. For this sample, you can use the api
* key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/


// this file was generated from app.mustache
package cask.groupId.server
Expand All @@ -27,10 +29,11 @@ object MoreRoutes extends cask.Routes {
initialize()
}

/** This is an example of how you might extends BaseApp for a runnable application.
*
* See the README.md for how to create your own app
*/
/**
* This is an example of how you might extends BaseApp for a runnable application.
*
* See the README.md for how to create your own app
*/
object ExampleApp extends BaseApp() {
// override to include our additional route
override def allRoutes = super.allRoutes ++ Option(MoreRoutes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/** OpenAPI Petstore This is a sample server Petstore server. For this sample, you can use the api
* key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator.
*
* https://openapi-generator.tech
*/


// generated from openapiRoute.mustache
package sample.cask.api
Expand All @@ -17,13 +19,14 @@ import cask.model.Response

import java.nio.file.{Files, Path, Paths}

/** This code will try and download the swagger UI static files on startup
*
* That behaviour can be altered by:
* - setting the environment variable SWAGGER_ON to false
* - setting the environment variable SWAGGER_UI_URL to either the URL of a swagger UI zip or
* setting it to the empty string
*/
/**
* This code will try and download the swagger UI static files on startup
*
* That behaviour can be altered by:
* - setting the environment variable SWAGGER_ON to false
* - setting the environment variable SWAGGER_UI_URL to either the URL of a swagger UI zip or setting it to the empty string
*
*/
object OpenApiRoutes {

def swaggerUIUrl: Option[String] = {
Expand Down Expand Up @@ -87,7 +90,7 @@ class OpenApiRoutes(localPort: Int, swaggerUrl: Option[String]) extends cask.Rou
}
}

if (extracted.isFailure) {
if (extracted.isFailure) {
println(s"Error extracting swagger: ${extracted}")
} else {
println(s"Extracting swagger: ${extracted}")
Expand All @@ -111,8 +114,7 @@ class OpenApiRoutes(localPort: Int, swaggerUrl: Option[String]) extends cask.Rou

// keeping this compatible for java 8, where this is from >= java 11:
// Files.writeString(fullPath, textLines.mkString("\n"))
scala.util
.Using(new java.io.PrintWriter(fullPath.toFile))(_.write(textLines.mkString("\n")))
scala.util.Using(new java.io.PrintWriter(fullPath.toFile))(_.write(textLines.mkString("\n")))
} else {
Using(new FileOutputStream(filePath)) { outputStream =>
val buffer = new Array[Byte](1024)
Expand Down
Loading

0 comments on commit c5f0dff

Please sign in to comment.