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 b129475e387..534ababda74 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 @@ -83,6 +83,40 @@ paths: text/plain: schema: type: string + # form parameter tests for oneOf schema + /form/oneof: + post: + tags: + - form + summary: Test form parameter(s) for oneOf schema + description: Test form parameter(s) for oneOf schema + operationId: test/form/oneof + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + oneOf: + - type: object + properties: + form1: + type: string + form2: + type: integer + - type: object + properties: + form3: + type: string + form4: + type: boolean + - $ref: '#/components/schemas/Tag' + responses: + '200': + description: Successful operation + content: + text/plain: + schema: + type: string # header parameter tests /header/integer/boolean/string: get: diff --git a/samples/client/echo_api/csharp-restsharp/README.md b/samples/client/echo_api/csharp-restsharp/README.md index 76892df3a7e..c5d5fff5f0b 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* | [**TestEchoBodyPetResponseString**](docs/BodyApi.md#testechobodypetresponsestring) | **POST** /echo/body/Pet/response_string | Test empty response body *BodyApi* | [**TestEchoBodyTagResponseString**](docs/BodyApi.md#testechobodytagresponsestring) | **POST** /echo/body/Tag/response_string | Test empty json (request body) *FormApi* | [**TestFormIntegerBooleanString**](docs/FormApi.md#testformintegerbooleanstring) | **POST** /form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**TestFormOneof**](docs/FormApi.md#testformoneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema *HeaderApi* | [**TestHeaderIntegerBooleanString**](docs/HeaderApi.md#testheaderintegerbooleanstring) | **GET** /header/integer/boolean/string | Test header parameter(s) *PathApi* | [**TestsPathStringPathStringIntegerPathInteger**](docs/PathApi.md#testspathstringpathstringintegerpathinteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s) *QueryApi* | [**TestEnumRefString**](docs/QueryApi.md#testenumrefstring) | **GET** /query/enum_ref_string | Test query parameter(s) diff --git a/samples/client/echo_api/csharp-restsharp/api/openapi.yaml b/samples/client/echo_api/csharp-restsharp/api/openapi.yaml index e48005e9652..9699db191cd 100644 --- a/samples/client/echo_api/csharp-restsharp/api/openapi.yaml +++ b/samples/client/echo_api/csharp-restsharp/api/openapi.yaml @@ -59,6 +59,25 @@ paths: summary: Test form parameter(s) tags: - form + /form/oneof: + post: + description: Test form parameter(s) for oneOf schema + operationId: test/form/oneof + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/test_form_oneof_request' + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test form parameter(s) for oneOf schema + tags: + - form /header/integer/boolean/string: get: description: Test header parameter(s) @@ -642,6 +661,26 @@ components: string_form: type: string type: object + test_form_oneof_request_oneOf: + properties: + form1: + type: string + form2: + type: integer + type: object + test_form_oneof_request_oneOf_1: + properties: + form3: + type: string + form4: + type: boolean + type: object + test_form_oneof_request: + oneOf: + - $ref: '#/components/schemas/test_form_oneof_request_oneOf' + - $ref: '#/components/schemas/test_form_oneof_request_oneOf_1' + - $ref: '#/components/schemas/Tag' + type: object test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: diff --git a/samples/client/echo_api/csharp-restsharp/docs/FormApi.md b/samples/client/echo_api/csharp-restsharp/docs/FormApi.md index 3783717ed31..2e133fd42fb 100644 --- a/samples/client/echo_api/csharp-restsharp/docs/FormApi.md +++ b/samples/client/echo_api/csharp-restsharp/docs/FormApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://localhost:3000* | Method | HTTP request | Description | |--------|--------------|-------------| | [**TestFormIntegerBooleanString**](FormApi.md#testformintegerbooleanstring) | **POST** /form/integer/boolean/string | Test form parameter(s) | +| [**TestFormOneof**](FormApi.md#testformoneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema | # **TestFormIntegerBooleanString** @@ -101,3 +102,104 @@ 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) + +# **TestFormOneof** +> string TestFormOneof (string? form1 = null, int? form2 = null, string? form3 = null, bool? form4 = null, long? id = null, string? name = null) + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### 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 TestFormOneofExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://localhost:3000"; + var apiInstance = new FormApi(config); + var form1 = "form1_example"; // string? | (optional) + var form2 = 56; // int? | (optional) + var form3 = "form3_example"; // string? | (optional) + var form4 = true; // bool? | (optional) + var id = 789L; // long? | (optional) + var name = "name_example"; // string? | (optional) + + try + { + // Test form parameter(s) for oneOf schema + string result = apiInstance.TestFormOneof(form1, form2, form3, form4, id, name); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FormApi.TestFormOneof: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestFormOneofWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test form parameter(s) for oneOf schema + ApiResponse response = apiInstance.TestFormOneofWithHttpInfo(form1, form2, form3, form4, id, name); + 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 FormApi.TestFormOneofWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **form1** | **string?** | | [optional] | +| **form2** | **int?** | | [optional] | +| **form3** | **string?** | | [optional] | +| **form4** | **bool?** | | [optional] | +| **id** | **long?** | | [optional] | +| **name** | **string?** | | [optional] | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **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) + diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/FormApi.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/FormApi.cs index e6c47761094..b0ead55b2d1 100644 --- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/FormApi.cs +++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/FormApi.cs @@ -53,6 +53,39 @@ namespace Org.OpenAPITools.Api /// Index associated with the operation. /// ApiResponse of string ApiResponse TestFormIntegerBooleanStringWithHttpInfo(int? integerForm = default(int?), bool? booleanForm = default(bool?), string? stringForm = default(string?), int operationIndex = 0); + /// + /// Test form parameter(s) for oneOf schema + /// + /// + /// Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// string + string TestFormOneof(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), int operationIndex = 0); + + /// + /// Test form parameter(s) for oneOf schema + /// + /// + /// Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// ApiResponse of string + ApiResponse TestFormOneofWithHttpInfo(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), int operationIndex = 0); #endregion Synchronous Operations } @@ -91,6 +124,41 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (string) System.Threading.Tasks.Task> TestFormIntegerBooleanStringWithHttpInfoAsync(int? integerForm = default(int?), bool? booleanForm = default(bool?), string? stringForm = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test form parameter(s) for oneOf schema + /// + /// + /// Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of string + System.Threading.Tasks.Task TestFormOneofAsync(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test form parameter(s) for oneOf schema + /// + /// + /// Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (string) + System.Threading.Tasks.Task> TestFormOneofWithHttpInfoAsync(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -375,5 +443,205 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// Test form parameter(s) for oneOf schema Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// string + public string TestFormOneof(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = TestFormOneofWithHttpInfo(form1, form2, form3, form4, id, name); + return localVarResponse.Data; + } + + /// + /// Test form parameter(s) for oneOf schema Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// ApiResponse of string + public Org.OpenAPITools.Client.ApiResponse TestFormOneofWithHttpInfo(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "text/plain" + }; + + 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); + } + + if (form1 != null) + { + localVarRequestOptions.FormParameters.Add("form1", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form1)); // form parameter + } + if (form2 != null) + { + localVarRequestOptions.FormParameters.Add("form2", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form2)); // form parameter + } + if (form3 != null) + { + localVarRequestOptions.FormParameters.Add("form3", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form3)); // form parameter + } + if (form4 != null) + { + localVarRequestOptions.FormParameters.Add("form4", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form4)); // form parameter + } + if (id != null) + { + localVarRequestOptions.FormParameters.Add("id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(id)); // form parameter + } + if (name != null) + { + localVarRequestOptions.FormParameters.Add("name", Org.OpenAPITools.Client.ClientUtils.ParameterToString(name)); // form parameter + } + + localVarRequestOptions.Operation = "FormApi.TestFormOneof"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/form/oneof", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("TestFormOneof", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test form parameter(s) for oneOf schema Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of string + public async System.Threading.Tasks.Task TestFormOneofAsync(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await TestFormOneofWithHttpInfoAsync(form1, form2, form3, form4, id, name, operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test form parameter(s) for oneOf schema Test form parameter(s) for oneOf schema + /// + /// Thrown when fails to make API call + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// (optional) + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (string) + public async System.Threading.Tasks.Task> TestFormOneofWithHttpInfoAsync(string? form1 = default(string?), int? form2 = default(int?), string? form3 = default(string?), bool? form4 = default(bool?), long? id = default(long?), string? name = default(string?), 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/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "text/plain" + }; + + 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); + } + + if (form1 != null) + { + localVarRequestOptions.FormParameters.Add("form1", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form1)); // form parameter + } + if (form2 != null) + { + localVarRequestOptions.FormParameters.Add("form2", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form2)); // form parameter + } + if (form3 != null) + { + localVarRequestOptions.FormParameters.Add("form3", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form3)); // form parameter + } + if (form4 != null) + { + localVarRequestOptions.FormParameters.Add("form4", Org.OpenAPITools.Client.ClientUtils.ParameterToString(form4)); // form parameter + } + if (id != null) + { + localVarRequestOptions.FormParameters.Add("id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(id)); // form parameter + } + if (name != null) + { + localVarRequestOptions.FormParameters.Add("name", Org.OpenAPITools.Client.ClientUtils.ParameterToString(name)); // form parameter + } + + localVarRequestOptions.Operation = "FormApi.TestFormOneof"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/form/oneof", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("TestFormOneof", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/echo_api/java/apache-httpclient/README.md b/samples/client/echo_api/java/apache-httpclient/README.md index ecf2a857f1d..b3d34287c2e 100644 --- a/samples/client/echo_api/java/apache-httpclient/README.md +++ b/samples/client/echo_api/java/apache-httpclient/README.md @@ -113,6 +113,7 @@ Class | Method | HTTP request | Description *BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body *BodyApi* | [**testEchoBodyTagResponseString**](docs/BodyApi.md#testEchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body) *FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**testFormOneof**](docs/FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema *HeaderApi* | [**testHeaderIntegerBooleanString**](docs/HeaderApi.md#testHeaderIntegerBooleanString) | **GET** /header/integer/boolean/string | Test header parameter(s) *PathApi* | [**testsPathStringPathStringIntegerPathInteger**](docs/PathApi.md#testsPathStringPathStringIntegerPathInteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s) *QueryApi* | [**testEnumRefString**](docs/QueryApi.md#testEnumRefString) | **GET** /query/enum_ref_string | Test query parameter(s) 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 d8196f68ed2..a32ee32bd49 100644 --- a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml +++ b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml @@ -62,6 +62,27 @@ paths: - form x-content-type: application/x-www-form-urlencoded x-accepts: text/plain + /form/oneof: + post: + description: Test form parameter(s) for oneOf schema + operationId: test/form/oneof + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/test_form_oneof_request' + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test form parameter(s) for oneOf schema + tags: + - form + x-content-type: application/x-www-form-urlencoded + x-accepts: text/plain /header/integer/boolean/string: get: description: Test header parameter(s) @@ -667,6 +688,26 @@ components: string_form: type: string type: object + test_form_oneof_request_oneOf: + properties: + form1: + type: string + form2: + type: integer + type: object + test_form_oneof_request_oneOf_1: + properties: + form3: + type: string + form4: + type: boolean + type: object + test_form_oneof_request: + oneOf: + - $ref: '#/components/schemas/test_form_oneof_request_oneOf' + - $ref: '#/components/schemas/test_form_oneof_request_oneOf_1' + - $ref: '#/components/schemas/Tag' + type: object test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: diff --git a/samples/client/echo_api/java/apache-httpclient/docs/FormApi.md b/samples/client/echo_api/java/apache-httpclient/docs/FormApi.md index b15d9c91253..1f3ad73e938 100644 --- a/samples/client/echo_api/java/apache-httpclient/docs/FormApi.md +++ b/samples/client/echo_api/java/apache-httpclient/docs/FormApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://localhost:3000* | Method | HTTP request | Description | |------------- | ------------- | -------------| | [**testFormIntegerBooleanString**](FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) | +| [**testFormOneof**](FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema | @@ -77,3 +78,79 @@ No authorization required |-------------|-------------|------------------| | **200** | Successful operation | - | + +## testFormOneof + +> String testFormOneof(form1, form2, form3, form4, id, name) + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### 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.FormApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + FormApi apiInstance = new FormApi(defaultClient); + String form1 = "form1_example"; // String | + Integer form2 = 56; // Integer | + String form3 = "form3_example"; // String | + Boolean form4 = true; // Boolean | + Long id = 56L; // Long | + String name = "name_example"; // String | + try { + String result = apiInstance.testFormOneof(form1, form2, form3, form4, id, name); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FormApi#testFormOneof"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **form1** | **String**| | [optional] | +| **form2** | **Integer**| | [optional] | +| **form3** | **String**| | [optional] | +| **form4** | **Boolean**| | [optional] | +| **id** | **Long**| | [optional] | +| **name** | **String**| | [optional] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: text/plain + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/FormApi.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/FormApi.java index 4d750a2cb29..e39b0b3e5e9 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/FormApi.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/FormApi.java @@ -129,4 +129,95 @@ if (stringForm != null) ); } + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return String + * @throws ApiException if fails to make API call + */ + public String testFormOneof(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException { + return this.testFormOneof(form1, form2, form3, form4, id, name, Collections.emptyMap()); + } + + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @param additionalHeaders additionalHeaders for this call + * @return String + * @throws ApiException if fails to make API call + */ + public String testFormOneof(String form1, Integer form2, String form3, Boolean form4, Long id, String name, Map additionalHeaders) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/form/oneof"; + + 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); + + + if (form1 != null) + localVarFormParams.put("form1", form1); +if (form2 != null) + localVarFormParams.put("form2", form2); +if (form3 != null) + localVarFormParams.put("form3", form3); +if (form4 != null) + localVarFormParams.put("form4", form4); +if (id != null) + localVarFormParams.put("id", id); +if (name != null) + localVarFormParams.put("name", name); + + final String[] localVarAccepts = { + "text/plain" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/x-www-form-urlencoded" + }; + 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 + ); + } + } 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 d8196f68ed2..a32ee32bd49 100644 --- a/samples/client/echo_api/java/feign-gson/api/openapi.yaml +++ b/samples/client/echo_api/java/feign-gson/api/openapi.yaml @@ -62,6 +62,27 @@ paths: - form x-content-type: application/x-www-form-urlencoded x-accepts: text/plain + /form/oneof: + post: + description: Test form parameter(s) for oneOf schema + operationId: test/form/oneof + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/test_form_oneof_request' + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test form parameter(s) for oneOf schema + tags: + - form + x-content-type: application/x-www-form-urlencoded + x-accepts: text/plain /header/integer/boolean/string: get: description: Test header parameter(s) @@ -667,6 +688,26 @@ components: string_form: type: string type: object + test_form_oneof_request_oneOf: + properties: + form1: + type: string + form2: + type: integer + type: object + test_form_oneof_request_oneOf_1: + properties: + form3: + type: string + form4: + type: boolean + type: object + test_form_oneof_request: + oneOf: + - $ref: '#/components/schemas/test_form_oneof_request_oneOf' + - $ref: '#/components/schemas/test_form_oneof_request_oneOf_1' + - $ref: '#/components/schemas/Tag' + type: object test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/FormApi.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/FormApi.java index abc282063ca..a65d74a127f 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/FormApi.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/FormApi.java @@ -47,4 +47,43 @@ public interface FormApi extends ApiClient.Api { ApiResponse testFormIntegerBooleanStringWithHttpInfo(@Param("integer_form") Integer integerForm, @Param("boolean_form") Boolean booleanForm, @Param("string_form") String stringForm); + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return String + */ + @RequestLine("POST /form/oneof") + @Headers({ + "Content-Type: application/x-www-form-urlencoded", + "Accept: text/plain", + }) + String testFormOneof(@Param("form1") String form1, @Param("form2") Integer form2, @Param("form3") String form3, @Param("form4") Boolean form4, @Param("id") Long id, @Param("name") String name); + + /** + * Test form parameter(s) for oneOf schema + * Similar to testFormOneof but it also returns the http response headers . + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return A ApiResponse that wraps the response boyd and the http headers. + */ + @RequestLine("POST /form/oneof") + @Headers({ + "Content-Type: application/x-www-form-urlencoded", + "Accept: text/plain", + }) + ApiResponse testFormOneofWithHttpInfo(@Param("form1") String form1, @Param("form2") Integer form2, @Param("form3") String form3, @Param("form4") Boolean form4, @Param("id") Long id, @Param("name") String name); + + } diff --git a/samples/client/echo_api/java/native/README.md b/samples/client/echo_api/java/native/README.md index 96b5104f7c7..1184f9f739c 100644 --- a/samples/client/echo_api/java/native/README.md +++ b/samples/client/echo_api/java/native/README.md @@ -120,6 +120,8 @@ Class | Method | HTTP request | Description *BodyApi* | [**testEchoBodyTagResponseStringWithHttpInfo**](docs/BodyApi.md#testEchoBodyTagResponseStringWithHttpInfo) | **POST** /echo/body/Tag/response_string | Test empty json (request body) *FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) *FormApi* | [**testFormIntegerBooleanStringWithHttpInfo**](docs/FormApi.md#testFormIntegerBooleanStringWithHttpInfo) | **POST** /form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**testFormOneof**](docs/FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema +*FormApi* | [**testFormOneofWithHttpInfo**](docs/FormApi.md#testFormOneofWithHttpInfo) | **POST** /form/oneof | Test form parameter(s) for oneOf schema *HeaderApi* | [**testHeaderIntegerBooleanString**](docs/HeaderApi.md#testHeaderIntegerBooleanString) | **GET** /header/integer/boolean/string | Test header parameter(s) *HeaderApi* | [**testHeaderIntegerBooleanStringWithHttpInfo**](docs/HeaderApi.md#testHeaderIntegerBooleanStringWithHttpInfo) | **GET** /header/integer/boolean/string | Test header parameter(s) *PathApi* | [**testsPathStringPathStringIntegerPathInteger**](docs/PathApi.md#testsPathStringPathStringIntegerPathInteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path 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 d8196f68ed2..a32ee32bd49 100644 --- a/samples/client/echo_api/java/native/api/openapi.yaml +++ b/samples/client/echo_api/java/native/api/openapi.yaml @@ -62,6 +62,27 @@ paths: - form x-content-type: application/x-www-form-urlencoded x-accepts: text/plain + /form/oneof: + post: + description: Test form parameter(s) for oneOf schema + operationId: test/form/oneof + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/test_form_oneof_request' + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test form parameter(s) for oneOf schema + tags: + - form + x-content-type: application/x-www-form-urlencoded + x-accepts: text/plain /header/integer/boolean/string: get: description: Test header parameter(s) @@ -667,6 +688,26 @@ components: string_form: type: string type: object + test_form_oneof_request_oneOf: + properties: + form1: + type: string + form2: + type: integer + type: object + test_form_oneof_request_oneOf_1: + properties: + form3: + type: string + form4: + type: boolean + type: object + test_form_oneof_request: + oneOf: + - $ref: '#/components/schemas/test_form_oneof_request_oneOf' + - $ref: '#/components/schemas/test_form_oneof_request_oneOf_1' + - $ref: '#/components/schemas/Tag' + type: object test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: diff --git a/samples/client/echo_api/java/native/docs/FormApi.md b/samples/client/echo_api/java/native/docs/FormApi.md index 973cfdd0f8f..435271bcedf 100644 --- a/samples/client/echo_api/java/native/docs/FormApi.md +++ b/samples/client/echo_api/java/native/docs/FormApi.md @@ -6,6 +6,8 @@ All URIs are relative to *http://localhost:3000* |------------- | ------------- | -------------| | [**testFormIntegerBooleanString**](FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) | | [**testFormIntegerBooleanStringWithHttpInfo**](FormApi.md#testFormIntegerBooleanStringWithHttpInfo) | **POST** /form/integer/boolean/string | Test form parameter(s) | +| [**testFormOneof**](FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema | +| [**testFormOneofWithHttpInfo**](FormApi.md#testFormOneofWithHttpInfo) | **POST** /form/oneof | Test form parameter(s) for oneOf schema | @@ -150,3 +152,157 @@ No authorization required |-------------|-------------|------------------| | **200** | Successful operation | - | + +## testFormOneof + +> String testFormOneof(form1, form2, form3, form4, id, name) + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### 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.FormApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + FormApi apiInstance = new FormApi(defaultClient); + String form1 = "form1_example"; // String | + Integer form2 = 56; // Integer | + String form3 = "form3_example"; // String | + Boolean form4 = true; // Boolean | + Long id = 56L; // Long | + String name = "name_example"; // String | + try { + String result = apiInstance.testFormOneof(form1, form2, form3, form4, id, name); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FormApi#testFormOneof"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **form1** | **String**| | [optional] | +| **form2** | **Integer**| | [optional] | +| **form3** | **String**| | [optional] | +| **form4** | **Boolean**| | [optional] | +| **id** | **Long**| | [optional] | +| **name** | **String**| | [optional] | + +### Return type + +**String** + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +## testFormOneofWithHttpInfo + +> ApiResponse testFormOneof testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name) + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### 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.FormApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + FormApi apiInstance = new FormApi(defaultClient); + String form1 = "form1_example"; // String | + Integer form2 = 56; // Integer | + String form3 = "form3_example"; // String | + Boolean form4 = true; // Boolean | + Long id = 56L; // Long | + String name = "name_example"; // String | + try { + ApiResponse response = apiInstance.testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name); + 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 FormApi#testFormOneof"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **form1** | **String**| | [optional] | +| **form2** | **Integer**| | [optional] | +| **form3** | **String**| | [optional] | +| **form4** | **Boolean**| | [optional] | +| **id** | **Long**| | [optional] | +| **name** | **String**| | [optional] | + +### Return type + +ApiResponse<**String**> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java index c6e033ec70b..44de90891dd 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java @@ -185,4 +185,118 @@ public class FormApi { } return localVarRequestBuilder; } + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return String + * @throws ApiException if fails to make API call + */ + public String testFormOneof(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException { + ApiResponse localVarResponse = testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name); + return localVarResponse.getData(); + } + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testFormOneofWithHttpInfo(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testFormOneofRequestBuilder(form1, form2, form3, form4, id, name); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("testFormOneof", localVarResponse); + } + // for plain text response + if (localVarResponse.headers().map().containsKey("Content-Type") && + "text/plain".equalsIgnoreCase(localVarResponse.headers().map().get("Content-Type").get(0).split(";")[0].trim())) { + java.util.Scanner s = new java.util.Scanner(localVarResponse.body()).useDelimiter("\\A"); + String responseBodyText = s.hasNext() ? s.next() : ""; + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBodyText + ); + } else { + throw new RuntimeException("Error! The response Content-Type is supposed to be `text/plain` but it's not: " + localVarResponse); + } + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder testFormOneofRequestBuilder(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/form/oneof"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "text/plain"); + + List formValues = new ArrayList<>(); + if (form1 != null) { + formValues.add(new BasicNameValuePair("form1", form1.toString())); + } + if (form2 != null) { + formValues.add(new BasicNameValuePair("form2", form2.toString())); + } + if (form3 != null) { + formValues.add(new BasicNameValuePair("form3", form3.toString())); + } + if (form4 != null) { + formValues.add(new BasicNameValuePair("form4", form4.toString())); + } + if (id != null) { + formValues.add(new BasicNameValuePair("id", id.toString())); + } + if (name != null) { + formValues.add(new BasicNameValuePair("name", name.toString())); + } + HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8); + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()))); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } } 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 dc4eba6e001..92c7966b05c 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 @@ -284,6 +284,18 @@ public class CustomTest { Assert.assertEquals("3b\ninteger_form=1337&boolean_form=true&string_form=Hello+World\n0\n\n", p.body); } + @Test + public void testFormOneOf() throws ApiException { + String form1 = "form1_example"; // String | + Integer form2 = 56; // Integer | + String form3 = "form3 example"; // String | + Boolean form4 = true; + String response = formApi.testFormOneof(form1, form2, form3, form4, null, null); + org.openapitools.client.EchoServerResponseParser p = new org.openapitools.client.EchoServerResponseParser(response); + Assert.assertEquals("/form/oneof", p.path); + Assert.assertEquals("3c\nform1=form1_example&form2=56&form3=form3++example&form4=true\n0\n\n", p.body); + } + @Test public void testBodyMultipartFormdataArrayOfBinary() throws ApiException { File file1 = Objects.requireNonNull(getFile("Hello")); diff --git a/samples/client/echo_api/java/okhttp-gson/README.md b/samples/client/echo_api/java/okhttp-gson/README.md index ed2dc844e46..5d9b02479ce 100644 --- a/samples/client/echo_api/java/okhttp-gson/README.md +++ b/samples/client/echo_api/java/okhttp-gson/README.md @@ -120,6 +120,7 @@ Class | Method | HTTP request | Description *BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body *BodyApi* | [**testEchoBodyTagResponseString**](docs/BodyApi.md#testEchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body) *FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**testFormOneof**](docs/FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema *HeaderApi* | [**testHeaderIntegerBooleanString**](docs/HeaderApi.md#testHeaderIntegerBooleanString) | **GET** /header/integer/boolean/string | Test header parameter(s) *PathApi* | [**testsPathStringPathStringIntegerPathInteger**](docs/PathApi.md#testsPathStringPathStringIntegerPathInteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s) *QueryApi* | [**testEnumRefString**](docs/QueryApi.md#testEnumRefString) | **GET** /query/enum_ref_string | Test query parameter(s) 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 d8196f68ed2..a32ee32bd49 100644 --- a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml +++ b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml @@ -62,6 +62,27 @@ paths: - form x-content-type: application/x-www-form-urlencoded x-accepts: text/plain + /form/oneof: + post: + description: Test form parameter(s) for oneOf schema + operationId: test/form/oneof + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/test_form_oneof_request' + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test form parameter(s) for oneOf schema + tags: + - form + x-content-type: application/x-www-form-urlencoded + x-accepts: text/plain /header/integer/boolean/string: get: description: Test header parameter(s) @@ -667,6 +688,26 @@ components: string_form: type: string type: object + test_form_oneof_request_oneOf: + properties: + form1: + type: string + form2: + type: integer + type: object + test_form_oneof_request_oneOf_1: + properties: + form3: + type: string + form4: + type: boolean + type: object + test_form_oneof_request: + oneOf: + - $ref: '#/components/schemas/test_form_oneof_request_oneOf' + - $ref: '#/components/schemas/test_form_oneof_request_oneOf_1' + - $ref: '#/components/schemas/Tag' + type: object test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: diff --git a/samples/client/echo_api/java/okhttp-gson/docs/FormApi.md b/samples/client/echo_api/java/okhttp-gson/docs/FormApi.md index 2d2e11673a8..4bb3395781a 100644 --- a/samples/client/echo_api/java/okhttp-gson/docs/FormApi.md +++ b/samples/client/echo_api/java/okhttp-gson/docs/FormApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://localhost:3000* | Method | HTTP request | Description | |------------- | ------------- | -------------| | [**testFormIntegerBooleanString**](FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) | +| [**testFormOneof**](FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema | @@ -73,3 +74,75 @@ No authorization required |-------------|-------------|------------------| | **200** | Successful operation | - | + +# **testFormOneof** +> String testFormOneof(form1, form2, form3, form4, id, name) + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### 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.FormApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + FormApi apiInstance = new FormApi(defaultClient); + String form1 = "form1_example"; // String | + Integer form2 = 56; // Integer | + String form3 = "form3_example"; // String | + Boolean form4 = true; // Boolean | + Long id = 56L; // Long | + String name = "name_example"; // String | + try { + String result = apiInstance.testFormOneof(form1, form2, form3, form4, id, name); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FormApi#testFormOneof"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **form1** | **String**| | [optional] | +| **form2** | **Integer**| | [optional] | +| **form3** | **String**| | [optional] | +| **form4** | **Boolean**| | [optional] | +| **id** | **Long**| | [optional] | +| **name** | **String**| | [optional] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/FormApi.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/FormApi.java index d0d03d4028a..c8672dc2b18 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/FormApi.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/FormApi.java @@ -209,4 +209,166 @@ public class FormApi { localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for testFormOneof + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (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 testFormOneofCall(String form1, Integer form2, String form3, Boolean form4, Long id, String name, 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 = null; + + // create path and map variables + String localVarPath = "/form/oneof"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (form1 != null) { + localVarFormParams.put("form1", form1); + } + + if (form2 != null) { + localVarFormParams.put("form2", form2); + } + + if (form3 != null) { + localVarFormParams.put("form3", form3); + } + + if (form4 != null) { + localVarFormParams.put("form4", form4); + } + + if (id != null) { + localVarFormParams.put("id", id); + } + + if (name != null) { + localVarFormParams.put("name", name); + } + + final String[] localVarAccepts = { + "text/plain" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/x-www-form-urlencoded" + }; + 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 testFormOneofValidateBeforeCall(String form1, Integer form2, String form3, Boolean form4, Long id, String name, final ApiCallback _callback) throws ApiException { + return testFormOneofCall(form1, form2, form3, form4, id, name, _callback); + + } + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return String + * @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 String testFormOneof(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException { + ApiResponse localVarResp = testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name); + return localVarResp.getData(); + } + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return ApiResponse<String> + * @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 testFormOneofWithHttpInfo(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException { + okhttp3.Call localVarCall = testFormOneofValidateBeforeCall(form1, form2, form3, form4, id, name, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Test form parameter(s) for oneOf schema (asynchronously) + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (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 testFormOneofAsync(String form1, Integer form2, String form3, Boolean form4, Long id, String name, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = testFormOneofValidateBeforeCall(form1, form2, form3, form4, id, name, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } } diff --git a/samples/client/echo_api/python/README.md b/samples/client/echo_api/python/README.md index a6e39b465b1..39f8162aecb 100644 --- a/samples/client/echo_api/python/README.md +++ b/samples/client/echo_api/python/README.md @@ -92,6 +92,7 @@ Class | Method | HTTP request | Description *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 *BodyApi* | [**test_echo_body_tag_response_string**](docs/BodyApi.md#test_echo_body_tag_response_string) | **POST** /echo/body/Tag/response_string | Test empty json (request body) *FormApi* | [**test_form_integer_boolean_string**](docs/FormApi.md#test_form_integer_boolean_string) | **POST** /form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**test_form_oneof**](docs/FormApi.md#test_form_oneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema *HeaderApi* | [**test_header_integer_boolean_string**](docs/HeaderApi.md#test_header_integer_boolean_string) | **GET** /header/integer/boolean/string | Test header parameter(s) *PathApi* | [**tests_path_string_path_string_integer_path_integer**](docs/PathApi.md#tests_path_string_path_string_integer_path_integer) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s) *QueryApi* | [**test_enum_ref_string**](docs/QueryApi.md#test_enum_ref_string) | **GET** /query/enum_ref_string | Test query parameter(s) diff --git a/samples/client/echo_api/python/docs/FormApi.md b/samples/client/echo_api/python/docs/FormApi.md index 9d5eabf9cbf..c823e4b82ae 100644 --- a/samples/client/echo_api/python/docs/FormApi.md +++ b/samples/client/echo_api/python/docs/FormApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://localhost:3000* Method | HTTP request | Description ------------- | ------------- | ------------- [**test_form_integer_boolean_string**](FormApi.md#test_form_integer_boolean_string) | **POST** /form/integer/boolean/string | Test form parameter(s) +[**test_form_oneof**](FormApi.md#test_form_oneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema # **test_form_integer_boolean_string** @@ -77,3 +78,79 @@ 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_form_oneof** +> str test_form_oneof(form1=form1, form2=form2, form3=form3, form4=form4, id=id, name=name) + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### Example + +```python +import time +import os +import openapi_client +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.FormApi(api_client) + form1 = 'form1_example' # str | (optional) + form2 = 56 # int | (optional) + form3 = 'form3_example' # str | (optional) + form4 = True # bool | (optional) + id = 56 # int | (optional) + name = 'name_example' # str | (optional) + + try: + # Test form parameter(s) for oneOf schema + api_response = api_instance.test_form_oneof(form1=form1, form2=form2, form3=form3, form4=form4, id=id, name=name) + print("The response of FormApi->test_form_oneof:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FormApi->test_form_oneof: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **form1** | **str**| | [optional] + **form2** | **int**| | [optional] + **form3** | **str**| | [optional] + **form4** | **bool**| | [optional] + **id** | **int**| | [optional] + **name** | **str**| | [optional] + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **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) + diff --git a/samples/client/echo_api/python/openapi_client/api/form_api.py b/samples/client/echo_api/python/openapi_client/api/form_api.py index 1137bfca321..808dd48ffa2 100644 --- a/samples/client/echo_api/python/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python/openapi_client/api/form_api.py @@ -207,3 +207,190 @@ class FormApi: _request_timeout=_params.get('_request_timeout'), collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + + @validate_arguments + def test_form_oneof(self, form1 : Optional[StrictStr] = None, form2 : Optional[StrictInt] = None, form3 : Optional[StrictStr] = None, form4 : Optional[StrictBool] = None, id : Optional[StrictInt] = None, name : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501 + """Test form parameter(s) for oneOf schema # noqa: E501 + + Test form parameter(s) for oneOf schema # 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_form_oneof(form1, form2, form3, form4, id, name, async_req=True) + >>> result = thread.get() + + :param form1: + :type form1: str + :param form2: + :type form2: int + :param form3: + :type form3: str + :param form4: + :type form4: bool + :param id: + :type id: int + :param name: + :type name: str + :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: str + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_form_oneof_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_form_oneof_with_http_info(form1, form2, form3, form4, id, name, **kwargs) # noqa: E501 + + @validate_arguments + def test_form_oneof_with_http_info(self, form1 : Optional[StrictStr] = None, form2 : Optional[StrictInt] = None, form3 : Optional[StrictStr] = None, form4 : Optional[StrictBool] = None, id : Optional[StrictInt] = None, name : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Test form parameter(s) for oneOf schema # noqa: E501 + + Test form parameter(s) for oneOf schema # 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_form_oneof_with_http_info(form1, form2, form3, form4, id, name, async_req=True) + >>> result = thread.get() + + :param form1: + :type form1: str + :param form2: + :type form2: int + :param form3: + :type form3: str + :param form4: + :type form4: bool + :param id: + :type id: int + :param name: + :type name: str + :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(str, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'form1', + 'form2', + 'form3', + 'form4', + 'id', + 'name' + ] + _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_form_oneof" % _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 = {} + if _params['form1']: + _form_params.append(('form1', _params['form1'])) + + if _params['form2']: + _form_params.append(('form2', _params['form2'])) + + if _params['form3']: + _form_params.append(('form3', _params['form3'])) + + if _params['form4']: + _form_params.append(('form4', _params['form4'])) + + if _params['id']: + _form_params.append(('id', _params['id'])) + + if _params['name']: + _form_params.append(('name', _params['name'])) + + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['text/plain']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/x-www-form-urlencoded'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "str", + } + + return self.api_client.call_api( + '/form/oneof', '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'))