use map/array model class only if it is generated (#17612)

* fix

* tests

* generate samples

* refactor
This commit is contained in:
martin-mfg
2024-01-29 14:35:21 +01:00
committed by GitHub
parent 5055ebade9
commit 9afea50cab
210 changed files with 10550 additions and 6 deletions

View File

@@ -146,6 +146,8 @@ Class | Method | HTTP request | Description
*FakeApi* | [**testJsonFormDataWithHttpInfo**](docs/FakeApi.md#testJsonFormDataWithHttpInfo) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters |
*FakeApi* | [**testQueryParameterCollectionFormatWithHttpInfo**](docs/FakeApi.md#testQueryParameterCollectionFormatWithHttpInfo) | **PUT** /fake/test-query-parameters |
*FakeApi* | [**testStringMapReference**](docs/FakeApi.md#testStringMapReference) | **POST** /fake/stringMap-reference | test referenced string map
*FakeApi* | [**testStringMapReferenceWithHttpInfo**](docs/FakeApi.md#testStringMapReferenceWithHttpInfo) | **POST** /fake/stringMap-reference | test referenced string map
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
*FakeClassnameTags123Api* | [**testClassnameWithHttpInfo**](docs/FakeClassnameTags123Api.md#testClassnameWithHttpInfo) | **PATCH** /fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store

View File

@@ -971,6 +971,25 @@ paths:
- fake
x-content-type: application/json
x-accepts: application/json
/fake/stringMap-reference:
post:
description: ""
operationId: testStringMapReference
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/MapOfString'
description: request body
required: true
responses:
"200":
description: successful operation
summary: test referenced string map
tags:
- fake
x-content-type: application/json
x-accepts: application/json
/fake/inline-additionalProperties:
post:
description: ""
@@ -1798,6 +1817,11 @@ components:
additionalProperties: true
description: A schema consisting only of additional properties
type: object
MapOfString:
additionalProperties:
type: string
description: A schema consisting only of additional properties of type string
type: object
OuterEnum:
enum:
- placed

View File

@@ -40,6 +40,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
| [**testJsonFormDataWithHttpInfo**](FakeApi.md#testJsonFormDataWithHttpInfo) | **GET** /fake/jsonFormData | test json serialization of form data |
| [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | |
| [**testQueryParameterCollectionFormatWithHttpInfo**](FakeApi.md#testQueryParameterCollectionFormatWithHttpInfo) | **PUT** /fake/test-query-parameters | |
| [**testStringMapReference**](FakeApi.md#testStringMapReference) | **POST** /fake/stringMap-reference | test referenced string map |
| [**testStringMapReferenceWithHttpInfo**](FakeApi.md#testStringMapReferenceWithHttpInfo) | **POST** /fake/stringMap-reference | test referenced string map |
@@ -2731,3 +2733,144 @@ No authorization required
|-------------|-------------|------------------|
| **200** | Success | - |
## testStringMapReference
> CompletableFuture<Void> testStringMapReference(requestBody)
test referenced string map
### 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);
Map<String, String> requestBody = new HashMap(); // Map<String, String> | request body
try {
CompletableFuture<Void> result = apiInstance.testStringMapReference(requestBody);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testStringMapReference");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **requestBody** | [**Map&lt;String, String&gt;**](String.md)| request body | |
### Return type
CompletableFuture<void> (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | successful operation | - |
## testStringMapReferenceWithHttpInfo
> CompletableFuture<ApiResponse<Void>> testStringMapReference testStringMapReferenceWithHttpInfo(requestBody)
test referenced string map
### 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);
Map<String, String> requestBody = new HashMap(); // Map<String, String> | request body
try {
CompletableFuture<ApiResponse<Void>> response = apiInstance.testStringMapReferenceWithHttpInfo(requestBody);
System.out.println("Status code: " + response.get().getStatusCode());
System.out.println("Response headers: " + response.get().getHeaders());
} catch (InterruptedException | ExecutionException e) {
ApiException apiException = (ApiException)e.getCause();
System.err.println("Exception when calling FakeApi#testStringMapReference");
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#testStringMapReference");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
System.err.println("Reason: " + e.getResponseBody());
e.printStackTrace();
}
}
}
```
### Parameters
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **requestBody** | [**Map&lt;String, String&gt;**](String.md)| request body | |
### Return type
CompletableFuture<ApiResponse<Void>>
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | successful operation | - |

View File

@@ -2020,4 +2020,87 @@ public class FakeApi {
}
return localVarRequestBuilder;
}
/**
* test referenced string map
*
* @param requestBody request body (required)
* @return CompletableFuture&lt;Void&gt;
* @throws ApiException if fails to make API call
*/
public CompletableFuture<Void> testStringMapReference(Map<String, String> requestBody) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody);
return memberVarHttpClient.sendAsync(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
if (localVarResponse.statusCode()/ 100 != 2) {
return CompletableFuture.failedFuture(getApiException("testStringMapReference", localVarResponse));
}
return CompletableFuture.completedFuture(null);
});
}
catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* test referenced string map
*
* @param requestBody request body (required)
* @return CompletableFuture&lt;ApiResponse&lt;Void&gt;&gt;
* @throws ApiException if fails to make API call
*/
public CompletableFuture<ApiResponse<Void>> testStringMapReferenceWithHttpInfo(Map<String, String> requestBody) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody);
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("testStringMapReference", localVarResponse));
}
return CompletableFuture.completedFuture(
new ApiResponse<Void>(localVarResponse.statusCode(), localVarResponse.headers().map(), null)
);
}
);
}
catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder testStringMapReferenceRequestBuilder(Map<String, String> requestBody) throws ApiException {
// verify the required parameter 'requestBody' is set
if (requestBody == null) {
throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testStringMapReference");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/fake/stringMap-reference";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(requestBody);
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
} catch (IOException e) {
throw new ApiException(e);
}
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
}