mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Improve handling of pekko versions in scala-akka-http-server generator (#20277)
* Fix issue 20275 Improve handling of pekko versions * Generated docs * Use version 1.1.0 as default version of pekko-http. * Updated sample
This commit is contained in:
parent
e7b5f348e7
commit
b218e238f4
@ -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).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|
|
||||
|
@ -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 class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
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 class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
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 class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
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) {
|
||||
|
@ -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}}
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user