diff --git a/docs/generators/scala-akka-http-server.md b/docs/generators/scala-akka-http-server.md index 15108cd3eb67..5fea99079296 100644 --- a/docs/generators/scala-akka-http-server.md +++ b/docs/generators/scala-akka-http-server.md @@ -33,6 +33,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| |modelPackage|package for generated models| |null| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| +|pekkoHttpVersion|The version of pekko-http| |1.1.0| |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaHttpServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaHttpServerCodegen.java index 2962bfc56191..d1d1daed8833 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaHttpServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaHttpServerCodegen.java @@ -45,11 +45,14 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements protected String akkaHttpVersion; protected boolean generateAsManagedSources; protected boolean useApachePekko; + protected String pekkoHttpVersion; public static final String AKKA_HTTP_VERSION = "akkaHttpVersion"; 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_PEKKO_HTTP_VERSION = "1.0.0"; + public static final String DEFAULT_PEKKO_HTTP_VERSION = "1.1.0"; public static final String GENERATE_AS_MANAGED_SOURCES = "asManagedSources"; public static final String GENERATE_AS_MANAGED_SOURCES_DESC = "Resulting files cab be used as managed resources. No build files or default controllers will be generated"; @@ -124,6 +127,7 @@ public ScalaAkkaHttpServerCodegen() { akkaHttpVersion = DEFAULT_AKKA_HTTP_VERSION; generateAsManagedSources = DEFAULT_GENERATE_AS_MANAGED_SOURCES; useApachePekko = DEFAULT_USE_APACHE_PEKKO; + pekkoHttpVersion = DEFAULT_PEKKO_HTTP_VERSION; setReservedWordsLowerCase( Arrays.asList( @@ -141,6 +145,7 @@ public ScalaAkkaHttpServerCodegen() { cliOptions.add(CliOption.newString(AKKA_HTTP_VERSION, AKKA_HTTP_VERSION_DESC).defaultValue(akkaHttpVersion)); cliOptions.add(CliOption.newBoolean(GENERATE_AS_MANAGED_SOURCES, GENERATE_AS_MANAGED_SOURCES_DESC).defaultValue(Boolean.valueOf(DEFAULT_GENERATE_AS_MANAGED_SOURCES).toString())); cliOptions.add(CliOption.newBoolean(USE_APACHE_PEKKO, USE_APACHE_PEKKO_DESC).defaultValue(Boolean.valueOf(DEFAULT_USE_APACHE_PEKKO).toString())); + cliOptions.add(CliOption.newString(PEKKO_HTTP_VERSION, PEKKO_HTTP_VERSION_DESC).defaultValue(pekkoHttpVersion)); importMapping.remove("Seq"); importMapping.remove("List"); @@ -204,11 +209,16 @@ public void processOpts() { additionalProperties.put(USE_APACHE_PEKKO, useApachePekko); } + if (additionalProperties.containsKey(PEKKO_HTTP_VERSION)) { + pekkoHttpVersion = (String) additionalProperties.get(PEKKO_HTTP_VERSION); + } else { + additionalProperties.put(PEKKO_HTTP_VERSION, DEFAULT_PEKKO_HTTP_VERSION); + } + if (additionalProperties.containsKey(AKKA_HTTP_VERSION)) { akkaHttpVersion = (String) additionalProperties.get(AKKA_HTTP_VERSION); } else { - String version = useApachePekko ? DEFAULT_PEKKO_HTTP_VERSION : DEFAULT_AKKA_HTTP_VERSION; - additionalProperties.put(AKKA_HTTP_VERSION, version); + additionalProperties.put(AKKA_HTTP_VERSION, akkaHttpVersion); } if (useApachePekko) { diff --git a/modules/openapi-generator/src/main/resources/scala-akka-http-server/build.sbt.mustache b/modules/openapi-generator/src/main/resources/scala-akka-http-server/build.sbt.mustache index f2f036b613f7..b6f1149a4023 100644 --- a/modules/openapi-generator/src/main/resources/scala-akka-http-server/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/scala-akka-http-server/build.sbt.mustache @@ -4,8 +4,8 @@ organization := "{{groupId}}" scalaVersion := "2.12.8" libraryDependencies ++= Seq({{#useApachePekko}} - "org.apache.pekko" %% "pekko-stream" % "{{akkaHttpVersion}}", - "org.apache.pekko" %% "pekko-http" % "{{akkaHttpVersion}}"{{/useApachePekko}}{{^useApachePekko}} + "org.apache.pekko" %% "pekko-stream" % "1.0.3", + "org.apache.pekko" %% "pekko-http" % "{{pekkoHttpVersion}}"{{/useApachePekko}}{{^useApachePekko}} "com.typesafe.akka" %% "akka-stream" % "2.5.21", "com.typesafe.akka" %% "akka-http" % "{{akkaHttpVersion}}"{{/useApachePekko}} ) diff --git a/samples/server/petstore/scala-pekko-http-server/build.sbt b/samples/server/petstore/scala-pekko-http-server/build.sbt index 8e54aeb598ff..61690fec7f17 100644 --- a/samples/server/petstore/scala-pekko-http-server/build.sbt +++ b/samples/server/petstore/scala-pekko-http-server/build.sbt @@ -4,6 +4,6 @@ organization := "org.openapitools" scalaVersion := "2.12.8" libraryDependencies ++= Seq( - "org.apache.pekko" %% "pekko-stream" % "1.0.0", - "org.apache.pekko" %% "pekko-http" % "1.0.0" + "org.apache.pekko" %% "pekko-stream" % "1.0.3", + "org.apache.pekko" %% "pekko-http" % "1.1.0" )