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

@@ -129,6 +129,7 @@ Class | Method | HTTP request | Description
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters |
*FakeApi* | [**testStringMapReference**](docs/FakeApi.md#testStringMapReference) | **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
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet

View File

@@ -1029,6 +1029,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: ""
@@ -1874,6 +1893,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

@@ -25,6 +25,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
| [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data |
| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property |
| [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | |
| [**testStringMapReference**](FakeApi.md#testStringMapReference) | **POST** /fake/stringMap-reference | test referenced string map |
@@ -1473,3 +1474,68 @@ No authorization required
|-------------|-------------|------------------|
| **200** | Success | - |
## testStringMapReference
> 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;
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 {
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
null (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 | - |

View File

@@ -1737,4 +1737,75 @@ if (param2 != null)
);
}
/**
* test referenced string map
*
* @param requestBody request body (required)
* @throws ApiException if fails to make API call
*/
public void testStringMapReference(Map<String, String> requestBody) throws ApiException {
this.testStringMapReference(requestBody, Collections.emptyMap());
}
/**
* test referenced string map
*
* @param requestBody request body (required)
* @param additionalHeaders additionalHeaders for this call
* @throws ApiException if fails to make API call
*/
public void testStringMapReference(Map<String, String> requestBody, Map<String, String> additionalHeaders) throws ApiException {
Object localVarPostBody = requestBody;
// verify the required parameter 'requestBody' is set
if (requestBody == null) {
throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testStringMapReference");
}
// create path and map variables
String localVarPath = "/fake/stringMap-reference";
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarHeaderParams.putAll(additionalHeaders);
final String[] localVarAccepts = {
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(
localVarPath,
"POST",
localVarQueryParams,
localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(),
localVarPostBody,
localVarHeaderParams,
localVarCookieParams,
localVarFormParams,
localVarAccept,
localVarContentType,
localVarAuthNames,
null
);
}
}