diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 6bbbdb567c11..d8ee95b5ae9f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -7581,8 +7581,19 @@ public CodegenParameter fromRequestBody(RequestBody body, Set imports, S String name = null; LOGGER.debug("Request body = {}", body); Schema schema = ModelUtils.getSchemaFromRequestBody(body); - codegenParameter.setContent(getContent(body.getContent(), imports, "RequestBody")); + Schema original = null; + // check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level + if (ModelUtils.isAllOf(schema) && schema.getAllOf().size() == 1 && + schema.getType() == null && schema.getTypes() == null) { + if (schema.getAllOf().get(0) instanceof Schema) { + original = schema; + schema = (Schema) schema.getAllOf().get(0); + } else { + LOGGER.error("Unknown type in allOf schema. Please report the issue via openapi-generator's Github issue tracker."); + } + } + codegenParameter.setContent(getContent(body.getContent(), imports, "RequestBody")); if (StringUtils.isNotBlank(schema.get$ref())) { name = ModelUtils.getSimpleRef(schema.get$ref()); } @@ -7651,6 +7662,20 @@ public CodegenParameter fromRequestBody(RequestBody body, Set imports, S // should be overridden by lang codegen setParameterExampleValue(codegenParameter, body); + // restore original schema with description, extensions etc + if (original != null) { + schema = original; + // evaluate common attributes such as description if defined in the top level + if (schema.getDescription() != null) { + codegenParameter.description = escapeText(schema.getDescription()); + codegenParameter.unescapedDescription = schema.getDescription(); + } + + if (original.getExtensions() != null) { + codegenParameter.vendorExtensions.putAll(original.getExtensions()); + } + } + return codegenParameter; } diff --git a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml index 9d9bbf3e85f1..b96a62333ed5 100644 --- a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml @@ -430,6 +430,22 @@ paths: application/json: schema: $ref: '#/components/schemas/Pet' + /echo/body/allOf/Pet: + post: + tags: + - body + summary: Test body parameter(s) + description: Test body parameter(s) + operationId: test/echo/body/allOf/Pet + requestBody: + $ref: '#/components/requestBodies/AllOfPet' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' /echo/body/Pet/response_string: post: tags: @@ -554,6 +570,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: diff --git a/samples/client/echo_api/csharp-restsharp/README.md b/samples/client/echo_api/csharp-restsharp/README.md index 96bb4d4a50d6..065fef947005 100644 --- a/samples/client/echo_api/csharp-restsharp/README.md +++ b/samples/client/echo_api/csharp-restsharp/README.md @@ -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 diff --git a/samples/client/echo_api/csharp-restsharp/api/openapi.yaml b/samples/client/echo_api/csharp-restsharp/api/openapi.yaml index cef46d3ec210..18f869cd6b06 100644 --- a/samples/client/echo_api/csharp-restsharp/api/openapi.yaml +++ b/samples/client/echo_api/csharp-restsharp/api/openapi.yaml @@ -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: diff --git a/samples/client/echo_api/csharp-restsharp/docs/BodyApi.md b/samples/client/echo_api/csharp-restsharp/docs/BodyApi.md index 4d33c624608b..e8e87af2d769 100644 --- a/samples/client/echo_api/csharp-restsharp/docs/BodyApi.md +++ b/samples/client/echo_api/csharp-restsharp/docs/BodyApi.md @@ -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) + + +# **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 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 | |-------------|-------------|------------------| diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/BodyApi.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/BodyApi.cs index abcd4a4071a7..984066576a88 100644 --- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/BodyApi.cs +++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/BodyApi.cs @@ -95,6 +95,29 @@ public interface IBodyApiSync : IApiAccessor /// ApiResponse of string ApiResponse TestBodyMultipartFormdataArrayOfBinaryWithHttpInfo(List files, int operationIndex = 0); /// + /// Test body parameter(s) + /// + /// + /// Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// Pet + Pet TestEchoBodyAllOfPet(Pet? pet = default(Pet?), int operationIndex = 0); + + /// + /// Test body parameter(s) + /// + /// + /// Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// ApiResponse of Pet + ApiResponse TestEchoBodyAllOfPetWithHttpInfo(Pet? pet = default(Pet?), int operationIndex = 0); + /// /// Test free form object /// /// @@ -269,6 +292,31 @@ public interface IBodyApiAsync : IApiAccessor /// Task of ApiResponse (string) System.Threading.Tasks.Task> TestBodyMultipartFormdataArrayOfBinaryWithHttpInfoAsync(List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test body parameter(s) + /// + /// + /// Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of Pet + System.Threading.Tasks.Task TestEchoBodyAllOfPetAsync(Pet? pet = default(Pet?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test body parameter(s) + /// + /// + /// Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (Pet) + System.Threading.Tasks.Task> TestEchoBodyAllOfPetWithHttpInfoAsync(Pet? pet = default(Pet?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// Test free form object /// /// @@ -900,6 +948,140 @@ public Org.OpenAPITools.Client.ApiResponse TestBodyMultipartFormdataArra return localVarResponse; } + /// + /// Test body parameter(s) Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// Pet + public Pet TestEchoBodyAllOfPet(Pet? pet = default(Pet?), int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = TestEchoBodyAllOfPetWithHttpInfo(pet); + return localVarResponse.Data; + } + + /// + /// Test body parameter(s) Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// ApiResponse of Pet + public Org.OpenAPITools.Client.ApiResponse 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("/echo/body/allOf/Pet", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("TestEchoBodyAllOfPet", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test body parameter(s) Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of Pet + public async System.Threading.Tasks.Task TestEchoBodyAllOfPetAsync(Pet? pet = default(Pet?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await TestEchoBodyAllOfPetWithHttpInfoAsync(pet, operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test body parameter(s) Test body parameter(s) + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (Pet) + public async System.Threading.Tasks.Task> 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("/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; + } + /// /// Test free form object Test free form object /// diff --git a/samples/client/echo_api/go/README.md b/samples/client/echo_api/go/README.md index c79c3ec989f4..44c3d8a5a05f 100644 --- a/samples/client/echo_api/go/README.md +++ b/samples/client/echo_api/go/README.md @@ -81,6 +81,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 diff --git a/samples/client/echo_api/go/api/openapi.yaml b/samples/client/echo_api/go/api/openapi.yaml index 104784c4a235..deb46346fca2 100644 --- a/samples/client/echo_api/go/api/openapi.yaml +++ b/samples/client/echo_api/go/api/openapi.yaml @@ -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: diff --git a/samples/client/echo_api/go/api_body.go b/samples/client/echo_api/go/api_body.go index c21bc9822fa6..8700b5b42293 100644 --- a/samples/client/echo_api/go/api_body.go +++ b/samples/client/echo_api/go/api_body.go @@ -356,6 +356,114 @@ func (a *BodyAPIService) TestBodyMultipartFormdataArrayOfBinaryExecute(r ApiTest return localVarReturnValue, localVarHTTPResponse, nil } +type ApiTestEchoBodyAllOfPetRequest struct { + ctx context.Context + ApiService *BodyAPIService + pet *Pet +} + +// Pet object that needs to be added to the store +func (r ApiTestEchoBodyAllOfPetRequest) Pet(pet Pet) ApiTestEchoBodyAllOfPetRequest { + r.pet = &pet + return r +} + +func (r ApiTestEchoBodyAllOfPetRequest) Execute() (*Pet, *http.Response, error) { + return r.ApiService.TestEchoBodyAllOfPetExecute(r) +} + +/* +TestEchoBodyAllOfPet Test body parameter(s) + +Test body parameter(s) + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiTestEchoBodyAllOfPetRequest +*/ +func (a *BodyAPIService) TestEchoBodyAllOfPet(ctx context.Context) ApiTestEchoBodyAllOfPetRequest { + return ApiTestEchoBodyAllOfPetRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// @return Pet +func (a *BodyAPIService) TestEchoBodyAllOfPetExecute(r ApiTestEchoBodyAllOfPetRequest) (*Pet, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Pet + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BodyAPIService.TestEchoBodyAllOfPet") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/echo/body/allOf/Pet" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.pet + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiTestEchoBodyFreeFormObjectResponseStringRequest struct { ctx context.Context ApiService *BodyAPIService diff --git a/samples/client/echo_api/go/docs/BodyAPI.md b/samples/client/echo_api/go/docs/BodyAPI.md index 73b021cdcdea..111542e9714b 100644 --- a/samples/client/echo_api/go/docs/BodyAPI.md +++ b/samples/client/echo_api/go/docs/BodyAPI.md @@ -7,6 +7,7 @@ Method | HTTP request | Description [**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 @@ -207,6 +208,72 @@ No authorization required [[Back to README]](../README.md) +## TestEchoBodyAllOfPet + +> Pet TestEchoBodyAllOfPet(ctx).Pet(pet).Execute() + +Test body parameter(s) + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.BodyAPI.TestEchoBodyAllOfPet(context.Background()).Pet(pet).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `BodyAPI.TestEchoBodyAllOfPet``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `TestEchoBodyAllOfPet`: Pet + fmt.Fprintf(os.Stdout, "Response from `BodyAPI.TestEchoBodyAllOfPet`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiTestEchoBodyAllOfPetRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## TestEchoBodyFreeFormObjectResponseString > string TestEchoBodyFreeFormObjectResponseString(ctx).Body(body).Execute() diff --git a/samples/client/echo_api/java/apache-httpclient/README.md b/samples/client/echo_api/java/apache-httpclient/README.md index c0f6067fdeb3..c0551b4fb8c2 100644 --- a/samples/client/echo_api/java/apache-httpclient/README.md +++ b/samples/client/echo_api/java/apache-httpclient/README.md @@ -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 diff --git a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml index de47c7b5e355..0f6131f70618 100644 --- a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml +++ b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml @@ -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: diff --git a/samples/client/echo_api/java/apache-httpclient/docs/BodyApi.md b/samples/client/echo_api/java/apache-httpclient/docs/BodyApi.md index 9eecf09eb766..d83932321002 100644 --- a/samples/client/echo_api/java/apache-httpclient/docs/BodyApi.md +++ b/samples/client/echo_api/java/apache-httpclient/docs/BodyApi.md @@ -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) diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java index f03255836397..0b62e882472a 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java @@ -265,6 +265,75 @@ public String testBodyMultipartFormdataArrayOfBinary(List files, Map additionalHeaders) throws ApiException { + Object localVarPostBody = pet; + + // create path and map variables + String localVarPath = "/echo/body/allOf/Pet"; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + 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 localVarReturnType = new TypeReference() {}; + 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 diff --git a/samples/client/echo_api/java/feign-gson/api/openapi.yaml b/samples/client/echo_api/java/feign-gson/api/openapi.yaml index de47c7b5e355..0f6131f70618 100644 --- a/samples/client/echo_api/java/feign-gson/api/openapi.yaml +++ b/samples/client/echo_api/java/feign-gson/api/openapi.yaml @@ -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: diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/BodyApi.java index fbc19a32eb69..fe1c9f927567 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/BodyApi.java @@ -101,6 +101,35 @@ public interface BodyApi extends ApiClient.Api { + /** + * Test body parameter(s) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @return Pet + */ + @RequestLine("POST /echo/body/allOf/Pet") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + Pet testEchoBodyAllOfPet(Pet pet); + + /** + * Test body parameter(s) + * Similar to testEchoBodyAllOfPet but it also returns the http response headers . + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @return A ApiResponse that wraps the response boyd and the http headers. + */ + @RequestLine("POST /echo/body/allOf/Pet") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + ApiResponse testEchoBodyAllOfPetWithHttpInfo(Pet pet); + + + /** * Test free form object * Test free form object diff --git a/samples/client/echo_api/java/native/README.md b/samples/client/echo_api/java/native/README.md index 6caea3a23da1..58ece7603ded 100644 --- a/samples/client/echo_api/java/native/README.md +++ b/samples/client/echo_api/java/native/README.md @@ -112,6 +112,8 @@ Class | Method | HTTP request | Description *BodyApi* | [**testBodyApplicationOctetstreamBinaryWithHttpInfo**](docs/BodyApi.md#testBodyApplicationOctetstreamBinaryWithHttpInfo) | **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* | [**testBodyMultipartFormdataArrayOfBinaryWithHttpInfo**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinaryWithHttpInfo) | **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* | [**testEchoBodyAllOfPetWithHttpInfo**](docs/BodyApi.md#testEchoBodyAllOfPetWithHttpInfo) | **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* | [**testEchoBodyFreeFormObjectResponseStringWithHttpInfo**](docs/BodyApi.md#testEchoBodyFreeFormObjectResponseStringWithHttpInfo) | **POST** /echo/body/FreeFormObject/response_string | Test free form object *BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) diff --git a/samples/client/echo_api/java/native/api/openapi.yaml b/samples/client/echo_api/java/native/api/openapi.yaml index de47c7b5e355..0f6131f70618 100644 --- a/samples/client/echo_api/java/native/api/openapi.yaml +++ b/samples/client/echo_api/java/native/api/openapi.yaml @@ -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: diff --git a/samples/client/echo_api/java/native/docs/BodyApi.md b/samples/client/echo_api/java/native/docs/BodyApi.md index 3661d666b2f7..1b680eb3918a 100644 --- a/samples/client/echo_api/java/native/docs/BodyApi.md +++ b/samples/client/echo_api/java/native/docs/BodyApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://localhost:3000* | [**testBodyApplicationOctetstreamBinaryWithHttpInfo**](BodyApi.md#testBodyApplicationOctetstreamBinaryWithHttpInfo) | **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 | | [**testBodyMultipartFormdataArrayOfBinaryWithHttpInfo**](BodyApi.md#testBodyMultipartFormdataArrayOfBinaryWithHttpInfo) | **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) | +| [**testEchoBodyAllOfPetWithHttpInfo**](BodyApi.md#testEchoBodyAllOfPetWithHttpInfo) | **POST** /echo/body/allOf/Pet | Test body parameter(s) | | [**testEchoBodyFreeFormObjectResponseString**](BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object | | [**testEchoBodyFreeFormObjectResponseStringWithHttpInfo**](BodyApi.md#testEchoBodyFreeFormObjectResponseStringWithHttpInfo) | **POST** /echo/body/FreeFormObject/response_string | Test free form object | | [**testEchoBodyPet**](BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) | @@ -415,6 +417,140 @@ 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 | - | + +## testEchoBodyAllOfPetWithHttpInfo + +> ApiResponse testEchoBodyAllOfPet testEchoBodyAllOfPetWithHttpInfo(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.ApiResponse; +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 { + ApiResponse response = apiInstance.testEchoBodyAllOfPetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling BodyApi#testEchoBodyAllOfPet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] | + +### Return type + +ApiResponse<[**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) diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java index 78f0991205bd..f075423ce95b 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java @@ -349,6 +349,79 @@ private HttpRequest.Builder testBodyMultipartFormdataArrayOfBinaryRequestBuilder } return localVarRequestBuilder; } + /** + * 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 { + ApiResponse localVarResponse = testEchoBodyAllOfPetWithHttpInfo(pet); + return localVarResponse.getData(); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEchoBodyAllOfPetWithHttpInfo(Pet pet) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEchoBodyAllOfPetRequestBuilder(pet); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("testEchoBodyAllOfPet", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder testEchoBodyAllOfPetRequestBuilder(Pet pet) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/echo/body/allOf/Pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + 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; + } /** * Test free form object * Test free form object diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java index 92c7966b05c8..0eb53fa61b18 100644 --- a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java +++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java @@ -60,6 +60,28 @@ public void testEchoBodyPet() throws ApiException { Assert.assertNull(p2); } + /** + * Test allOf body parameter(s) + *

+ * Test allOf body parameter(s) + * + * @throws ApiException if the Api call fails + */ + @Test + public void testEchoBodyAllOfPet() throws ApiException { + Pet queryObject = new Pet().id(12345L).name("Hello World"). + photoUrls(Arrays.asList(new String[]{"http://a.com", "http://b.com"})).category(new Category().id(987L).name("new category")); + + Pet p = bodyApi.testEchoBodyAllOfPet(queryObject); + Assert.assertNotNull(p); + Assert.assertEquals("Hello World", p.getName()); + Assert.assertEquals(Long.valueOf(12345L), p.getId()); + + // response is empty body + Pet p2 = bodyApi.testEchoBodyPet(null); + Assert.assertNull(p2); + } + /** * Test query parameter(s) *

diff --git a/samples/client/echo_api/java/okhttp-gson/README.md b/samples/client/echo_api/java/okhttp-gson/README.md index 155878f2f8ca..6c2ba0f4740e 100644 --- a/samples/client/echo_api/java/okhttp-gson/README.md +++ b/samples/client/echo_api/java/okhttp-gson/README.md @@ -122,6 +122,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 diff --git a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml index de47c7b5e355..0f6131f70618 100644 --- a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml +++ b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml @@ -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: diff --git a/samples/client/echo_api/java/okhttp-gson/docs/BodyApi.md b/samples/client/echo_api/java/okhttp-gson/docs/BodyApi.md index 39348a00e2f3..265f46bb01d5 100644 --- a/samples/client/echo_api/java/okhttp-gson/docs/BodyApi.md +++ b/samples/client/echo_api/java/okhttp-gson/docs/BodyApi.md @@ -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 | @@ -195,6 +196,68 @@ 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) diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/BodyApi.java index 413daf159798..f0e04903aa6d 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/BodyApi.java @@ -432,6 +432,124 @@ public okhttp3.Call testBodyMultipartFormdataArrayOfBinaryAsync(List files localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for testEchoBodyAllOfPet + * @param pet Pet object that needs to be added to the store (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public okhttp3.Call testEchoBodyAllOfPetCall(Pet pet, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = pet; + + // create path and map variables + String localVarPath = "/echo/body/allOf/Pet"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call testEchoBodyAllOfPetValidateBeforeCall(Pet pet, final ApiCallback _callback) throws ApiException { + return testEchoBodyAllOfPetCall(pet, _callback); + + } + + /** + * 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 fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public Pet testEchoBodyAllOfPet(Pet pet) throws ApiException { + ApiResponse localVarResp = testEchoBodyAllOfPetWithHttpInfo(pet); + return localVarResp.getData(); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @return ApiResponse<Pet> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public ApiResponse testEchoBodyAllOfPetWithHttpInfo(Pet pet) throws ApiException { + okhttp3.Call localVarCall = testEchoBodyAllOfPetValidateBeforeCall(pet, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Test body parameter(s) (asynchronously) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public okhttp3.Call testEchoBodyAllOfPetAsync(Pet pet, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = testEchoBodyAllOfPetValidateBeforeCall(pet, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for testEchoBodyFreeFormObjectResponseString * @param body Free form object (optional) diff --git a/samples/client/echo_api/php-nextgen/README.md b/samples/client/echo_api/php-nextgen/README.md index 03fa13c33a9a..3e8fd3436dd3 100644 --- a/samples/client/echo_api/php-nextgen/README.md +++ b/samples/client/echo_api/php-nextgen/README.md @@ -80,6 +80,7 @@ Class | Method | HTTP request | Description *BodyApi* | [**testBinaryGif**](docs/Api/BodyApi.md#testbinarygif) | **POST** /binary/gif | Test binary (gif) response body *BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/Api/BodyApi.md#testbodyapplicationoctetstreambinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) *BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/Api/BodyApi.md#testbodymultipartformdataarrayofbinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*BodyApi* | [**testEchoBodyAllOfPet**](docs/Api/BodyApi.md#testechobodyallofpet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) *BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/Api/BodyApi.md#testechobodyfreeformobjectresponsestring) | **POST** /echo/body/FreeFormObject/response_string | Test free form object *BodyApi* | [**testEchoBodyPet**](docs/Api/BodyApi.md#testechobodypet) | **POST** /echo/body/Pet | Test body parameter(s) *BodyApi* | [**testEchoBodyPetResponseString**](docs/Api/BodyApi.md#testechobodypetresponsestring) | **POST** /echo/body/Pet/response_string | Test empty response body diff --git a/samples/client/echo_api/php-nextgen/docs/Api/BodyApi.md b/samples/client/echo_api/php-nextgen/docs/Api/BodyApi.md index 84fb8a7aa783..7b185c725c42 100644 --- a/samples/client/echo_api/php-nextgen/docs/Api/BodyApi.md +++ b/samples/client/echo_api/php-nextgen/docs/Api/BodyApi.md @@ -7,6 +7,7 @@ All URIs are relative to http://localhost:3000, except if the operation defines | [**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 | @@ -178,6 +179,62 @@ No authorization required [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `testEchoBodyAllOfPet()` + +```php +testEchoBodyAllOfPet($pet): \OpenAPI\Client\Model\Pet +``` + +Test body parameter(s) + +Test body parameter(s) + +### Example + +```php +testEchoBodyAllOfPet($pet); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling BodyApi->testEchoBodyAllOfPet: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | [optional] | + +### Return type + +[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + ## `testEchoBodyFreeFormObjectResponseString()` ```php diff --git a/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php b/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php index 8fb03404664e..ec5d46670df4 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php @@ -81,6 +81,9 @@ class BodyApi 'testBodyMultipartFormdataArrayOfBinary' => [ 'multipart/form-data', ], + 'testEchoBodyAllOfPet' => [ + 'application/json', + ], 'testEchoBodyFreeFormObjectResponseString' => [ 'application/json', ], @@ -1007,6 +1010,297 @@ public function testBodyMultipartFormdataArrayOfBinaryRequest( ); } + /** + * Operation testEchoBodyAllOfPet + * + * Test body parameter(s) + * + * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyAllOfPet'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \OpenAPI\Client\Model\Pet + */ + public function testEchoBodyAllOfPet( + ?\OpenAPI\Client\Model\Pet $pet = null, + string $contentType = self::contentTypes['testEchoBodyAllOfPet'][0] + ): \OpenAPI\Client\Model\Pet + { + list($response) = $this->testEchoBodyAllOfPetWithHttpInfo($pet, $contentType); + return $response; + } + + /** + * Operation testEchoBodyAllOfPetWithHttpInfo + * + * Test body parameter(s) + * + * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyAllOfPet'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return array of \OpenAPI\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) + */ + public function testEchoBodyAllOfPetWithHttpInfo( + ?\OpenAPI\Client\Model\Pet $pet = null, + string $contentType = self::contentTypes['testEchoBodyAllOfPet'][0] + ): array + { + $request = $this->testEchoBodyAllOfPetRequest($pet, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\Pet' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\Pet' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\OpenAPI\Client\Model\Pet'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\Pet', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation testEchoBodyAllOfPetAsync + * + * Test body parameter(s) + * + * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyAllOfPet'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function testEchoBodyAllOfPetAsync( + ?\OpenAPI\Client\Model\Pet $pet = null, + string $contentType = self::contentTypes['testEchoBodyAllOfPet'][0] + ): PromiseInterface + { + return $this->testEchoBodyAllOfPetAsyncWithHttpInfo($pet, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testEchoBodyAllOfPetAsyncWithHttpInfo + * + * Test body parameter(s) + * + * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyAllOfPet'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function testEchoBodyAllOfPetAsyncWithHttpInfo( + $pet = null, + string $contentType = self::contentTypes['testEchoBodyAllOfPet'][0] + ): PromiseInterface + { + $returnType = '\OpenAPI\Client\Model\Pet'; + $request = $this->testEchoBodyAllOfPetRequest($pet, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testEchoBodyAllOfPet' + * + * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyAllOfPet'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function testEchoBodyAllOfPetRequest( + $pet = null, + string $contentType = self::contentTypes['testEchoBodyAllOfPet'][0] + ): Request + { + + + + $resourcePath = '/echo/body/allOf/Pet'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($pet)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + } else { + $httpBody = $pet; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Operation testEchoBodyFreeFormObjectResponseString * diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/README.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/README.md index 9096a78c85de..1873ea15fbb4 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/README.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/README.md @@ -98,6 +98,7 @@ Class | Method | HTTP request | Description *BodyApi* | [**test_binary_gif**](docs/BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body *BodyApi* | [**test_body_application_octetstream_binary**](docs/BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) *BodyApi* | [**test_body_multipart_formdata_array_of_binary**](docs/BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*BodyApi* | [**test_echo_body_all_of_pet**](docs/BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) *BodyApi* | [**test_echo_body_free_form_object_response_string**](docs/BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object *BodyApi* | [**test_echo_body_pet**](docs/BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) *BodyApi* | [**test_echo_body_pet_response_string**](docs/BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/docs/BodyApi.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/docs/BodyApi.md index 553100ffc922..cd65141a98fc 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/docs/BodyApi.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/docs/BodyApi.md @@ -7,6 +7,7 @@ Method | HTTP request | Description [**test_binary_gif**](BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body [**test_body_application_octetstream_binary**](BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) [**test_body_multipart_formdata_array_of_binary**](BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +[**test_echo_body_all_of_pet**](BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) [**test_echo_body_free_form_object_response_string**](BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object [**test_echo_body_pet**](BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) [**test_echo_body_pet_response_string**](BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body @@ -207,6 +208,73 @@ No authorization required [[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) +# **test_echo_body_all_of_pet** +> Pet test_echo_body_all_of_pet(pet=pet) + +Test body parameter(s) + +Test body parameter(s) + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.pet import Pet +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost:3000 +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost:3000" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.BodyApi(api_client) + pet = openapi_client.Pet() # Pet | Pet object that needs to be added to the store (optional) + + try: + # Test body parameter(s) + api_response = api_instance.test_echo_body_all_of_pet(pet=pet) + print("The response of BodyApi->test_echo_body_all_of_pet:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling BodyApi->test_echo_body_all_of_pet: %s\n" % e) +``` + + + +### 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 | - | + +[[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) + # **test_echo_body_free_form_object_response_string** > str test_echo_body_free_form_object_response_string(body=body) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py index c9ef69733890..e84a432c4368 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py @@ -851,6 +851,280 @@ def _test_body_multipart_formdata_array_of_binary_serialize( + @validate_call + def test_echo_body_all_of_pet( + self, + pet: Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Pet: + """Test body parameter(s) + + Test body parameter(s) + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_echo_body_all_of_pet_serialize( + pet=pet, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Pet" + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def test_echo_body_all_of_pet_with_http_info( + self, + pet: Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Pet]: + """Test body parameter(s) + + Test body parameter(s) + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_echo_body_all_of_pet_serialize( + pet=pet, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Pet" + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def test_echo_body_all_of_pet_without_preload_content( + self, + pet: Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Test body parameter(s) + + Test body parameter(s) + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_echo_body_all_of_pet_serialize( + pet=pet, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Pet" + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_echo_body_all_of_pet_serialize( + self, + pet, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if pet is not None: + _body_params = pet + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/echo/body/allOf/Pet', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def test_echo_body_free_form_object_response_string( self, diff --git a/samples/client/echo_api/python-pydantic-v1/README.md b/samples/client/echo_api/python-pydantic-v1/README.md index 65c5ff5e5437..61249db8a196 100644 --- a/samples/client/echo_api/python-pydantic-v1/README.md +++ b/samples/client/echo_api/python-pydantic-v1/README.md @@ -98,6 +98,7 @@ Class | Method | HTTP request | Description *BodyApi* | [**test_binary_gif**](docs/BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body *BodyApi* | [**test_body_application_octetstream_binary**](docs/BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) *BodyApi* | [**test_body_multipart_formdata_array_of_binary**](docs/BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*BodyApi* | [**test_echo_body_all_of_pet**](docs/BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) *BodyApi* | [**test_echo_body_free_form_object_response_string**](docs/BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object *BodyApi* | [**test_echo_body_pet**](docs/BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) *BodyApi* | [**test_echo_body_pet_response_string**](docs/BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body diff --git a/samples/client/echo_api/python-pydantic-v1/docs/BodyApi.md b/samples/client/echo_api/python-pydantic-v1/docs/BodyApi.md index 553100ffc922..cd65141a98fc 100644 --- a/samples/client/echo_api/python-pydantic-v1/docs/BodyApi.md +++ b/samples/client/echo_api/python-pydantic-v1/docs/BodyApi.md @@ -7,6 +7,7 @@ Method | HTTP request | Description [**test_binary_gif**](BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body [**test_body_application_octetstream_binary**](BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) [**test_body_multipart_formdata_array_of_binary**](BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +[**test_echo_body_all_of_pet**](BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) [**test_echo_body_free_form_object_response_string**](BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object [**test_echo_body_pet**](BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) [**test_echo_body_pet_response_string**](BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body @@ -207,6 +208,73 @@ No authorization required [[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) +# **test_echo_body_all_of_pet** +> Pet test_echo_body_all_of_pet(pet=pet) + +Test body parameter(s) + +Test body parameter(s) + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.pet import Pet +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost:3000 +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost:3000" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.BodyApi(api_client) + pet = openapi_client.Pet() # Pet | Pet object that needs to be added to the store (optional) + + try: + # Test body parameter(s) + api_response = api_instance.test_echo_body_all_of_pet(pet=pet) + print("The response of BodyApi->test_echo_body_all_of_pet:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling BodyApi->test_echo_body_all_of_pet: %s\n" % e) +``` + + + +### 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 | - | + +[[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) + # **test_echo_body_free_form_object_response_string** > str test_echo_body_free_form_object_response_string(body=body) diff --git a/samples/client/echo_api/python-pydantic-v1/openapi_client/api/body_api.py b/samples/client/echo_api/python-pydantic-v1/openapi_client/api/body_api.py index ebb8111b7725..925f1ae6de28 100644 --- a/samples/client/echo_api/python-pydantic-v1/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python-pydantic-v1/openapi_client/api/body_api.py @@ -479,6 +479,153 @@ def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : co collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def test_echo_body_all_of_pet(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> Pet: # noqa: E501 + """Test body parameter(s) # noqa: E501 + + Test body parameter(s) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_echo_body_all_of_pet(pet, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Pet + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_echo_body_all_of_pet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_echo_body_all_of_pet_with_http_info(pet, **kwargs) # noqa: E501 + + @validate_arguments + def test_echo_body_all_of_pet_with_http_info(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Test body parameter(s) # noqa: E501 + + Test body parameter(s) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_echo_body_all_of_pet_with_http_info(pet, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Pet, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'pet' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_echo_body_all_of_pet" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['pet'] is not None: + _body_params = _params['pet'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Pet", + } + + return self.api_client.call_api( + '/echo/body/allOf/Pet', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def test_echo_body_free_form_object_response_string(self, body : Annotated[Optional[Dict[str, Any]], Field(description="Free form object")] = None, **kwargs) -> str: # noqa: E501 """Test free form object # noqa: E501 diff --git a/samples/client/echo_api/python/README.md b/samples/client/echo_api/python/README.md index 9096a78c85de..1873ea15fbb4 100644 --- a/samples/client/echo_api/python/README.md +++ b/samples/client/echo_api/python/README.md @@ -98,6 +98,7 @@ Class | Method | HTTP request | Description *BodyApi* | [**test_binary_gif**](docs/BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body *BodyApi* | [**test_body_application_octetstream_binary**](docs/BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) *BodyApi* | [**test_body_multipart_formdata_array_of_binary**](docs/BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*BodyApi* | [**test_echo_body_all_of_pet**](docs/BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) *BodyApi* | [**test_echo_body_free_form_object_response_string**](docs/BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object *BodyApi* | [**test_echo_body_pet**](docs/BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) *BodyApi* | [**test_echo_body_pet_response_string**](docs/BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body diff --git a/samples/client/echo_api/python/docs/BodyApi.md b/samples/client/echo_api/python/docs/BodyApi.md index 553100ffc922..cd65141a98fc 100644 --- a/samples/client/echo_api/python/docs/BodyApi.md +++ b/samples/client/echo_api/python/docs/BodyApi.md @@ -7,6 +7,7 @@ Method | HTTP request | Description [**test_binary_gif**](BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body [**test_body_application_octetstream_binary**](BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) [**test_body_multipart_formdata_array_of_binary**](BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +[**test_echo_body_all_of_pet**](BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) [**test_echo_body_free_form_object_response_string**](BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object [**test_echo_body_pet**](BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) [**test_echo_body_pet_response_string**](BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body @@ -207,6 +208,73 @@ No authorization required [[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) +# **test_echo_body_all_of_pet** +> Pet test_echo_body_all_of_pet(pet=pet) + +Test body parameter(s) + +Test body parameter(s) + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.pet import Pet +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost:3000 +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost:3000" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.BodyApi(api_client) + pet = openapi_client.Pet() # Pet | Pet object that needs to be added to the store (optional) + + try: + # Test body parameter(s) + api_response = api_instance.test_echo_body_all_of_pet(pet=pet) + print("The response of BodyApi->test_echo_body_all_of_pet:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling BodyApi->test_echo_body_all_of_pet: %s\n" % e) +``` + + + +### 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 | - | + +[[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) + # **test_echo_body_free_form_object_response_string** > str test_echo_body_free_form_object_response_string(body=body) diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index c9ef69733890..e84a432c4368 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -851,6 +851,280 @@ def _test_body_multipart_formdata_array_of_binary_serialize( + @validate_call + def test_echo_body_all_of_pet( + self, + pet: Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Pet: + """Test body parameter(s) + + Test body parameter(s) + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_echo_body_all_of_pet_serialize( + pet=pet, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Pet" + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def test_echo_body_all_of_pet_with_http_info( + self, + pet: Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Pet]: + """Test body parameter(s) + + Test body parameter(s) + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_echo_body_all_of_pet_serialize( + pet=pet, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Pet" + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def test_echo_body_all_of_pet_without_preload_content( + self, + pet: Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Test body parameter(s) + + Test body parameter(s) + + :param pet: Pet object that needs to be added to the store + :type pet: Pet + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_echo_body_all_of_pet_serialize( + pet=pet, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Pet" + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_echo_body_all_of_pet_serialize( + self, + pet, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if pet is not None: + _body_params = pet + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/echo/body/allOf/Pet', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def test_echo_body_free_form_object_response_string( self, diff --git a/samples/client/echo_api/ruby-httpx/README.md b/samples/client/echo_api/ruby-httpx/README.md index b5f01671a665..809a4331ef3d 100644 --- a/samples/client/echo_api/ruby-httpx/README.md +++ b/samples/client/echo_api/ruby-httpx/README.md @@ -87,6 +87,7 @@ Class | Method | HTTP request | Description *OpenapiClient::BodyApi* | [**test_binary_gif**](docs/BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body *OpenapiClient::BodyApi* | [**test_body_application_octetstream_binary**](docs/BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) *OpenapiClient::BodyApi* | [**test_body_multipart_formdata_array_of_binary**](docs/BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*OpenapiClient::BodyApi* | [**test_echo_body_all_of_pet**](docs/BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) *OpenapiClient::BodyApi* | [**test_echo_body_free_form_object_response_string**](docs/BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object *OpenapiClient::BodyApi* | [**test_echo_body_pet**](docs/BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) *OpenapiClient::BodyApi* | [**test_echo_body_pet_response_string**](docs/BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body diff --git a/samples/client/echo_api/ruby-httpx/docs/BodyApi.md b/samples/client/echo_api/ruby-httpx/docs/BodyApi.md index 89a5d10159a0..e8b37e1fd54d 100644 --- a/samples/client/echo_api/ruby-httpx/docs/BodyApi.md +++ b/samples/client/echo_api/ruby-httpx/docs/BodyApi.md @@ -7,6 +7,7 @@ All URIs are relative to *http://localhost:3000* | [**test_binary_gif**](BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body | | [**test_body_application_octetstream_binary**](BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s) | | [**test_body_multipart_formdata_array_of_binary**](BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime | +| [**test_echo_body_all_of_pet**](BodyApi.md#test_echo_body_all_of_pet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) | | [**test_echo_body_free_form_object_response_string**](BodyApi.md#test_echo_body_free_form_object_response_string) | **POST** /echo/body/FreeFormObject/response_string | Test free form object | | [**test_echo_body_pet**](BodyApi.md#test_echo_body_pet) | **POST** /echo/body/Pet | Test body parameter(s) | | [**test_echo_body_pet_response_string**](BodyApi.md#test_echo_body_pet_response_string) | **POST** /echo/body/Pet/response_string | Test empty response body | @@ -204,6 +205,72 @@ No authorization required - **Accept**: text/plain +## test_echo_body_all_of_pet + +> test_echo_body_all_of_pet(opts) + +Test body parameter(s) + +Test body parameter(s) + +### Examples + +```ruby +require 'time' +require 'openapi_client' + +api_instance = OpenapiClient::BodyApi.new +opts = { + pet: OpenapiClient::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']}) # Pet | Pet object that needs to be added to the store +} + +begin + # Test body parameter(s) + result = api_instance.test_echo_body_all_of_pet(opts) + p result +rescue OpenapiClient::ApiError => e + puts "Error when calling BodyApi->test_echo_body_all_of_pet: #{e}" +end +``` + +#### Using the test_echo_body_all_of_pet_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> test_echo_body_all_of_pet_with_http_info(opts) + +```ruby +begin + # Test body parameter(s) + data, status_code, headers = api_instance.test_echo_body_all_of_pet_with_http_info(opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue OpenapiClient::ApiError => e + puts "Error when calling BodyApi->test_echo_body_all_of_pet_with_http_info: #{e}" +end +``` + +### 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 + + ## test_echo_body_free_form_object_response_string > String test_echo_body_free_form_object_response_string(opts) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/api/body_api.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/api/body_api.rb index 1a9970d95a3e..cad639a8145a 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/api/body_api.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/api/body_api.rb @@ -209,6 +209,70 @@ def test_body_multipart_formdata_array_of_binary_with_http_info(files, opts = {} return data, status_code, headers end + # Test body parameter(s) + # Test body parameter(s) + # @param [Hash] opts the optional parameters + # @option opts [Pet] :pet Pet object that needs to be added to the store + # @return [Pet] + def test_echo_body_all_of_pet(opts = {}) + data, _status_code, _headers = test_echo_body_all_of_pet_with_http_info(opts) + data + end + + # Test body parameter(s) + # Test body parameter(s) + # @param [Hash] opts the optional parameters + # @option opts [Pet] :pet Pet object that needs to be added to the store + # @return [Array<(Pet, Integer, Hash)>] Pet data, response status code and response headers + def test_echo_body_all_of_pet_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: BodyApi.test_echo_body_all_of_pet ...' + end + # resource path + local_var_path = '/echo/body/allOf/Pet' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'pet']) + + # return_type + return_type = opts[:debug_return_type] || 'Pet' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"BodyApi.test_echo_body_all_of_pet", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: BodyApi#test_echo_body_all_of_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Test free form object # Test free form object # @param [Hash] opts the optional parameters diff --git a/samples/client/echo_api/typescript-axios/build/api.ts b/samples/client/echo_api/typescript-axios/build/api.ts index 25207b6f5903..26516836aca4 100644 --- a/samples/client/echo_api/typescript-axios/build/api.ts +++ b/samples/client/echo_api/typescript-axios/build/api.ts @@ -554,6 +554,40 @@ export const BodyApiAxiosParamCreator = function (configuration?: Configuration) options: localVarRequestOptions, }; }, + /** + * Test body parameter(s) + * @summary Test body parameter(s) + * @param {Pet} [pet] Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testEchoBodyAllOfPet: async (pet?: Pet, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/echo/body/allOf/Pet`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(pet, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * Test free form object * @summary Test free form object @@ -738,6 +772,19 @@ export const BodyApiFp = function(configuration?: Configuration) { const operationBasePath = operationServerMap['BodyApi.testBodyMultipartFormdataArrayOfBinary']?.[index]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, + /** + * Test body parameter(s) + * @summary Test body parameter(s) + * @param {Pet} [pet] Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testEchoBodyAllOfPet(pet?: Pet, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testEchoBodyAllOfPet(pet, options); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['BodyApi.testEchoBodyAllOfPet']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); + }, /** * Test free form object * @summary Test free form object @@ -829,6 +876,16 @@ export const BodyApiFactory = function (configuration?: Configuration, basePath? testBodyMultipartFormdataArrayOfBinary(files: Array, options?: any): AxiosPromise { return localVarFp.testBodyMultipartFormdataArrayOfBinary(files, options).then((request) => request(axios, basePath)); }, + /** + * Test body parameter(s) + * @summary Test body parameter(s) + * @param {Pet} [pet] Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testEchoBodyAllOfPet(pet?: Pet, options?: any): AxiosPromise { + return localVarFp.testEchoBodyAllOfPet(pet, options).then((request) => request(axios, basePath)); + }, /** * Test free form object * @summary Test free form object @@ -914,6 +971,18 @@ export class BodyApi extends BaseAPI { return BodyApiFp(this.configuration).testBodyMultipartFormdataArrayOfBinary(files, options).then((request) => request(this.axios, this.basePath)); } + /** + * Test body parameter(s) + * @summary Test body parameter(s) + * @param {Pet} [pet] Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BodyApi + */ + public testEchoBodyAllOfPet(pet?: Pet, options?: AxiosRequestConfig) { + return BodyApiFp(this.configuration).testEchoBodyAllOfPet(pet, options).then((request) => request(this.axios, this.basePath)); + } + /** * Test free form object * @summary Test free form object