diff --git a/docs/generators/scala-sttp.md b/docs/generators/scala-sttp.md index b425573a556..798740d2566 100644 --- a/docs/generators/scala-sttp.md +++ b/docs/generators/scala-sttp.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |null| +|circeVersion|The version of circe library| |0.14.1| |dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app)
**java8**
Java 8 native JSR310 (preferred for JDK 1.8+)
|java8| |disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java index c1fd3f42294..f4aa0e66327 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java @@ -49,7 +49,8 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code "joda-time library", "2.10.13"); private static final StringProperty JSON4S_VERSION = new StringProperty("json4sVersion", "The version of json4s " + "library", "3.6.11"); - + private static final StringProperty CIRCE_VERSION = new StringProperty("circeVersion", "The version of circe " + + "library", "0.14.1"); private static final JsonLibraryProperty JSON_LIBRARY_PROPERTY = new JsonLibraryProperty(); public static final String DEFAULT_PACKAGE_NAME = "org.openapitools.client"; @@ -57,7 +58,7 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code private static final List> properties = Arrays.asList( STTP_CLIENT_VERSION, USE_SEPARATE_ERROR_CHANNEL, JODA_TIME_VERSION, - JSON4S_VERSION, JSON_LIBRARY_PROPERTY, PACKAGE_PROPERTY); + JSON4S_VERSION, CIRCE_VERSION, JSON_LIBRARY_PROPERTY, PACKAGE_PROPERTY); private final Logger LOGGER = LoggerFactory.getLogger(ScalaSttpClientCodegen.class); diff --git a/modules/openapi-generator/src/main/resources/scala-sttp/build.sbt.mustache b/modules/openapi-generator/src/main/resources/scala-sttp/build.sbt.mustache index b7a40f8682a..0e7a134b384 100644 --- a/modules/openapi-generator/src/main/resources/scala-sttp/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/scala-sttp/build.sbt.mustache @@ -15,7 +15,8 @@ libraryDependencies ++= Seq( "org.json4s" %% "json4s-jackson" % "{{json4sVersion}}" {{/json4s}} {{#circe}} - "com.softwaremill.sttp.client3" %% "circe" % "{{sttpClientVersion}}" + "com.softwaremill.sttp.client3" %% "circe" % "{{sttpClientVersion}}", + "io.circe" %% "circe-generic" % "{{circeVersion}}" {{/circe}} ) diff --git a/modules/openapi-generator/src/main/resources/scala-sttp/jsonSupport.mustache b/modules/openapi-generator/src/main/resources/scala-sttp/jsonSupport.mustache index 6a0b9665a09..2dcb6109a86 100644 --- a/modules/openapi-generator/src/main/resources/scala-sttp/jsonSupport.mustache +++ b/modules/openapi-generator/src/main/resources/scala-sttp/jsonSupport.mustache @@ -53,6 +53,14 @@ object JsonSupport extends SttpCirceApi with AutoDerivation with DateSerializers implicit val {{classname}}Decoder: Decoder[{{classname}}.{{classname}}] = Decoder.decodeEnumeration({{classname}}) implicit val {{classname}}Encoder: Encoder[{{classname}}.{{classname}}] = Encoder.encodeEnumeration({{classname}}) {{/isEnum}} +{{#hasEnums}} +{{#vars}} +{{#isEnum}} + implicit val {{classname}}{{datatypeWithEnum}}Decoder: Decoder[{{classname}}Enums.{{datatypeWithEnum}}] = Decoder.decodeEnumeration({{classname}}Enums.{{datatypeWithEnum}}) + implicit val {{classname}}{{datatypeWithEnum}}Encoder: Encoder[{{classname}}Enums.{{datatypeWithEnum}}] = Encoder.encodeEnumeration({{classname}}Enums.{{datatypeWithEnum}}) +{{/isEnum}} +{{/vars}} +{{/hasEnums}} {{/model}} {{/models}} }