Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generators/scala-akka-http-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid warnings

[warn] tmp/samples/server/petstore/scala-pekko-http-server/src/main/scala/org/openapitools/server/StringDirectives.scala:12:16: implicit conversion method _symbol2NR should be enabled
[warn] by making the implicit value scala.language.implicitConversions visible.
[warn] This can be achieved by adding the import clause 'import scala.language.implicitConversions'
[warn] or by setting the compiler option -language:implicitConversions.
[warn] See the Scaladoc for value scala.language.implicitConversions for a discussion
[warn] why the feature should be explicitly enabled.
[warn]   implicit def _symbol2NR(symbol: Symbol): NameReceptacle[String] = new NameReceptacle[String](symbol.name)
[warn]                ^
[warn] tmp/samples/server/petstore/scala-pekko-http-server/src/main/scala/org/openapitools/server/StringDirectives.scala:13:16: implicit conversion method _string2NR should be enabled
[warn] by making the implicit value scala.language.implicitConversions visible.
[warn]   implicit def _string2NR(string: String): NameReceptacle[String] = new NameReceptacle[String](string)
[warn]                ^
[warn] tmp/samples/server/petstore/scala-pekko-http-server/src/main/scala/org/openapitools/server/StringDirectives.scala:31:18: implicit conversion method apply should be enabled
[warn] by making the implicit value scala.language.implicitConversions visible.
[warn]     implicit def apply[T](value: T)(implicit sdef: StringDef[T]): StringMagnet { type Out = sdef.Out } =
[warn]                  ^
[warn] three warnings found

import scala.util.{Failure, Success}

trait StringDirectives {
Expand Down
11 changes: 8 additions & 3 deletions samples/server/petstore/scala-akka-http-server/build.sbt
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 7 additions & 2 deletions samples/server/petstore/scala-pekko-http-server/build.sbt
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading