Skip to content

Commit 2fda670

Browse files
committed
[Fix][scala-sttp] Skip model-package prefix when type name is already fully qualified
1 parent 878d821 commit 2fda670

4 files changed

Lines changed: 37 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ public ScalaSttpClientCodegen() {
125125
additionalProperties.put("fnCamelize", new CamelizeLambda(false));
126126
additionalProperties.put("fnEnumEntry", new EnumEntryLambda());
127127

128-
// importMapping.remove("Seq");
129-
// importMapping.remove("List");
130-
// importMapping.remove("Set");
131-
// importMapping.remove("Map");
132-
133128
// TODO: there is no specific sttp mapping. All Scala Type mappings should be in AbstractScala
134129
typeMapping = new HashMap<>();
135130
typeMapping.put("array", "Seq");
@@ -171,6 +166,8 @@ public void processOpts() {
171166

172167
String jsonLibrary = JSON_LIBRARY_PROPERTY.getValue(additionalProperties);
173168
String jsonValueClass = "circe".equals(jsonLibrary) ? "io.circe.Json" : "org.json4s.JValue";
169+
importMapping.put(jsonValueClass, jsonValueClass);
170+
174171
typeMapping.put("object", jsonValueClass);
175172
typeMapping.put("AnyType", jsonValueClass);
176173

modules/openapi-generator/src/test/resources/3_0/scala-sttp-circe/petstore.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,22 @@ paths:
283283
description: file to upload
284284
type: string
285285
format: binary
286+
/store/stats:
287+
get:
288+
tags:
289+
- store
290+
summary: Returns store statistics as a free-form JSON object
291+
description: Returns arbitrary store metrics whose schema is not fixed
292+
operationId: getStoreStats
293+
responses:
294+
'200':
295+
description: successful operation
296+
content:
297+
application/json:
298+
schema:
299+
type: object
300+
security:
301+
- api_key: []
286302
/store/inventory:
287303
get:
288304
tags:

samples/client/petstore/scala-sttp-circe/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Class | Method | HTTP request | Description
7878
*StoreApi* | **deleteOrder** | **DELETE** /store/order/${orderId} | Delete purchase order by ID
7979
*StoreApi* | **getInventory** | **GET** /store/inventory | Returns pet inventories by status
8080
*StoreApi* | **getOrderById** | **GET** /store/order/${orderId} | Find purchase order by ID
81+
*StoreApi* | **getStoreStats** | **GET** /store/stats | Returns store statistics as a free-form JSON object
8182
*StoreApi* | **placeOrder** | **POST** /store/order | Place an order for a pet
8283
*UserApi* | **createUser** | **POST** /user | Create user
8384
*UserApi* | **createUsersWithArrayInput** | **POST** /user/createWithArray | Creates list of users with given input array

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package org.openapitools.client.api
1313

1414
import org.openapitools.client.model.Order
15+
import io.circe.Json
1516
import org.openapitools.client.core.JsonSupport._
1617
import sttp.client3._
1718
import sttp.model.Method
@@ -72,6 +73,23 @@ class StoreApi(baseUrl: String) {
7273
.contentType("application/json")
7374
.response(asJson[Order])
7475

76+
/**
77+
* Returns arbitrary store metrics whose schema is not fixed
78+
*
79+
* Expected answers:
80+
* code 200 : io.circe.Json (successful operation)
81+
*
82+
* Available security schemes:
83+
* api_key (apiKey)
84+
*/
85+
def getStoreStats(apiKeyHeader: String)(
86+
): Request[Either[ResponseException[String, Exception], io.circe.Json], Any] =
87+
basicRequest
88+
.method(Method.GET, uri"$baseUrl/store/stats")
89+
.contentType("application/json")
90+
.header("api_key", apiKeyHeader)
91+
.response(asJson[io.circe.Json])
92+
7593
/**
7694
*
7795
*

0 commit comments

Comments
 (0)