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:
William Cheng
2023-11-05 22:43:45 +08:00
committed by GitHub
parent 339596aeec
commit 49208144e1
41 changed files with 2682 additions and 1 deletions

View File

@@ -120,6 +120,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

View File

@@ -403,6 +403,22 @@ paths:
summary: Test body parameter(s)
tags:
- body
/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
/echo/body/Pet/response_string:
post:
description: Test empty response body
@@ -513,6 +529,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:

View File

@@ -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 |
@@ -273,6 +274,97 @@ No authorization required
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successful operation | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
<a id="testechobodyallofpet"></a>
# **TestEchoBodyAllOfPet**
> Pet TestEchoBodyAllOfPet (Pet? pet = null)
Test body parameter(s)
Test body parameter(s)
### Example
```csharp
using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class TestEchoBodyAllOfPetExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "http://localhost:3000";
var apiInstance = new BodyApi(config);
var pet = new Pet?(); // Pet? | Pet object that needs to be added to the store (optional)
try
{
// Test body parameter(s)
Pet result = apiInstance.TestEchoBodyAllOfPet(pet);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling BodyApi.TestEchoBodyAllOfPet: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
```
#### Using the TestEchoBodyAllOfPetWithHttpInfo variant
This returns an ApiResponse object which contains the response data, status code and headers.
```csharp
try
{
// Test body parameter(s)
ApiResponse<Pet> response = apiInstance.TestEchoBodyAllOfPetWithHttpInfo(pet);
Debug.Write("Status Code: " + response.StatusCode);
Debug.Write("Response Headers: " + response.Headers);
Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
Debug.Print("Exception when calling BodyApi.TestEchoBodyAllOfPetWithHttpInfo: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
```
### 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 |
|-------------|-------------|------------------|

View File

@@ -95,6 +95,29 @@ namespace Org.OpenAPITools.Api
/// <returns>ApiResponse of string</returns>
ApiResponse<string> TestBodyMultipartFormdataArrayOfBinaryWithHttpInfo(List<System.IO.Stream> files, int operationIndex = 0);
/// <summary>
/// Test body parameter(s)
/// </summary>
/// <remarks>
/// Test body parameter(s)
/// </remarks>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <returns>Pet</returns>
Pet TestEchoBodyAllOfPet(Pet? pet = default(Pet?), int operationIndex = 0);
/// <summary>
/// Test body parameter(s)
/// </summary>
/// <remarks>
/// Test body parameter(s)
/// </remarks>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <returns>ApiResponse of Pet</returns>
ApiResponse<Pet> TestEchoBodyAllOfPetWithHttpInfo(Pet? pet = default(Pet?), int operationIndex = 0);
/// <summary>
/// Test free form object
/// </summary>
/// <remarks>
@@ -269,6 +292,31 @@ namespace Org.OpenAPITools.Api
/// <returns>Task of ApiResponse (string)</returns>
System.Threading.Tasks.Task<ApiResponse<string>> TestBodyMultipartFormdataArrayOfBinaryWithHttpInfoAsync(List<System.IO.Stream> files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
/// <summary>
/// Test body parameter(s)
/// </summary>
/// <remarks>
/// Test body parameter(s)
/// </remarks>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of Pet</returns>
System.Threading.Tasks.Task<Pet> TestEchoBodyAllOfPetAsync(Pet? pet = default(Pet?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
/// <summary>
/// Test body parameter(s)
/// </summary>
/// <remarks>
/// Test body parameter(s)
/// </remarks>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ApiResponse (Pet)</returns>
System.Threading.Tasks.Task<ApiResponse<Pet>> TestEchoBodyAllOfPetWithHttpInfoAsync(Pet? pet = default(Pet?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
/// <summary>
/// Test free form object
/// </summary>
/// <remarks>
@@ -900,6 +948,140 @@ namespace Org.OpenAPITools.Api
return localVarResponse;
}
/// <summary>
/// Test body parameter(s) Test body parameter(s)
/// </summary>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <returns>Pet</returns>
public Pet TestEchoBodyAllOfPet(Pet? pet = default(Pet?), int operationIndex = 0)
{
Org.OpenAPITools.Client.ApiResponse<Pet> localVarResponse = TestEchoBodyAllOfPetWithHttpInfo(pet);
return localVarResponse.Data;
}
/// <summary>
/// Test body parameter(s) Test body parameter(s)
/// </summary>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <returns>ApiResponse of Pet</returns>
public Org.OpenAPITools.Client.ApiResponse<Pet> TestEchoBodyAllOfPetWithHttpInfo(Pet? pet = default(Pet?), int operationIndex = 0)
{
Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();
string[] _contentTypes = new string[] {
"application/json"
};
// to determine the Accept header
string[] _accepts = new string[] {
"application/json"
};
var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
if (localVarContentType != null)
{
localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
}
var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);
if (localVarAccept != null)
{
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
}
localVarRequestOptions.Data = pet;
localVarRequestOptions.Operation = "BodyApi.TestEchoBodyAllOfPet";
localVarRequestOptions.OperationIndex = operationIndex;
// make the HTTP request
var localVarResponse = this.Client.Post<Pet>("/echo/body/allOf/Pet", localVarRequestOptions, this.Configuration);
if (this.ExceptionFactory != null)
{
Exception _exception = this.ExceptionFactory("TestEchoBodyAllOfPet", localVarResponse);
if (_exception != null)
{
throw _exception;
}
}
return localVarResponse;
}
/// <summary>
/// Test body parameter(s) Test body parameter(s)
/// </summary>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of Pet</returns>
public async System.Threading.Tasks.Task<Pet> TestEchoBodyAllOfPetAsync(Pet? pet = default(Pet?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
Org.OpenAPITools.Client.ApiResponse<Pet> localVarResponse = await TestEchoBodyAllOfPetWithHttpInfoAsync(pet, operationIndex, cancellationToken).ConfigureAwait(false);
return localVarResponse.Data;
}
/// <summary>
/// Test body parameter(s) Test body parameter(s)
/// </summary>
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="pet">Pet object that needs to be added to the store (optional)</param>
/// <param name="operationIndex">Index associated with the operation.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ApiResponse (Pet)</returns>
public async System.Threading.Tasks.Task<Org.OpenAPITools.Client.ApiResponse<Pet>> TestEchoBodyAllOfPetWithHttpInfoAsync(Pet? pet = default(Pet?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();
string[] _contentTypes = new string[] {
"application/json"
};
// to determine the Accept header
string[] _accepts = new string[] {
"application/json"
};
var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
if (localVarContentType != null)
{
localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
}
var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);
if (localVarAccept != null)
{
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
}
localVarRequestOptions.Data = pet;
localVarRequestOptions.Operation = "BodyApi.TestEchoBodyAllOfPet";
localVarRequestOptions.OperationIndex = operationIndex;
// make the HTTP request
var localVarResponse = await this.AsynchronousClient.PostAsync<Pet>("/echo/body/allOf/Pet", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);
if (this.ExceptionFactory != null)
{
Exception _exception = this.ExceptionFactory("TestEchoBodyAllOfPet", localVarResponse);
if (_exception != null)
{
throw _exception;
}
}
return localVarResponse;
}
/// <summary>
/// Test free form object Test free form object
/// </summary>