mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
update akka-http and pekko-http server generator and example (#21166)
This commit is contained in:
parent
3bac186b2f
commit
56eb8f7bc9
@ -18,7 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|akkaHttpVersion|The version of akka-http| |10.1.10|
|
||||
|akkaHttpVersion|The version of akka-http| |10.2.9|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactId|artifactId| |openapi-scala-akka-http-server|
|
||||
|
@ -51,7 +51,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
public static final String AKKA_HTTP_VERSION_DESC = "The version of akka-http";
|
||||
public static final String PEKKO_HTTP_VERSION = "pekkoHttpVersion";
|
||||
public static final String PEKKO_HTTP_VERSION_DESC = "The version of pekko-http";
|
||||
public static final String DEFAULT_AKKA_HTTP_VERSION = "10.1.10";
|
||||
public static final String DEFAULT_AKKA_HTTP_VERSION = "10.2.9";
|
||||
public static final String DEFAULT_PEKKO_HTTP_VERSION = "1.1.0";
|
||||
|
||||
public static final String GENERATE_AS_MANAGED_SOURCES = "asManagedSources";
|
||||
|
@ -1,11 +1,16 @@
|
||||
version := "{{artifactVersion}}"
|
||||
name := "{{artifactId}}"
|
||||
organization := "{{groupId}}"
|
||||
scalaVersion := "2.12.20"
|
||||
scalaVersion := "2.13.16"
|
||||
|
||||
libraryDependencies ++= Seq({{#useApachePekko}}
|
||||
"org.apache.pekko" %% "pekko-stream" % "1.0.3",
|
||||
"org.apache.pekko" %% "pekko-stream" % "1.1.3",
|
||||
"org.apache.pekko" %% "pekko-http" % "{{pekkoHttpVersion}}"{{/useApachePekko}}{{^useApachePekko}}
|
||||
"com.typesafe.akka" %% "akka-stream" % "2.5.21",
|
||||
"com.typesafe.akka" %% "akka-stream" % "2.6.21",
|
||||
"com.typesafe.akka" %% "akka-http" % "{{akkaHttpVersion}}"{{/useApachePekko}}
|
||||
)
|
||||
|
||||
scalacOptions ++= Seq(
|
||||
"-deprecation",
|
||||
"-feature",
|
||||
)
|
||||
|
@ -6,11 +6,11 @@ import {{akkaImportGroupId}}.http.scaladsl.server.Route
|
||||
{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
import {{akkaImportGroupId}}.http.scaladsl.server.Directives._
|
||||
import {{akkaImportGroupId}}.actor.ActorSystem
|
||||
import {{akkaImportGroupId}}.stream.ActorMaterializer
|
||||
import {{akkaImportGroupId}}.stream.Materializer
|
||||
|
||||
class Controller({{#apiInfo}}{{#apis}}{{#operations}}{{classVarName}}: {{classname}}{{^-last}}, {{/-last}}{{/operations}}{{/apis}}{{/apiInfo}})(implicit system: ActorSystem, materializer: ActorMaterializer) {
|
||||
class Controller({{#apiInfo}}{{#apis}}{{#operations}}{{classVarName}}: {{classname}}{{^-last}}, {{/-last}}{{/operations}}{{/apis}}{{/apiInfo}})(implicit system: ActorSystem, materializer: Materializer) {
|
||||
|
||||
lazy val routes: Route = {{#apiInfo}}{{#apis}}{{#operations}}{{classVarName}}.route {{^-last}}~ {{/-last}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
Http().bindAndHandle(routes, "0.0.0.0", 9000)
|
||||
}
|
||||
Http().newServerAt("0.0.0.0", 9000).bind(routes)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import {{akkaImportGroupId}}.http.scaladsl.server.directives.BasicDirectives
|
||||
import {{akkaImportGroupId}}.http.scaladsl.unmarshalling.Unmarshaller.UnsupportedContentTypeException
|
||||
|
||||
import scala.concurrent.Future
|
||||
import scala.language.implicitConversions
|
||||
import scala.util.{Failure, Success}
|
||||
|
||||
trait StringDirectives {
|
||||
|
@ -1,9 +1,14 @@
|
||||
version := "1.0.0"
|
||||
name := "openapi-scala-akka-http-server"
|
||||
organization := "org.openapitools"
|
||||
scalaVersion := "2.12.20"
|
||||
scalaVersion := "2.13.16"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"com.typesafe.akka" %% "akka-stream" % "2.5.21",
|
||||
"com.typesafe.akka" %% "akka-http" % "10.1.10"
|
||||
"com.typesafe.akka" %% "akka-stream" % "2.6.21",
|
||||
"com.typesafe.akka" %% "akka-http" % "10.2.9"
|
||||
)
|
||||
|
||||
scalacOptions ++= Seq(
|
||||
"-deprecation",
|
||||
"-feature",
|
||||
)
|
||||
|
@ -8,11 +8,11 @@ import org.openapitools.server.api.UserApi
|
||||
|
||||
import akka.http.scaladsl.server.Directives._
|
||||
import akka.actor.ActorSystem
|
||||
import akka.stream.ActorMaterializer
|
||||
import akka.stream.Materializer
|
||||
|
||||
class Controller(pet: PetApi, store: StoreApi, user: UserApi)(implicit system: ActorSystem, materializer: ActorMaterializer) {
|
||||
class Controller(pet: PetApi, store: StoreApi, user: UserApi)(implicit system: ActorSystem, materializer: Materializer) {
|
||||
|
||||
lazy val routes: Route = pet.route ~ store.route ~ user.route
|
||||
|
||||
Http().bindAndHandle(routes, "0.0.0.0", 9000)
|
||||
}
|
||||
Http().newServerAt("0.0.0.0", 9000).bind(routes)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import akka.http.scaladsl.server.directives.BasicDirectives
|
||||
import akka.http.scaladsl.unmarshalling.Unmarshaller.UnsupportedContentTypeException
|
||||
|
||||
import scala.concurrent.Future
|
||||
import scala.language.implicitConversions
|
||||
import scala.util.{Failure, Success}
|
||||
|
||||
trait StringDirectives {
|
||||
|
@ -1,9 +1,14 @@
|
||||
version := "1.0.0"
|
||||
name := "openapi-scala-pekko-http-server"
|
||||
organization := "org.openapitools"
|
||||
scalaVersion := "2.12.20"
|
||||
scalaVersion := "2.13.16"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"org.apache.pekko" %% "pekko-stream" % "1.0.3",
|
||||
"org.apache.pekko" %% "pekko-stream" % "1.1.3",
|
||||
"org.apache.pekko" %% "pekko-http" % "1.1.0"
|
||||
)
|
||||
|
||||
scalacOptions ++= Seq(
|
||||
"-deprecation",
|
||||
"-feature",
|
||||
)
|
||||
|
@ -8,11 +8,11 @@ import org.openapitools.server.api.UserApi
|
||||
|
||||
import org.apache.pekko.http.scaladsl.server.Directives._
|
||||
import org.apache.pekko.actor.ActorSystem
|
||||
import org.apache.pekko.stream.ActorMaterializer
|
||||
import org.apache.pekko.stream.Materializer
|
||||
|
||||
class Controller(pet: PetApi, store: StoreApi, user: UserApi)(implicit system: ActorSystem, materializer: ActorMaterializer) {
|
||||
class Controller(pet: PetApi, store: StoreApi, user: UserApi)(implicit system: ActorSystem, materializer: Materializer) {
|
||||
|
||||
lazy val routes: Route = pet.route ~ store.route ~ user.route
|
||||
|
||||
Http().bindAndHandle(routes, "0.0.0.0", 9000)
|
||||
}
|
||||
Http().newServerAt("0.0.0.0", 9000).bind(routes)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.apache.pekko.http.scaladsl.server.directives.BasicDirectives
|
||||
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshaller.UnsupportedContentTypeException
|
||||
|
||||
import scala.concurrent.Future
|
||||
import scala.language.implicitConversions
|
||||
import scala.util.{Failure, Success}
|
||||
|
||||
trait StringDirectives {
|
||||
|
Loading…
x
Reference in New Issue
Block a user