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 527ee58cc5fb..bfa824392e8d 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 @@ -125,11 +125,6 @@ public ScalaSttpClientCodegen() { additionalProperties.put("fnCamelize", new CamelizeLambda(false)); additionalProperties.put("fnEnumEntry", new EnumEntryLambda()); -// importMapping.remove("Seq"); -// importMapping.remove("List"); -// importMapping.remove("Set"); -// importMapping.remove("Map"); - // TODO: there is no specific sttp mapping. All Scala Type mappings should be in AbstractScala typeMapping = new HashMap<>(); typeMapping.put("array", "Seq"); @@ -170,9 +165,12 @@ public void processOpts() { modelPackage = PACKAGE_PROPERTY.getModelPackage(additionalProperties); String jsonLibrary = JSON_LIBRARY_PROPERTY.getValue(additionalProperties); - String jsonValueClass = "circe".equals(jsonLibrary) ? "io.circe.Json" : "org.json4s.JValue"; - typeMapping.put("object", jsonValueClass); - typeMapping.put("AnyType", jsonValueClass); + String jsonValueFqn = "circe".equals(jsonLibrary) ? "io.circe.Json" : "org.json4s.JValue"; + String jsonValueSimpleName = jsonValueFqn.substring(jsonValueFqn.lastIndexOf('.') + 1); + + typeMapping.put("object", jsonValueSimpleName); + typeMapping.put("AnyType", jsonValueSimpleName); + importMapping.put(jsonValueSimpleName, jsonValueFqn); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); diff --git a/modules/openapi-generator/src/test/resources/3_0/scala-sttp-circe/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/scala-sttp-circe/petstore.yaml index 65c92603c2bf..ea571731a106 100644 --- a/modules/openapi-generator/src/test/resources/3_0/scala-sttp-circe/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/scala-sttp-circe/petstore.yaml @@ -283,6 +283,22 @@ paths: description: file to upload type: string format: binary + /store/stats: + get: + tags: + - store + summary: Returns store statistics as a free-form JSON object + description: Returns arbitrary store metrics whose schema is not fixed + operationId: getStoreStats + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + security: + - api_key: [] /store/inventory: get: tags: diff --git a/samples/client/petstore/scala-sttp-circe/README.md b/samples/client/petstore/scala-sttp-circe/README.md index 3455cf578d1c..0a7a9b2de1ff 100644 --- a/samples/client/petstore/scala-sttp-circe/README.md +++ b/samples/client/petstore/scala-sttp-circe/README.md @@ -78,6 +78,7 @@ Class | Method | HTTP request | Description *StoreApi* | **deleteOrder** | **DELETE** /store/order/${orderId} | Delete purchase order by ID *StoreApi* | **getInventory** | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | **getOrderById** | **GET** /store/order/${orderId} | Find purchase order by ID +*StoreApi* | **getStoreStats** | **GET** /store/stats | Returns store statistics as a free-form JSON object *StoreApi* | **placeOrder** | **POST** /store/order | Place an order for a pet *UserApi* | **createUser** | **POST** /user | Create user *UserApi* | **createUsersWithArrayInput** | **POST** /user/createWithArray | Creates list of users with given input array diff --git a/samples/client/petstore/scala-sttp-circe/src/main/scala/org/openapitools/client/api/StoreApi.scala b/samples/client/petstore/scala-sttp-circe/src/main/scala/org/openapitools/client/api/StoreApi.scala index efddc39a690b..b95fda527181 100644 --- a/samples/client/petstore/scala-sttp-circe/src/main/scala/org/openapitools/client/api/StoreApi.scala +++ b/samples/client/petstore/scala-sttp-circe/src/main/scala/org/openapitools/client/api/StoreApi.scala @@ -11,6 +11,7 @@ */ package org.openapitools.client.api +import io.circe.Json import org.openapitools.client.model.Order import org.openapitools.client.core.JsonSupport._ import sttp.client3._ @@ -72,6 +73,23 @@ class StoreApi(baseUrl: String) { .contentType("application/json") .response(asJson[Order]) + /** + * Returns arbitrary store metrics whose schema is not fixed + * + * Expected answers: + * code 200 : Json (successful operation) + * + * Available security schemes: + * api_key (apiKey) + */ + def getStoreStats(apiKeyHeader: String)( +): Request[Either[ResponseException[String, Exception], Json], Any] = + basicRequest + .method(Method.GET, uri"$baseUrl/store/stats") + .contentType("application/json") + .header("api_key", apiKeyHeader) + .response(asJson[Json]) + /** * *