Skip to content

Commit 41448b2

Browse files
committed
add tests for scala sttp circe
1 parent 4048942 commit 41448b2

23 files changed

Lines changed: 991 additions & 0 deletions

.github/workflows/samples-scala.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
- samples/client/petstore/scalaz
2525
- samples/client/petstore/scala-pekko
2626
- samples/client/petstore/scala-http4s
27+
- samples/client/petstore/scala-sttp
28+
- samples/client/petstore/scala-sttp-circe
2729
#- samples/client/petstore/scala-sttp # won't pass while the same tests in circleci pass
2830
# servers
2931
- samples/server/petstore/scala-lagom-server

bin/configs/scala-sttp-circe.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
generatorName: scala-sttp
2+
outputDir: samples/client/petstore/scala-sttp-circe
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/scala/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/scala-sttp
5+
nameMappings:
6+
_type: "`underscoreType`"
7+
type_: "`typeWithUnderscore`"
8+
http_debug_operation: "`httpDebugOperation`"
9+
parameterNameMappings:
10+
_type: underscoreType
11+
type_: typeWithUnderscore
12+
http_debug_operation: httpDebugOperation
13+
additionalProperties:
14+
artifactId: scala-sttp-petstore
15+
jsonLibrary: circe
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
README.md
2+
build.sbt
3+
project/build.properties
4+
src/main/scala/org/openapitools/client/api/FakeApi.scala
5+
src/main/scala/org/openapitools/client/api/PetApi.scala
6+
src/main/scala/org/openapitools/client/api/StoreApi.scala
7+
src/main/scala/org/openapitools/client/api/UserApi.scala
8+
src/main/scala/org/openapitools/client/core/AdditionalTypeSerializers.scala
9+
src/main/scala/org/openapitools/client/core/DateSerializers.scala
10+
src/main/scala/org/openapitools/client/core/JsonSupport.scala
11+
src/main/scala/org/openapitools/client/model/ApiResponse.scala
12+
src/main/scala/org/openapitools/client/model/Category.scala
13+
src/main/scala/org/openapitools/client/model/EnumTest.scala
14+
src/main/scala/org/openapitools/client/model/Order.scala
15+
src/main/scala/org/openapitools/client/model/Pet.scala
16+
src/main/scala/org/openapitools/client/model/PropertyNameMapping.scala
17+
src/main/scala/org/openapitools/client/model/Tag.scala
18+
src/main/scala/org/openapitools/client/model/User.scala
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.13.0-SNAPSHOT
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# scala-sttp-petstore
2+
3+
OpenAPI Petstore
4+
- API version: 1.0.0
5+
- Generator version: 7.13.0-SNAPSHOT
6+
7+
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
8+
9+
10+
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
11+
12+
## Requirements
13+
14+
Building the API client library requires:
15+
1. Java 1.7+
16+
2. Maven/Gradle/SBT
17+
18+
## Installation
19+
20+
To install the API client library to your local Maven repository, simply execute:
21+
22+
```shell
23+
mvn clean install
24+
```
25+
26+
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
27+
28+
```shell
29+
mvn clean deploy
30+
```
31+
32+
Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
33+
34+
### Maven users
35+
36+
Add this dependency to your project's POM:
37+
38+
```xml
39+
<dependency>
40+
<groupId>org.openapitools</groupId>
41+
<artifactId>scala-sttp-petstore</artifactId>
42+
<version>1.0.0</version>
43+
<scope>compile</scope>
44+
</dependency>
45+
```
46+
47+
### Gradle users
48+
49+
Add this dependency to your project's build file:
50+
51+
```groovy
52+
compile "org.openapitools:scala-sttp-petstore:1.0.0"
53+
```
54+
55+
### SBT users
56+
57+
```scala
58+
libraryDependencies += "org.openapitools" % "scala-sttp-petstore" % "1.0.0"
59+
```
60+
61+
## Getting Started
62+
63+
## Documentation for API Endpoints
64+
65+
All URIs are relative to *http://petstore.swagger.io/v2*
66+
67+
Class | Method | HTTP request | Description
68+
------------ | ------------- | ------------- | -------------
69+
*FakeApi* | **getParameterNameMapping** | **GET** /fake/parameter-name-mapping | parameter name mapping test
70+
*PetApi* | **addPet** | **POST** /pet | Add a new pet to the store
71+
*PetApi* | **deletePet** | **DELETE** /pet/${petId} | Deletes a pet
72+
*PetApi* | **findPetsByStatus** | **GET** /pet/findByStatus | Finds Pets by status
73+
*PetApi* | **findPetsByTags** | **GET** /pet/findByTags | Finds Pets by tags
74+
*PetApi* | **getPetById** | **GET** /pet/${petId} | Find pet by ID
75+
*PetApi* | **updatePet** | **PUT** /pet | Update an existing pet
76+
*PetApi* | **updatePetWithForm** | **POST** /pet/${petId} | Updates a pet in the store with form data
77+
*PetApi* | **uploadFile** | **POST** /pet/${petId}/uploadImage | uploads an image
78+
*StoreApi* | **deleteOrder** | **DELETE** /store/order/${orderId} | Delete purchase order by ID
79+
*StoreApi* | **getInventory** | **GET** /store/inventory | Returns pet inventories by status
80+
*StoreApi* | **getOrderById** | **GET** /store/order/${orderId} | Find purchase order by ID
81+
*StoreApi* | **placeOrder** | **POST** /store/order | Place an order for a pet
82+
*UserApi* | **createUser** | **POST** /user | Create user
83+
*UserApi* | **createUsersWithArrayInput** | **POST** /user/createWithArray | Creates list of users with given input array
84+
*UserApi* | **createUsersWithListInput** | **POST** /user/createWithList | Creates list of users with given input array
85+
*UserApi* | **deleteUser** | **DELETE** /user/${username} | Delete user
86+
*UserApi* | **getUserByName** | **GET** /user/${username} | Get user by user name
87+
*UserApi* | **loginUser** | **GET** /user/login | Logs user into the system
88+
*UserApi* | **logoutUser** | **GET** /user/logout | Logs out current logged in user session
89+
*UserApi* | **updateUser** | **PUT** /user/${username} | Updated user
90+
91+
92+
## Documentation for Models
93+
94+
- [ApiResponse](ApiResponse.md)
95+
- [Category](Category.md)
96+
- [EnumTest](EnumTest.md)
97+
- [Order](Order.md)
98+
- [Pet](Pet.md)
99+
- [PropertyNameMapping](PropertyNameMapping.md)
100+
- [Tag](Tag.md)
101+
- [User](User.md)
102+
103+
104+
<a id="documentation-for-authorization"></a>
105+
## Documentation for Authorization
106+
107+
108+
Authentication schemes defined for the API:
109+
<a id="api_key"></a>
110+
### api_key
111+
112+
- **Type**: API key
113+
- **API key parameter name**: api_key
114+
- **Location**: HTTP header
115+
116+
117+
## Author
118+
119+
120+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version := "1.0.0"
2+
name := "scala-sttp-petstore"
3+
organization := "org.openapitools"
4+
5+
scalaVersion := "2.13.16"
6+
crossScalaVersions := Seq(scalaVersion.value, "2.12.20")
7+
8+
libraryDependencies ++= Seq(
9+
"com.softwaremill.sttp.client3" %% "core" % "3.3.18",
10+
"com.softwaremill.sttp.client3" %% "circe" % "3.3.18",
11+
"io.circe" %% "circe-generic" % "0.14.1"
12+
)
13+
14+
scalacOptions := Seq(
15+
"-unchecked",
16+
"-deprecation",
17+
"-feature"
18+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.10.11
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* OpenAPI Petstore
3+
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
package org.openapitools.client.api
13+
14+
import org.openapitools.client.core.JsonSupport._
15+
import sttp.client3._
16+
import sttp.model.Method
17+
18+
object FakeApi {
19+
def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new FakeApi(baseUrl)
20+
}
21+
22+
class FakeApi(baseUrl: String) {
23+
24+
/**
25+
* Expected answers:
26+
* code 200 : (OK)
27+
*
28+
* @param underscoreType _type
29+
* @param `type` type
30+
* @param typeWithUnderscore type_
31+
* @param httpDebugOption http debug option (to test parameter naming option)
32+
*/
33+
def getParameterNameMapping(underscoreType: Long, `type`: String, typeWithUnderscore: String, httpDebugOption: String
34+
): Request[Either[ResponseException[String, Exception], Unit], Any] =
35+
basicRequest
36+
.method(Method.GET, uri"$baseUrl/fake/parameter-name-mapping?type=${ `type` }&http_debug_option=${ httpDebugOption }")
37+
.contentType("application/json")
38+
.header("_type", underscoreType.toString)
39+
.header("type_", typeWithUnderscore.toString)
40+
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
41+
42+
}

0 commit comments

Comments
 (0)