Skip to content

Commit 4d6de32

Browse files
committed
Refactor
1 parent 2fda670 commit 4d6de32

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ public void processOpts() {
165165
modelPackage = PACKAGE_PROPERTY.getModelPackage(additionalProperties);
166166

167167
String jsonLibrary = JSON_LIBRARY_PROPERTY.getValue(additionalProperties);
168-
String jsonValueClass = "circe".equals(jsonLibrary) ? "io.circe.Json" : "org.json4s.JValue";
169-
importMapping.put(jsonValueClass, jsonValueClass);
168+
String jsonValueFqn = "circe".equals(jsonLibrary) ? "io.circe.Json" : "org.json4s.JValue";
169+
String jsonValueSimpleName = jsonValueFqn.substring(jsonValueFqn.lastIndexOf('.') + 1);
170170

171-
typeMapping.put("object", jsonValueClass);
172-
typeMapping.put("AnyType", jsonValueClass);
171+
typeMapping.put("object", jsonValueSimpleName);
172+
typeMapping.put("AnyType", jsonValueSimpleName);
173+
importMapping.put(jsonValueSimpleName, jsonValueFqn);
173174

174175
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
175176
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));

samples/client/petstore/scala-sttp-circe/src/main/scala/org/openapitools/client/api/StoreApi.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*/
1212
package org.openapitools.client.api
1313

14-
import org.openapitools.client.model.Order
1514
import io.circe.Json
15+
import org.openapitools.client.model.Order
1616
import org.openapitools.client.core.JsonSupport._
1717
import sttp.client3._
1818
import sttp.model.Method
@@ -77,18 +77,18 @@ class StoreApi(baseUrl: String) {
7777
* Returns arbitrary store metrics whose schema is not fixed
7878
*
7979
* Expected answers:
80-
* code 200 : io.circe.Json (successful operation)
80+
* code 200 : Json (successful operation)
8181
*
8282
* Available security schemes:
8383
* api_key (apiKey)
8484
*/
8585
def getStoreStats(apiKeyHeader: String)(
86-
): Request[Either[ResponseException[String, Exception], io.circe.Json], Any] =
86+
): Request[Either[ResponseException[String, Exception], Json], Any] =
8787
basicRequest
8888
.method(Method.GET, uri"$baseUrl/store/stats")
8989
.contentType("application/json")
9090
.header("api_key", apiKeyHeader)
91-
.response(asJson[io.circe.Json])
91+
.response(asJson[Json])
9292

9393
/**
9494
*

0 commit comments

Comments
 (0)