[JAVA] fix toUrlQueryString for BigDecimal (#15764)

* add MyImportTest.java

* fix original issue

* fix same issue for native library

* remove MyImportTest

* add test configs

* generate samples (again?)

* generate samples again

* generate samples again, undo pom.xml mistake [amended to retrigger circliCi]
This commit is contained in:
martin-mfg
2023-06-08 03:34:06 +02:00
committed by GitHub
parent fbe768bb9c
commit b7f2b723aa
176 changed files with 7934 additions and 8 deletions

View File

@@ -36,6 +36,7 @@ docs/EnumClass.md
docs/EnumTest.md
docs/EquilateralTriangle.md
docs/FakeApi.md
docs/FakeBigDecimalMap200Response.md
docs/FakeClassnameTags123Api.md
docs/FileSchemaTestClass.md
docs/Foo.md
@@ -142,6 +143,7 @@ src/main/java/org/openapitools/client/model/EnumArrays.java
src/main/java/org/openapitools/client/model/EnumClass.java
src/main/java/org/openapitools/client/model/EnumTest.java
src/main/java/org/openapitools/client/model/EquilateralTriangle.java
src/main/java/org/openapitools/client/model/FakeBigDecimalMap200Response.java
src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
src/main/java/org/openapitools/client/model/Foo.java
src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java

View File

@@ -110,6 +110,8 @@ Class | Method | HTTP request | Description
*AnotherFakeApi* | [**call123testSpecialTagsWithHttpInfo**](docs/AnotherFakeApi.md#call123testSpecialTagsWithHttpInfo) | **PATCH** /another-fake/dummy | To test special tags
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo |
*DefaultApi* | [**fooGetWithHttpInfo**](docs/DefaultApi.md#fooGetWithHttpInfo) | **GET** /foo |
*FakeApi* | [**fakeBigDecimalMap**](docs/FakeApi.md#fakeBigDecimalMap) | **GET** /fake/BigDecimalMap |
*FakeApi* | [**fakeBigDecimalMapWithHttpInfo**](docs/FakeApi.md#fakeBigDecimalMapWithHttpInfo) | **GET** /fake/BigDecimalMap |
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**fakeHealthGetWithHttpInfo**](docs/FakeApi.md#fakeHealthGetWithHttpInfo) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
@@ -216,6 +218,7 @@ Class | Method | HTTP request | Description
- [EnumClass](docs/EnumClass.md)
- [EnumTest](docs/EnumTest.md)
- [EquilateralTriangle](docs/EquilateralTriangle.md)
- [FakeBigDecimalMap200Response](docs/FakeBigDecimalMap200Response.md)
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
- [Foo](docs/Foo.md)
- [FooGetDefaultResponse](docs/FooGetDefaultResponse.md)

View File

@@ -920,6 +920,21 @@ paths:
- fake
x-content-type: application/json
x-accepts: '*/*'
/fake/BigDecimalMap:
get:
description: "for Java apache and Java native, test toUrlQueryString for maps\
\ with BegDecimal keys"
operationId: fakeBigDecimalMap
responses:
"200":
content:
'*/*':
schema:
$ref: '#/components/schemas/fakeBigDecimalMap_200_response'
description: successful operation
tags:
- fake
x-accepts: '*/*'
/fake/jsonFormData:
get:
description: ""
@@ -2255,6 +2270,19 @@ components:
- number
- pattern_without_delimiter
type: object
fakeBigDecimalMap_200_response:
example:
someId: 0.8008281904610115
someMap:
key: 6.027456183070403
properties:
someId:
type: number
someMap:
additionalProperties:
type: number
type: object
type: object
testJsonFormData_request:
properties:
param:

View File

@@ -4,6 +4,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**fakeBigDecimalMap**](FakeApi.md#fakeBigDecimalMap) | **GET** /fake/BigDecimalMap | |
| [**fakeBigDecimalMapWithHttpInfo**](FakeApi.md#fakeBigDecimalMapWithHttpInfo) | **GET** /fake/BigDecimalMap | |
| [**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint |
| [**fakeHealthGetWithHttpInfo**](FakeApi.md#fakeHealthGetWithHttpInfo) | **GET** /fake/health | Health check endpoint |
| [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | |
@@ -37,6 +39,141 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
## fakeBigDecimalMap
> CompletableFuture<FakeBigDecimalMap200Response> fakeBigDecimalMap()
for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.FakeApi;
import java.util.concurrent.CompletableFuture;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
FakeApi apiInstance = new FakeApi(defaultClient);
try {
CompletableFuture<FakeBigDecimalMap200Response> result = apiInstance.fakeBigDecimalMap();
System.out.println(result.get());
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#fakeBigDecimalMap");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
CompletableFuture<[**FakeBigDecimalMap200Response**](FakeBigDecimalMap200Response.md)>
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: */*
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | successful operation | - |
## fakeBigDecimalMapWithHttpInfo
> CompletableFuture<ApiResponse<FakeBigDecimalMap200Response>> fakeBigDecimalMap fakeBigDecimalMapWithHttpInfo()
for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.ApiResponse;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.FakeApi;
import java.util.concurrent.CompletableFuture;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
FakeApi apiInstance = new FakeApi(defaultClient);
try {
CompletableFuture<ApiResponse<FakeBigDecimalMap200Response>> response = apiInstance.fakeBigDecimalMapWithHttpInfo();
System.out.println("Status code: " + response.get().getStatusCode());
System.out.println("Response headers: " + response.get().getHeaders());
System.out.println("Response body: " + response.get().getData());
} catch (InterruptedException | ExecutionException e) {
ApiException apiException = (ApiException)e.getCause();
System.err.println("Exception when calling FakeApi#fakeBigDecimalMap");
System.err.println("Status code: " + apiException.getCode());
System.err.println("Response headers: " + apiException.getResponseHeaders());
System.err.println("Reason: " + apiException.getResponseBody());
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#fakeBigDecimalMap");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
System.err.println("Reason: " + e.getResponseBody());
e.printStackTrace();
}
}
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
CompletableFuture<ApiResponse<[**FakeBigDecimalMap200Response**](FakeBigDecimalMap200Response.md)>>
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: */*
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | successful operation | - |
## fakeHealthGet
> CompletableFuture<HealthCheckResult> fakeHealthGet()

View File

@@ -0,0 +1,14 @@
# FakeBigDecimalMap200Response
## Properties
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**someId** | **BigDecimal** | | [optional] |
|**someMap** | **Map&lt;String, BigDecimal&gt;** | | [optional] |

View File

@@ -19,6 +19,7 @@ import org.openapitools.client.Pair;
import java.math.BigDecimal;
import org.openapitools.client.model.Client;
import org.openapitools.client.model.FakeBigDecimalMap200Response;
import java.io.File;
import org.openapitools.client.model.FileSchemaTestClass;
import org.openapitools.client.model.HealthCheckResult;
@@ -97,6 +98,92 @@ public class FakeApi {
return operationId + " call failed with: " + statusCode + " - " + body;
}
/**
*
* for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys
* @return CompletableFuture&lt;FakeBigDecimalMap200Response&gt;
* @throws ApiException if fails to make API call
*/
public CompletableFuture<FakeBigDecimalMap200Response> fakeBigDecimalMap() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder();
return memberVarHttpClient.sendAsync(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
if (localVarResponse.statusCode()/ 100 != 2) {
return CompletableFuture.failedFuture(getApiException("fakeBigDecimalMap", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank() ? null : memberVarObjectMapper.readValue(responseBody, new TypeReference<FakeBigDecimalMap200Response>() {})
);
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
}
catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
*
* for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys
* @return CompletableFuture&lt;ApiResponse&lt;FakeBigDecimalMap200Response&gt;&gt;
* @throws ApiException if fails to make API call
*/
public CompletableFuture<ApiResponse<FakeBigDecimalMap200Response>> fakeBigDecimalMapWithHttpInfo() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder();
return memberVarHttpClient.sendAsync(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode()/ 100 != 2) {
return CompletableFuture.failedFuture(getApiException("fakeBigDecimalMap", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse<FakeBigDecimalMap200Response>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank() ? null : memberVarObjectMapper.readValue(responseBody, new TypeReference<FakeBigDecimalMap200Response>() {}))
);
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
}
);
}
catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder fakeBigDecimalMapRequestBuilder() throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/fake/BigDecimalMap";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "*/*");
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Health check endpoint
*

View File

@@ -0,0 +1,201 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.Objects;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* FakeBigDecimalMap200Response
*/
@JsonPropertyOrder({
FakeBigDecimalMap200Response.JSON_PROPERTY_SOME_ID,
FakeBigDecimalMap200Response.JSON_PROPERTY_SOME_MAP
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class FakeBigDecimalMap200Response {
public static final String JSON_PROPERTY_SOME_ID = "someId";
private BigDecimal someId;
public static final String JSON_PROPERTY_SOME_MAP = "someMap";
private Map<String, BigDecimal> someMap = new HashMap<>();
public FakeBigDecimalMap200Response() {
}
public FakeBigDecimalMap200Response someId(BigDecimal someId) {
this.someId = someId;
return this;
}
/**
* Get someId
* @return someId
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SOME_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getSomeId() {
return someId;
}
@JsonProperty(JSON_PROPERTY_SOME_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSomeId(BigDecimal someId) {
this.someId = someId;
}
public FakeBigDecimalMap200Response someMap(Map<String, BigDecimal> someMap) {
this.someMap = someMap;
return this;
}
public FakeBigDecimalMap200Response putSomeMapItem(String key, BigDecimal someMapItem) {
if (this.someMap == null) {
this.someMap = new HashMap<>();
}
this.someMap.put(key, someMapItem);
return this;
}
/**
* Get someMap
* @return someMap
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SOME_MAP)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Map<String, BigDecimal> getSomeMap() {
return someMap;
}
@JsonProperty(JSON_PROPERTY_SOME_MAP)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSomeMap(Map<String, BigDecimal> someMap) {
this.someMap = someMap;
}
/**
* Return true if this fakeBigDecimalMap_200_response object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FakeBigDecimalMap200Response fakeBigDecimalMap200Response = (FakeBigDecimalMap200Response) o;
return Objects.equals(this.someId, fakeBigDecimalMap200Response.someId) &&
Objects.equals(this.someMap, fakeBigDecimalMap200Response.someMap);
}
@Override
public int hashCode() {
return Objects.hash(someId, someMap);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class FakeBigDecimalMap200Response {\n");
sb.append(" someId: ").append(toIndentedString(someId)).append("\n");
sb.append(" someMap: ").append(toIndentedString(someMap)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
/**
* Convert the instance into URL query string.
*
* @return URL query string
*/
public String toUrlQueryString() {
return toUrlQueryString(null);
}
/**
* Convert the instance into URL query string.
*
* @param prefix prefix of the query string
* @return URL query string
*/
public String toUrlQueryString(String prefix) {
String suffix = "";
String containerSuffix = "";
String containerPrefix = "";
if (prefix == null) {
// style=form, explode=true, e.g. /pet?name=cat&type=manx
prefix = "";
} else {
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
prefix = prefix + "[";
suffix = "]";
containerSuffix = "]";
containerPrefix = "[";
}
StringJoiner joiner = new StringJoiner("&");
// add `someId` to the URL query string
if (getSomeId() != null) {
joiner.add(String.format("%ssomeId%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSomeId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
// add `someMap` to the URL query string
if (getSomeMap() != null) {
for (String _key : getSomeMap().keySet()) {
joiner.add(String.format("%ssomeMap%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix),
getSomeMap().get(_key), URLEncoder.encode(String.valueOf(getSomeMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
return joiner.toString();
}
}

View File

@@ -0,0 +1,58 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for FakeBigDecimalMap200Response
*/
public class FakeBigDecimalMap200ResponseTest {
private final FakeBigDecimalMap200Response model = new FakeBigDecimalMap200Response();
/**
* Model tests for FakeBigDecimalMap200Response
*/
@Test
public void testFakeBigDecimalMap200Response() {
// TODO: test FakeBigDecimalMap200Response
}
/**
* Test the property 'someId'
*/
@Test
public void someIdTest() {
// TODO: test someId
}
/**
* Test the property 'someMap'
*/
@Test
public void someMapTest() {
// TODO: test someMap
}
}