-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,272 additions
and
2,219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.10.0-SNAPSHOT | ||
7.10.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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}")) | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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] = { | ||
|
@@ -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}") | ||
|
@@ -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) | ||
|
Oops, something went wrong.