Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/scala-sttp-circe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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])

/**
*
*
Expand Down
Loading