forked from loafle/openapi-generator-original
[BUG] [scala-sttp] [circe] Generate circe encoder and decoder for inline enumeration (#21028)
* Generate circe encoder and decoder for inline enumeration * Add missing circe-generic dependency, and the corresponding circeVersion property. --------- Co-authored-by: Basil Mironenko <basilm@mosaicpower.com>
This commit is contained in:
parent
6bf528950f
commit
4048942485
@ -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|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for JDK 1.8+)</dd></dl>|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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|
@ -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<Property<?>> 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);
|
||||
|
||||
|
@ -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}}
|
||||
)
|
||||
|
||||
|
@ -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}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user