mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 17:00:43 +00:00
Better handling of allOf in request body (#16991)
* better handling of allOf in request body, add tests * additional checks * fix description
This commit is contained in:
@@ -114,6 +114,7 @@ Class | Method | HTTP request | Description
|
||||
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body
|
||||
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
|
||||
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
|
||||
*BodyApi* | [**testEchoBodyAllOfPet**](docs/BodyApi.md#testEchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s)
|
||||
*BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object
|
||||
*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s)
|
||||
*BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body
|
||||
|
||||
@@ -421,6 +421,24 @@ paths:
|
||||
- body
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
/echo/body/allOf/Pet:
|
||||
post:
|
||||
description: Test body parameter(s)
|
||||
operationId: test/echo/body/allOf/Pet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/AllOfPet'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: Successful operation
|
||||
summary: Test body parameter(s)
|
||||
tags:
|
||||
- body
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
/echo/body/Pet/response_string:
|
||||
post:
|
||||
description: Test empty response body
|
||||
@@ -541,6 +559,13 @@ components:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
AllOfPet:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
Tag:
|
||||
content:
|
||||
application/json:
|
||||
|
||||
@@ -7,6 +7,7 @@ All URIs are relative to *http://localhost:3000*
|
||||
| [**testBinaryGif**](BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body |
|
||||
| [**testBodyApplicationOctetstreamBinary**](BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) |
|
||||
| [**testBodyMultipartFormdataArrayOfBinary**](BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime |
|
||||
| [**testEchoBodyAllOfPet**](BodyApi.md#testEchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) |
|
||||
| [**testEchoBodyFreeFormObjectResponseString**](BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object |
|
||||
| [**testEchoBodyPet**](BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) |
|
||||
| [**testEchoBodyPetResponseString**](BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body |
|
||||
@@ -208,6 +209,72 @@ No authorization required
|
||||
| **200** | Successful operation | - |
|
||||
|
||||
|
||||
## testEchoBodyAllOfPet
|
||||
|
||||
> Pet testEchoBodyAllOfPet(pet)
|
||||
|
||||
Test body parameter(s)
|
||||
|
||||
Test body parameter(s)
|
||||
|
||||
### 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.BodyApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://localhost:3000");
|
||||
|
||||
BodyApi apiInstance = new BodyApi(defaultClient);
|
||||
Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
|
||||
try {
|
||||
Pet result = apiInstance.testEchoBodyAllOfPet(pet);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling BodyApi#testEchoBodyAllOfPet");
|
||||
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 |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | Successful operation | - |
|
||||
|
||||
|
||||
## testEchoBodyFreeFormObjectResponseString
|
||||
|
||||
> String testEchoBodyFreeFormObjectResponseString(body)
|
||||
|
||||
@@ -265,6 +265,75 @@ public class BodyApi {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test body parameter(s)
|
||||
* Test body parameter(s)
|
||||
* @param pet Pet object that needs to be added to the store (optional)
|
||||
* @return Pet
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public Pet testEchoBodyAllOfPet(Pet pet) throws ApiException {
|
||||
return this.testEchoBodyAllOfPet(pet, Collections.emptyMap());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test body parameter(s)
|
||||
* Test body parameter(s)
|
||||
* @param pet Pet object that needs to be added to the store (optional)
|
||||
* @param additionalHeaders additionalHeaders for this call
|
||||
* @return Pet
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public Pet testEchoBodyAllOfPet(Pet pet, Map<String, String> additionalHeaders) throws ApiException {
|
||||
Object localVarPostBody = pet;
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/echo/body/allOf/Pet";
|
||||
|
||||
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 = {
|
||||
"application/json"
|
||||
};
|
||||
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
|
||||
|
||||
final String[] localVarContentTypes = {
|
||||
"application/json"
|
||||
};
|
||||
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
||||
|
||||
String[] localVarAuthNames = new String[] { };
|
||||
|
||||
TypeReference<Pet> localVarReturnType = new TypeReference<Pet>() {};
|
||||
return apiClient.invokeAPI(
|
||||
localVarPath,
|
||||
"POST",
|
||||
localVarQueryParams,
|
||||
localVarCollectionQueryParams,
|
||||
localVarQueryStringJoiner.toString(),
|
||||
localVarPostBody,
|
||||
localVarHeaderParams,
|
||||
localVarCookieParams,
|
||||
localVarFormParams,
|
||||
localVarAccept,
|
||||
localVarContentType,
|
||||
localVarAuthNames,
|
||||
localVarReturnType
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test free form object
|
||||
* Test free form object
|
||||
|
||||
Reference in New Issue
Block a user