From f7b93ebdf2063c853b6e9438e560c5a81a78bc98 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Sat, 29 May 2021 04:26:01 +0200 Subject: [PATCH] Update fake API to contain sample with binary body (#9610) --- ...ith-fake-endpoints-models-for-testing.yaml | 21 +- .../petstore/csharp/OpenAPIClient/README.md | 1 + .../csharp/OpenAPIClient/docs/FakeApi.md | 77 ++++++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 207 ++++++++++++++++- .../elixir/lib/openapi_petstore/api/fake.ex | 28 ++- .../client/petstore/javascript-es6/README.md | 1 + .../petstore/javascript-es6/docs/FakeApi.md | 48 +++- .../javascript-es6/src/api/FakeApi.js | 42 +++- .../petstore/javascript-promise-es6/README.md | 1 + .../javascript-promise-es6/docs/FakeApi.md | 47 +++- .../javascript-promise-es6/src/api/FakeApi.js | 49 +++- samples/client/petstore/perl/README.md | 1 + samples/client/petstore/perl/docs/FakeApi.md | 48 +++- .../perl/lib/WWW/OpenAPIClient/FakeApi.pm | 56 +++++ .../petstore/php/OpenAPIClient-php/README.md | 1 + .../php/OpenAPIClient-php/docs/Api/FakeApi.md | 58 ++++- .../php/OpenAPIClient-php/lib/Api/FakeApi.php | 209 ++++++++++++++++++ .../client/petstore/ruby-faraday/README.md | 1 + .../petstore/ruby-faraday/docs/FakeApi.md | 66 +++++- .../ruby-faraday/lib/petstore/api/fake_api.rb | 61 ++++- samples/client/petstore/ruby/README.md | 1 + samples/client/petstore/ruby/docs/FakeApi.md | 66 +++++- .../ruby/lib/petstore/api/fake_api.rb | 61 ++++- .../builds/default-v3.0/apis/FakeApi.ts | 40 +++- .../petstore_client_lib_fake/README.md | 1 + .../petstore_client_lib_fake/doc/FakeApi.md | 45 +++- .../lib/src/api/fake_api.dart | 72 +++++- .../petstore_client_lib_fake/README.md | 1 + .../petstore_client_lib_fake/doc/FakeApi.md | 45 +++- .../lib/api/fake_api.dart | 44 +++- .../dart2/petstore_client_lib_fake/README.md | 1 + .../petstore_client_lib_fake/doc/FakeApi.md | 45 +++- .../lib/api/fake_api.dart | 56 ++++- .../README.md | 1 + .../doc/FakeApi.md | 45 +++- .../lib/api/fake_api.dart | 56 ++++- .../client/petstore/python-legacy/README.md | 1 + .../petstore/python-legacy/docs/FakeApi.md | 63 +++++- .../petstore_api/api/fake_api.py | 133 ++++++++++- .../java/org/openapitools/api/FakeApi.java | 14 +- .../org/openapitools/api/FakeApiService.java | 1 + .../api/impl/FakeApiServiceImpl.java | 5 + .../app/Http/Controllers/FakeController.php | 24 ++ .../petstore/php-laravel/lib/routes/api.php | 9 +- .../lib/app/Http/Controllers/FakeApi.php | 24 ++ .../petstore/php-lumen/lib/routes/web.php | 9 +- 46 files changed, 1844 insertions(+), 42 deletions(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml index 431dd54b031..05b9fd5f542 100644 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1008,7 +1008,7 @@ paths: tags: - fake description: >- - For this test, the body for this request much reference a schema named + For this test, the body for this request must reference a schema named `File`. operationId: testBodyWithFileSchema responses: @@ -1020,6 +1020,25 @@ paths: schema: $ref: '#/components/schemas/FileSchemaTestClass' required: true + /fake/body-with-binary: + put: + tags: + - fake + description: >- + For this test, the body has to be a binary file. + operationId: testBodyWithBinary + responses: + '200': + description: Success + requestBody: + content: + image/png: + schema: + type: string + nullable: true + format: binary + description: image to upload + required: true /fake/test-query-paramters: put: tags: diff --git a/samples/client/petstore/csharp/OpenAPIClient/README.md b/samples/client/petstore/csharp/OpenAPIClient/README.md index f33c01b2a43..0174c279b8d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient/README.md @@ -114,6 +114,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**FakePropertyEnumIntegerSerialize**](docs/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**TestBodyWithBinary**](docs/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md b/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md index 64474672ca8..b821e3f31c1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | [**FakePropertyEnumIntegerSerialize**](FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +[**TestBodyWithBinary**](FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | [**TestClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model @@ -546,13 +547,87 @@ No authorization required [[Back to README]](../README.md) +## TestBodyWithBinary + +> void TestBodyWithBinary (System.IO.Stream body) + + + +For this test, the body has to be a binary file. + +### 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 TestBodyWithBinaryExample + { + public static void Main() + { + Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(Configuration.Default); + var body = BINARY_DATA_HERE; // System.IO.Stream | image to upload + + try + { + apiInstance.TestBodyWithBinary(body); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestBodyWithBinary: " + e.Message ); + Debug.Print("Status Code: "+ e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **System.IO.Stream**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: image/png +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Success | - | + +[[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) + + ## TestBodyWithFileSchema > void TestBodyWithFileSchema (FileSchemaTestClass fileSchemaTestClass) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs index 6161aa33d32..c01c18e2f8c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -178,7 +178,28 @@ namespace Org.OpenAPITools.Api /// /// /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// + void TestBodyWithBinary (System.IO.Stream body); + + /// + /// + /// + /// + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// ApiResponse of Object(void) + ApiResponse TestBodyWithBinaryWithHttpInfo (System.IO.Stream body); + /// + /// + /// + /// + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// @@ -189,7 +210,7 @@ namespace Org.OpenAPITools.Api /// /// /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// @@ -594,7 +615,30 @@ namespace Org.OpenAPITools.Api /// /// /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// Cancellation Token to cancel request (optional) + /// Task of void + System.Threading.Tasks.Task TestBodyWithBinaryAsync (System.IO.Stream body, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// + /// + /// + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// Cancellation Token to cancel request (optional) + /// Task of ApiResponse + System.Threading.Tasks.Task> TestBodyWithBinaryWithHttpInfoAsync (System.IO.Stream body, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// + /// + /// + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// @@ -606,7 +650,7 @@ namespace Org.OpenAPITools.Api /// /// /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// @@ -1988,7 +2032,154 @@ namespace Org.OpenAPITools.Api } /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// + public void TestBodyWithBinary (System.IO.Stream body) + { + TestBodyWithBinaryWithHttpInfo(body); + } + + /// + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// ApiResponse of Object(void) + public ApiResponse TestBodyWithBinaryWithHttpInfo (System.IO.Stream body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling FakeApi->TestBodyWithBinary"); + + var localVarPath = "/fake/body-with-binary"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(this.Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "image/png" + }; + String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) this.Configuration.ApiClient.CallApi(localVarPath, + Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestBodyWithBinary", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), + null); + } + + /// + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// Cancellation Token to cancel request (optional) + /// Task of void + public async System.Threading.Tasks.Task TestBodyWithBinaryAsync (System.IO.Stream body, CancellationToken cancellationToken = default(CancellationToken)) + { + await TestBodyWithBinaryWithHttpInfoAsync(body, cancellationToken); + + } + + /// + /// For this test, the body has to be a binary file. + /// + /// Thrown when fails to make API call + /// image to upload + /// Cancellation Token to cancel request (optional) + /// Task of ApiResponse + public async System.Threading.Tasks.Task> TestBodyWithBinaryWithHttpInfoAsync (System.IO.Stream body, CancellationToken cancellationToken = default(CancellationToken)) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling FakeApi->TestBodyWithBinary"); + + var localVarPath = "/fake/body-with-binary"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(this.Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "image/png" + }; + String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await this.Configuration.ApiClient.CallApiAsync(localVarPath, + Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType, cancellationToken); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestBodyWithBinary", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), + null); + } + + /// + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// @@ -1999,7 +2190,7 @@ namespace Org.OpenAPITools.Api } /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// @@ -2060,7 +2251,7 @@ namespace Org.OpenAPITools.Api } /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// @@ -2073,7 +2264,7 @@ namespace Org.OpenAPITools.Api } /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Thrown when fails to make API call /// diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex index 7d05057b3a6..407ff92dbbd 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex @@ -215,7 +215,33 @@ defmodule OpenapiPetstore.Api.Fake do end @doc """ - For this test, the body for this request much reference a schema named `File`. + For this test, the body has to be a binary file. + + ## Parameters + + - connection (OpenapiPetstore.Connection): Connection to server + - body (String.t): image to upload + - opts (KeywordList): [optional] Optional parameters + ## Returns + + {:ok, nil} on success + {:error, Tesla.Env.t} on failure + """ + @spec test_body_with_binary(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} + def test_body_with_binary(connection, body, _opts \\ []) do + %{} + |> method(:put) + |> url("/fake/body-with-binary") + |> add_param(:body, :body, body) + |> Enum.into([]) + |> (&Connection.request(connection, &1)).() + |> evaluate_response([ + { 200, false} + ]) + end + + @doc """ + For this test, the body for this request must reference a schema named `File`. ## Parameters diff --git a/samples/client/petstore/javascript-es6/README.md b/samples/client/petstore/javascript-es6/README.md index 7484625b457..736594bda69 100644 --- a/samples/client/petstore/javascript-es6/README.md +++ b/samples/client/petstore/javascript-es6/README.md @@ -129,6 +129,7 @@ Class | Method | HTTP request | Description *OpenApiPetstore.FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | *OpenApiPetstore.FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | *OpenApiPetstore.FakeApi* | [**fakePropertyEnumIntegerSerialize**](docs/FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int | +*OpenApiPetstore.FakeApi* | [**testBodyWithBinary**](docs/FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary | *OpenApiPetstore.FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | *OpenApiPetstore.FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | *OpenApiPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/client/petstore/javascript-es6/docs/FakeApi.md b/samples/client/petstore/javascript-es6/docs/FakeApi.md index 95446d77d5e..9ba9d28131b 100644 --- a/samples/client/petstore/javascript-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-es6/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**fakePropertyEnumIntegerSerialize**](FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int | +[**testBodyWithBinary**](FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary | [**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model @@ -345,13 +346,58 @@ No authorization required - **Accept**: */* +## testBodyWithBinary + +> testBodyWithBinary(body) + + + +For this test, the body has to be a binary file. + +### Example + +```javascript +import OpenApiPetstore from 'open_api_petstore'; + +let apiInstance = new OpenApiPetstore.FakeApi(); +let body = "/path/to/file"; // File | image to upload +apiInstance.testBodyWithBinary(body, (error, data, response) => { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}); +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **File**| image to upload | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: image/png +- **Accept**: Not defined + + ## testBodyWithFileSchema > testBodyWithFileSchema(fileSchemaTestClass) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example diff --git a/samples/client/petstore/javascript-es6/src/api/FakeApi.js b/samples/client/petstore/javascript-es6/src/api/FakeApi.js index 33f85635f09..df52f7e836c 100644 --- a/samples/client/petstore/javascript-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-es6/src/api/FakeApi.js @@ -319,6 +319,46 @@ export default class FakeApi { ); } + /** + * Callback function to receive the result of the testBodyWithBinary operation. + * @callback module:api/FakeApi~testBodyWithBinaryCallback + * @param {String} error Error message, if any. + * @param data This operation does not return a value. + * @param {String} response The complete HTTP response. + */ + + /** + * For this test, the body has to be a binary file. + * @param {File} body image to upload + * @param {module:api/FakeApi~testBodyWithBinaryCallback} callback The callback function, accepting three arguments: error, data, response + */ + testBodyWithBinary(body, callback) { + let postBody = body; + // verify the required parameter 'body' is set + if (body === undefined || body === null) { + throw new Error("Missing the required parameter 'body' when calling testBodyWithBinary"); + } + + let pathParams = { + }; + let queryParams = { + }; + let headerParams = { + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = ['image/png']; + let accepts = []; + let returnType = null; + return this.apiClient.callApi( + '/fake/body-with-binary', 'PUT', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, null, callback + ); + } + /** * Callback function to receive the result of the testBodyWithFileSchema operation. * @callback module:api/FakeApi~testBodyWithFileSchemaCallback @@ -328,7 +368,7 @@ export default class FakeApi { */ /** - * For this test, the body for this request much reference a schema named `File`. + * For this test, the body for this request must reference a schema named `File`. * @param {module:model/FileSchemaTestClass} fileSchemaTestClass * @param {module:api/FakeApi~testBodyWithFileSchemaCallback} callback The callback function, accepting three arguments: error, data, response */ diff --git a/samples/client/petstore/javascript-promise-es6/README.md b/samples/client/petstore/javascript-promise-es6/README.md index ef092423575..b13f89f2dac 100644 --- a/samples/client/petstore/javascript-promise-es6/README.md +++ b/samples/client/petstore/javascript-promise-es6/README.md @@ -127,6 +127,7 @@ Class | Method | HTTP request | Description *OpenApiPetstore.FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | *OpenApiPetstore.FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | *OpenApiPetstore.FakeApi* | [**fakePropertyEnumIntegerSerialize**](docs/FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int | +*OpenApiPetstore.FakeApi* | [**testBodyWithBinary**](docs/FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary | *OpenApiPetstore.FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | *OpenApiPetstore.FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | *OpenApiPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md index b6c5594e0ba..a0cd0aefb42 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**fakePropertyEnumIntegerSerialize**](FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int | +[**testBodyWithBinary**](FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary | [**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model @@ -338,13 +339,57 @@ No authorization required - **Accept**: */* +## testBodyWithBinary + +> testBodyWithBinary(body) + + + +For this test, the body has to be a binary file. + +### Example + +```javascript +import OpenApiPetstore from 'open_api_petstore'; + +let apiInstance = new OpenApiPetstore.FakeApi(); +let body = "/path/to/file"; // File | image to upload +apiInstance.testBodyWithBinary(body).then(() => { + console.log('API called successfully.'); +}, (error) => { + console.error(error); +}); + +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **File**| image to upload | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: image/png +- **Accept**: Not defined + + ## testBodyWithFileSchema > testBodyWithFileSchema(fileSchemaTestClass) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example diff --git a/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js b/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js index 0902c816dc4..dc949777c5b 100644 --- a/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js @@ -356,7 +356,52 @@ export default class FakeApi { /** - * For this test, the body for this request much reference a schema named `File`. + * For this test, the body has to be a binary file. + * @param {File} body image to upload + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + testBodyWithBinaryWithHttpInfo(body) { + let postBody = body; + // verify the required parameter 'body' is set + if (body === undefined || body === null) { + throw new Error("Missing the required parameter 'body' when calling testBodyWithBinary"); + } + + let pathParams = { + }; + let queryParams = { + }; + let headerParams = { + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = ['image/png']; + let accepts = []; + let returnType = null; + return this.apiClient.callApi( + '/fake/body-with-binary', 'PUT', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, null + ); + } + + /** + * For this test, the body has to be a binary file. + * @param {File} body image to upload + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + testBodyWithBinary(body) { + return this.testBodyWithBinaryWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + + /** + * For this test, the body for this request must reference a schema named `File`. * @param {module:model/FileSchemaTestClass} fileSchemaTestClass * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ @@ -388,7 +433,7 @@ export default class FakeApi { } /** - * For this test, the body for this request much reference a schema named `File`. + * For this test, the body for this request must reference a schema named `File`. * @param {module:model/FileSchemaTestClass} fileSchemaTestClass * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 9dd81b461b1..2a469ee47b7 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -385,6 +385,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | *FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | *FakeApi* | [**fake_property_enum_integer_serialize**](docs/FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**test_body_with_binary**](docs/FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | *FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model diff --git a/samples/client/petstore/perl/docs/FakeApi.md b/samples/client/petstore/perl/docs/FakeApi.md index d1696217c59..9db900a571a 100644 --- a/samples/client/petstore/perl/docs/FakeApi.md +++ b/samples/client/petstore/perl/docs/FakeApi.md @@ -16,6 +16,7 @@ Method | HTTP request | Description [**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | [**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | [**fake_property_enum_integer_serialize**](FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +[**test_body_with_binary**](FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | [**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model @@ -347,12 +348,57 @@ 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_body_with_binary** +> test_body_with_binary(body => $body) + + + +For this test, the body has to be a binary file. + +### Example +```perl +use Data::Dumper; +use WWW::OpenAPIClient::FakeApi; +my $api_instance = WWW::OpenAPIClient::FakeApi->new( +); + +my $body = WWW::OpenAPIClient::Object::string->new(); # string | image to upload + +eval { + $api_instance->test_body_with_binary(body => $body); +}; +if ($@) { + warn "Exception when calling FakeApi->test_body_with_binary: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **string****string**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: image/png + - **Accept**: Not defined + +[[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_body_with_file_schema** > test_body_with_file_schema(file_schema_test_class => $file_schema_test_class) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example ```perl diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm index 8646aa3cc07..d3879045dee 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm @@ -485,6 +485,62 @@ sub fake_property_enum_integer_serialize { return $_response_object; } +# +# test_body_with_binary +# +# +# +# @param string $body image to upload (required) +{ + my $params = { + 'body' => { + data_type => 'string', + description => 'image to upload', + required => '1', + }, + }; + __PACKAGE__->method_documentation->{ 'test_body_with_binary' } = { + summary => '', + params => $params, + returns => undef, + }; +} +# @return void +# +sub test_body_with_binary { + my ($self, %args) = @_; + + # parse inputs + my $_resource_path = '/fake/body-with-binary'; + + my $_method = 'PUT'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept(); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('image/png'); + + my $_body_data; + # body params + if ( exists $args{'body'}) { + $_body_data = $args{'body'}; + } + + # authentication setting, if any + my $auth_settings = [qw()]; + + # make the API Call + $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + return; +} + # # test_body_with_file_schema # diff --git a/samples/client/petstore/php/OpenAPIClient-php/README.md b/samples/client/petstore/php/OpenAPIClient-php/README.md index 2f4807ddee0..6540cb639a5 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/README.md +++ b/samples/client/petstore/php/OpenAPIClient-php/README.md @@ -80,6 +80,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**fakePropertyEnumIntegerSerialize**](docs/Api/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**testBodyWithBinary**](docs/Api/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | *FakeApi* | [**testBodyWithFileSchema**](docs/Api/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**testBodyWithQueryParams**](docs/Api/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**testClientModel**](docs/Api/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md index 4319d48a408..ce8d2050136 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize()**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize()**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**fakePropertyEnumIntegerSerialize()**](FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int | +[**testBodyWithBinary()**](FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary | [**testBodyWithFileSchema()**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams()**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testClientModel()**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model @@ -412,6 +413,61 @@ No authorization required [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `testBodyWithBinary()` + +```php +testBodyWithBinary($body) +``` + + + +For this test, the body has to be a binary file. + +### Example + +```php +testBodyWithBinary($body); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testBodyWithBinary: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **\SplFileObject****\SplFileObject**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: `image/png` +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + ## `testBodyWithFileSchema()` ```php @@ -420,7 +476,7 @@ testBodyWithFileSchema($file_schema_test_class) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index 69ea9500cde..93aeaacf9c9 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -1847,6 +1847,215 @@ class FakeApi ); } + /** + * Operation testBodyWithBinary + * + * @param \SplFileObject $body image to upload (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testBodyWithBinary($body) + { + $this->testBodyWithBinaryWithHttpInfo($body); + } + + /** + * Operation testBodyWithBinaryWithHttpInfo + * + * @param \SplFileObject $body image to upload (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function testBodyWithBinaryWithHttpInfo($body) + { + $request = $this->testBodyWithBinaryRequest($body); + + 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 + ); + } + + $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() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation testBodyWithBinaryAsync + * + * @param \SplFileObject $body image to upload (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testBodyWithBinaryAsync($body) + { + return $this->testBodyWithBinaryAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testBodyWithBinaryAsyncWithHttpInfo + * + * @param \SplFileObject $body image to upload (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testBodyWithBinaryAsyncWithHttpInfo($body) + { + $returnType = ''; + $request = $this->testBodyWithBinaryRequest($body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $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 'testBodyWithBinary' + * + * @param \SplFileObject $body image to upload (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function testBodyWithBinaryRequest($body) + { + // verify the required parameter 'body' is set + if ($body === null || (is_array($body) && count($body) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling testBodyWithBinary' + ); + } + + $resourcePath = '/fake/body-with-binary'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['image/png'] + ); + } + + // for model (json/xml) + if (isset($body)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body)); + } else { + $httpBody = $body; + } + } 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 ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Operation testBodyWithFileSchema * diff --git a/samples/client/petstore/ruby-faraday/README.md b/samples/client/petstore/ruby-faraday/README.md index f7d8816e8ca..e4cc57adb51 100644 --- a/samples/client/petstore/ruby-faraday/README.md +++ b/samples/client/petstore/ruby-faraday/README.md @@ -84,6 +84,7 @@ Class | Method | HTTP request | Description *Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | *Petstore::FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | *Petstore::FakeApi* | [**fake_property_enum_integer_serialize**](docs/FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +*Petstore::FakeApi* | [**test_body_with_binary**](docs/FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | *Petstore::FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | *Petstore::FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model diff --git a/samples/client/petstore/ruby-faraday/docs/FakeApi.md b/samples/client/petstore/ruby-faraday/docs/FakeApi.md index ce74242565c..696f5ff4820 100644 --- a/samples/client/petstore/ruby-faraday/docs/FakeApi.md +++ b/samples/client/petstore/ruby-faraday/docs/FakeApi.md @@ -11,6 +11,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | | | [**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | | | [**fake_property_enum_integer_serialize**](FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | | +| [**test_body_with_binary**](FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | | | [**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | | | [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | | | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model | @@ -479,13 +480,76 @@ No authorization required - **Accept**: */* +## test_body_with_binary + +> test_body_with_binary(body) + + + +For this test, the body has to be a binary file. + +### Examples + +```ruby +require 'time' +require 'petstore' + +api_instance = Petstore::FakeApi.new +body = File.new('/path/to/some/file') # File | image to upload + +begin + + api_instance.test_body_with_binary(body) +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_body_with_binary: #{e}" +end +``` + +#### Using the test_body_with_binary_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> test_body_with_binary_with_http_info(body) + +```ruby +begin + + data, status_code, headers = api_instance.test_body_with_binary_with_http_info(body) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_body_with_binary_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **body** | **File** | image to upload | | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: image/png +- **Accept**: Not defined + + ## test_body_with_file_schema > test_body_with_file_schema(file_schema_test_class) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Examples diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb index 2155182abf5..eed4d7da429 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb @@ -440,7 +440,64 @@ module Petstore return data, status_code, headers end - # For this test, the body for this request much reference a schema named `File`. + # For this test, the body has to be a binary file. + # @param body [File] image to upload + # @param [Hash] opts the optional parameters + # @return [nil] + def test_body_with_binary(body, opts = {}) + test_body_with_binary_with_http_info(body, opts) + nil + end + + # For this test, the body has to be a binary file. + # @param body [File] image to upload + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def test_body_with_binary_with_http_info(body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_body_with_binary ...' + end + # resource path + local_var_path = '/fake/body-with-binary' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['image/png']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"FakeApi.test_body_with_binary", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_body_with_binary\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # For this test, the body for this request must reference a schema named `File`. # @param file_schema_test_class [FileSchemaTestClass] # @param [Hash] opts the optional parameters # @return [nil] @@ -449,7 +506,7 @@ module Petstore nil end - # For this test, the body for this request much reference a schema named `File`. + # For this test, the body for this request must reference a schema named `File`. # @param file_schema_test_class [FileSchemaTestClass] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index f7d8816e8ca..e4cc57adb51 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -84,6 +84,7 @@ Class | Method | HTTP request | Description *Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | *Petstore::FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | *Petstore::FakeApi* | [**fake_property_enum_integer_serialize**](docs/FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +*Petstore::FakeApi* | [**test_body_with_binary**](docs/FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | *Petstore::FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | *Petstore::FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model diff --git a/samples/client/petstore/ruby/docs/FakeApi.md b/samples/client/petstore/ruby/docs/FakeApi.md index ce74242565c..696f5ff4820 100644 --- a/samples/client/petstore/ruby/docs/FakeApi.md +++ b/samples/client/petstore/ruby/docs/FakeApi.md @@ -11,6 +11,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | | | [**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | | | [**fake_property_enum_integer_serialize**](FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | | +| [**test_body_with_binary**](FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | | | [**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | | | [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | | | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model | @@ -479,13 +480,76 @@ No authorization required - **Accept**: */* +## test_body_with_binary + +> test_body_with_binary(body) + + + +For this test, the body has to be a binary file. + +### Examples + +```ruby +require 'time' +require 'petstore' + +api_instance = Petstore::FakeApi.new +body = File.new('/path/to/some/file') # File | image to upload + +begin + + api_instance.test_body_with_binary(body) +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_body_with_binary: #{e}" +end +``` + +#### Using the test_body_with_binary_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> test_body_with_binary_with_http_info(body) + +```ruby +begin + + data, status_code, headers = api_instance.test_body_with_binary_with_http_info(body) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_body_with_binary_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **body** | **File** | image to upload | | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: image/png +- **Accept**: Not defined + + ## test_body_with_file_schema > test_body_with_file_schema(file_schema_test_class) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Examples diff --git a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb index 2155182abf5..eed4d7da429 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb @@ -440,7 +440,64 @@ module Petstore return data, status_code, headers end - # For this test, the body for this request much reference a schema named `File`. + # For this test, the body has to be a binary file. + # @param body [File] image to upload + # @param [Hash] opts the optional parameters + # @return [nil] + def test_body_with_binary(body, opts = {}) + test_body_with_binary_with_http_info(body, opts) + nil + end + + # For this test, the body has to be a binary file. + # @param body [File] image to upload + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def test_body_with_binary_with_http_info(body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_body_with_binary ...' + end + # resource path + local_var_path = '/fake/body-with-binary' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['image/png']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"FakeApi.test_body_with_binary", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_body_with_binary\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # For this test, the body for this request must reference a schema named `File`. # @param file_schema_test_class [FileSchemaTestClass] # @param [Hash] opts the optional parameters # @return [nil] @@ -449,7 +506,7 @@ module Petstore nil end - # For this test, the body for this request much reference a schema named `File`. + # For this test, the body for this request must reference a schema named `File`. # @param file_schema_test_class [FileSchemaTestClass] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts index 358d9a5b09b..a1f992e866c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts @@ -64,6 +64,10 @@ export interface FakePropertyEnumIntegerSerializeRequest { outerObjectWithEnumProperty: OuterObjectWithEnumProperty; } +export interface TestBodyWithBinaryRequest { + body: Blob | null; +} + export interface TestBodyWithFileSchemaRequest { fileSchemaTestClass: FileSchemaTestClass; } @@ -352,7 +356,39 @@ export class FakeApi extends runtime.BaseAPI { } /** - * For this test, the body for this request much reference a schema named `File`. + * For this test, the body has to be a binary file. + */ + async testBodyWithBinaryRaw(requestParameters: TestBodyWithBinaryRequest): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling testBodyWithBinary.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'image/png'; + + const response = await this.request({ + path: `/fake/body-with-binary`, + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters.body as any, + }); + + return new runtime.VoidApiResponse(response); + } + + /** + * For this test, the body has to be a binary file. + */ + async testBodyWithBinary(requestParameters: TestBodyWithBinaryRequest): Promise { + await this.testBodyWithBinaryRaw(requestParameters); + } + + /** + * For this test, the body for this request must reference a schema named `File`. */ async testBodyWithFileSchemaRaw(requestParameters: TestBodyWithFileSchemaRequest): Promise> { if (requestParameters.fileSchemaTestClass === null || requestParameters.fileSchemaTestClass === undefined) { @@ -377,7 +413,7 @@ export class FakeApi extends runtime.BaseAPI { } /** - * For this test, the body for this request much reference a schema named `File`. + * For this test, the body for this request must reference a schema named `File`. */ async testBodyWithFileSchema(requestParameters: TestBodyWithFileSchemaRequest): Promise { await this.testBodyWithFileSchemaRaw(requestParameters); diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md index 48f3b73ec03..0e312d4370d 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md @@ -73,6 +73,7 @@ Class | Method | HTTP request | Description [*FakeApi*](doc/FakeApi.md) | [**fakeOuterNumberSerialize**](doc/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | [*FakeApi*](doc/FakeApi.md) | [**fakeOuterStringSerialize**](doc/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | [*FakeApi*](doc/FakeApi.md) | [**fakePropertyEnumIntegerSerialize**](doc/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +[*FakeApi*](doc/FakeApi.md) | [**testBodyWithBinary**](doc/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | [*FakeApi*](doc/FakeApi.md) | [**testBodyWithFileSchema**](doc/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | [*FakeApi*](doc/FakeApi.md) | [**testBodyWithQueryParams**](doc/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | [*FakeApi*](doc/FakeApi.md) | [**testClientModel**](doc/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/FakeApi.md index 00d1bde3e34..b8e90ea6074 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/FakeApi.md @@ -16,6 +16,7 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | [**fakePropertyEnumIntegerSerialize**](FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +[**testBodyWithBinary**](FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | [**testBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model @@ -326,12 +327,54 @@ 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) +# **testBodyWithBinary** +> testBodyWithBinary(body) + + + +For this test, the body has to be a binary file. + +### Example +```dart +import 'package:openapi/api.dart'; + +final api = Openapi().getFakeApi(); +final MultipartFile body = BINARY_DATA_HERE; // MultipartFile | image to upload + +try { + api.testBodyWithBinary(body); +} catch on DioError (e) { + print('Exception when calling FakeApi->testBodyWithBinary: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **MultipartFile**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: image/png + - **Accept**: Not defined + +[[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) + # **testBodyWithFileSchema** > testBodyWithFileSchema(fileSchemaTestClass) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example ```dart diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart index 583f89de933..20e4483e544 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart @@ -660,8 +660,78 @@ class FakeApi { ); } + /// testBodyWithBinary + /// For this test, the body has to be a binary file. + /// + /// Parameters: + /// * [body] - image to upload + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] + /// Throws [DioError] if API call or serialization fails + Future> testBodyWithBinary({ + required MultipartFile body, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/fake/body-with-binary'; + final _options = Options( + method: r'PUT', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'image/png', + validateStatus: validateStatus, + ); + + final _queryParameters = { + }; + + dynamic _bodyData; + + try { + _bodyData = body.finalize(); + + } catch(error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + queryParameters: _queryParameters, + ), + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + return _response; + } + /// testBodyWithFileSchema - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Parameters: /// * [fileSchemaTestClass] diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md index 22789ae7761..b1d9fbe962c 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md @@ -67,6 +67,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fakeOuterNumberSerialize**](doc/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterStringSerialize**](doc/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**fakePropertyEnumIntegerSerialize**](doc/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**testBodyWithBinary**](doc/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | *FakeApi* | [**testBodyWithFileSchema**](doc/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**testBodyWithQueryParams**](doc/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**testClientModel**](doc/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md index b28fe4abbe3..da4601dbec5 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md @@ -16,6 +16,7 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | [**fakePropertyEnumIntegerSerialize**](FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +[**testBodyWithBinary**](FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | [**testBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model @@ -326,12 +327,54 @@ 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) +# **testBodyWithBinary** +> testBodyWithBinary(body) + + + +For this test, the body has to be a binary file. + +### Example +```dart +import 'package:openapi/api.dart'; + +var api_instance = new FakeApi(); +var body = new Uint8List(); // Uint8List | image to upload + +try { + api_instance.testBodyWithBinary(body); +} catch (e) { + print('Exception when calling FakeApi->testBodyWithBinary: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **Uint8List**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: image/png + - **Accept**: Not defined + +[[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) + # **testBodyWithFileSchema** > testBodyWithFileSchema(fileSchemaTestClass) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example ```dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart index a8310d5f4a2..9dadc9c1988 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart @@ -413,7 +413,49 @@ class FakeApi { /// /// - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body has to be a binary file. + Future> testBodyWithBinary( + Uint8List body, { + CancelToken cancelToken, + Map headers, + Map extra, + ValidateStatus validateStatus, + ProgressCallback onSendProgress, + ProgressCallback onReceiveProgress, + }) async { + final _request = RequestOptions( + path: r'/fake/body-with-binary', + method: 'PUT', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + contentType: 'image/png', + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + dynamic _bodyData; + + _bodyData = body; + + final _response = await _dio.request( + _request.path, + data: _bodyData, + options: _request, + ); + + return _response; + } + + /// + /// + /// For this test, the body for this request must reference a schema named `File`. Future> testBodyWithFileSchema( FileSchemaTestClass fileSchemaTestClass, { CancelToken cancelToken, diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md index fe39c2f2126..ec001c87cea 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md @@ -67,6 +67,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fakeOuterNumberSerialize**](doc//FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterStringSerialize**](doc//FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**fakePropertyEnumIntegerSerialize**](doc//FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**testBodyWithBinary**](doc//FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | *FakeApi* | [**testBodyWithFileSchema**](doc//FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**testBodyWithQueryParams**](doc//FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**testClientModel**](doc//FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md index 8b7f63bf8bd..6d613003880 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md @@ -16,6 +16,7 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | [**fakePropertyEnumIntegerSerialize**](FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +[**testBodyWithBinary**](FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | [**testBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model @@ -323,12 +324,54 @@ 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) +# **testBodyWithBinary** +> testBodyWithBinary(body) + + + +For this test, the body has to be a binary file. + +### Example +```dart +import 'package:openapi/api.dart'; + +final api_instance = FakeApi(); +final body = MultipartFile(); // MultipartFile | image to upload + +try { + api_instance.testBodyWithBinary(body); +} catch (e) { + print('Exception when calling FakeApi->testBodyWithBinary: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **MultipartFile**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: image/png + - **Accept**: Not defined + +[[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) + # **testBodyWithFileSchema** > testBodyWithFileSchema(fileSchemaTestClass) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example ```dart diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart index 95eb36aacdf..03731c1bf00 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart @@ -414,7 +414,59 @@ class FakeApi { return Future.value(null); } - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body has to be a binary file. + /// + /// Note: This method returns the HTTP [Response]. + /// + /// Parameters: + /// + /// * [MultipartFile] body (required): + /// image to upload + Future testBodyWithBinaryWithHttpInfo(MultipartFile body) async { + // Verify required params are set. + if (body == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: body'); + } + + final path = r'/fake/body-with-binary'; + + Object postBody = body; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + final contentTypes = ['image/png']; + final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; + final authNames = []; + + + return await apiClient.invokeAPI( + path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + nullableContentType, + authNames, + ); + } + + /// For this test, the body has to be a binary file. + /// + /// Parameters: + /// + /// * [MultipartFile] body (required): + /// image to upload + Future testBodyWithBinary(MultipartFile body) async { + final response = await testBodyWithBinaryWithHttpInfo(body); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + } + + /// For this test, the body for this request must reference a schema named `File`. /// /// Note: This method returns the HTTP [Response]. /// @@ -452,7 +504,7 @@ class FakeApi { ); } - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Parameters: /// diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/README.md index fe39c2f2126..ec001c87cea 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/README.md @@ -67,6 +67,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fakeOuterNumberSerialize**](doc//FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterStringSerialize**](doc//FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**fakePropertyEnumIntegerSerialize**](doc//FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**testBodyWithBinary**](doc//FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | *FakeApi* | [**testBodyWithFileSchema**](doc//FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**testBodyWithQueryParams**](doc//FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**testClientModel**](doc//FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/doc/FakeApi.md index 8b7f63bf8bd..6d613003880 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/doc/FakeApi.md @@ -16,6 +16,7 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | [**fakePropertyEnumIntegerSerialize**](FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int | +[**testBodyWithBinary**](FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary | [**testBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model @@ -323,12 +324,54 @@ 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) +# **testBodyWithBinary** +> testBodyWithBinary(body) + + + +For this test, the body has to be a binary file. + +### Example +```dart +import 'package:openapi/api.dart'; + +final api_instance = FakeApi(); +final body = MultipartFile(); // MultipartFile | image to upload + +try { + api_instance.testBodyWithBinary(body); +} catch (e) { + print('Exception when calling FakeApi->testBodyWithBinary: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **MultipartFile**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: image/png + - **Accept**: Not defined + +[[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) + # **testBodyWithFileSchema** > testBodyWithFileSchema(fileSchemaTestClass) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example ```dart diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart index 2386fdfe4d5..9790ef7222c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart @@ -420,7 +420,59 @@ class FakeApi { return Future.value(null); } - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body has to be a binary file. + /// + /// Note: This method returns the HTTP [Response]. + /// + /// Parameters: + /// + /// * [MultipartFile] body (required): + /// image to upload + Future testBodyWithBinaryWithHttpInfo(MultipartFile body) async { + // Verify required params are set. + if (body == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: body'); + } + + final path = r'/fake/body-with-binary'; + + Object postBody = body; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + final contentTypes = ['image/png']; + final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; + final authNames = []; + + + return await apiClient.invokeAPI( + path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + nullableContentType, + authNames, + ); + } + + /// For this test, the body has to be a binary file. + /// + /// Parameters: + /// + /// * [MultipartFile] body (required): + /// image to upload + Future testBodyWithBinary(MultipartFile body) async { + final response = await testBodyWithBinaryWithHttpInfo(body); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + } + + /// For this test, the body for this request must reference a schema named `File`. /// /// Note: This method returns the HTTP [Response]. /// @@ -458,7 +510,7 @@ class FakeApi { ); } - /// For this test, the body for this request much reference a schema named `File`. + /// For this test, the body for this request must reference a schema named `File`. /// /// Parameters: /// diff --git a/samples/openapi3/client/petstore/python-legacy/README.md b/samples/openapi3/client/petstore/python-legacy/README.md index 65ce00102b4..507b849f5b2 100755 --- a/samples/openapi3/client/petstore/python-legacy/README.md +++ b/samples/openapi3/client/petstore/python-legacy/README.md @@ -90,6 +90,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | *FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | *FakeApi* | [**fake_property_enum_integer_serialize**](docs/FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**test_body_with_binary**](docs/FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | *FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model diff --git a/samples/openapi3/client/petstore/python-legacy/docs/FakeApi.md b/samples/openapi3/client/petstore/python-legacy/docs/FakeApi.md index f7bbbecdce6..f958d8f71a0 100755 --- a/samples/openapi3/client/petstore/python-legacy/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-legacy/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | [**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | [**fake_property_enum_integer_serialize**](FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +[**test_body_with_binary**](FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | [**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model @@ -510,12 +511,72 @@ 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_body_with_binary** +> test_body_with_binary(body) + + + +For this test, the body has to be a binary file. + +### Example + +```python +from __future__ import print_function +import time +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + body = '/path/to/file' # file | image to upload + + try: + api_instance.test_body_with_binary(body) + except ApiException as e: + print("Exception when calling FakeApi->test_body_with_binary: %s\n" % e) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **file**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: image/png + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[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_body_with_file_schema** > test_body_with_file_schema(file_schema_test_class) -For this test, the body for this request much reference a schema named `File`. +For this test, the body for this request must reference a schema named `File`. ### Example diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py index d5dd027679e..d81dc4866d9 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py @@ -982,10 +982,139 @@ class FakeApi(object): collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth')) + def test_body_with_binary(self, body, **kwargs): # noqa: E501 + """test_body_with_binary # noqa: E501 + + For this test, the body has to be a binary file. # 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_body_with_binary(body, async_req=True) + >>> result = thread.get() + + :param body: image to upload (required) + :type body: file + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :type _preload_content: 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: None + """ + kwargs['_return_http_data_only'] = True + return self.test_body_with_binary_with_http_info(body, **kwargs) # noqa: E501 + + def test_body_with_binary_with_http_info(self, body, **kwargs): # noqa: E501 + """test_body_with_binary # noqa: E501 + + For this test, the body has to be a binary file. # 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_body_with_binary_with_http_info(body, async_req=True) + >>> result = thread.get() + + :param body: image to upload (required) + :type body: file + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _return_http_data_only: response data without head status code + and headers + :type _return_http_data_only: bool, optional + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :type _preload_content: 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 + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + local_var_params = locals() + + all_params = [ + 'body' + ] + all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth' + ] + ) + + for key, val in six.iteritems(local_var_params['kwargs']): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_body_with_binary" % key + ) + local_var_params[key] = val + del local_var_params['kwargs'] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in local_var_params: + body_params = local_var_params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['image/png']) # noqa: E501 + + # Authentication setting + auth_settings = [] # noqa: E501 + + response_types_map = {} + + return self.api_client.call_api( + '/fake/body-with-binary', 'PUT', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_types_map=response_types_map, + auth_settings=auth_settings, + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats, + _request_auth=local_var_params.get('_request_auth')) + def test_body_with_file_schema(self, file_schema_test_class, **kwargs): # noqa: E501 """test_body_with_file_schema # noqa: E501 - For this test, the body for this request much reference a schema named `File`. # noqa: E501 + For this test, the body for this request must reference a schema named `File`. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -1015,7 +1144,7 @@ class FakeApi(object): def test_body_with_file_schema_with_http_info(self, file_schema_test_class, **kwargs): # noqa: E501 """test_body_with_file_schema # noqa: E501 - For this test, the body for this request much reference a schema named `File`. # noqa: E501 + For this test, the body for this request must reference a schema named `File`. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java index 43796a701ef..9cfd7cd8869 100644 --- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java @@ -153,10 +153,22 @@ public class FakeApi { return delegate.fakePropertyEnumIntegerSerialize(outerObjectWithEnumProperty, securityContext); } @PUT + @Path("/body-with-binary") + @Consumes({ "image/png" }) + + @io.swagger.annotations.ApiOperation(value = "", notes = "For this test, the body has to be a binary file.", response = Void.class, tags={ "fake", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "Success", response = Void.class) + }) + public Response testBodyWithBinary(@ApiParam(value = "image to upload", required = true) @NotNull File body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.testBodyWithBinary(body, securityContext); + } + @PUT @Path("/body-with-file-schema") @Consumes({ "application/json" }) - @io.swagger.annotations.ApiOperation(value = "", notes = "For this test, the body for this request much reference a schema named `File`.", response = Void.class, tags={ "fake", }) + @io.swagger.annotations.ApiOperation(value = "", notes = "For this test, the body for this request must reference a schema named `File`.", response = Void.class, tags={ "fake", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Success", response = Void.class) }) diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java index 60685a8f5ff..e5c1a063e88 100644 --- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java @@ -35,6 +35,7 @@ public abstract class FakeApiService { public abstract Response fakeOuterNumberSerialize(BigDecimal body,SecurityContext securityContext) throws NotFoundException; public abstract Response fakeOuterStringSerialize(String body,SecurityContext securityContext) throws NotFoundException; public abstract Response fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty,SecurityContext securityContext) throws NotFoundException; + public abstract Response testBodyWithBinary(File body,SecurityContext securityContext) throws NotFoundException; public abstract Response testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass,SecurityContext securityContext) throws NotFoundException; public abstract Response testBodyWithQueryParams( @NotNull String query,User user,SecurityContext securityContext) throws NotFoundException; public abstract Response testClientModel(Client client,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java index 10c9235fe62..b9b56985363 100644 --- a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java @@ -64,6 +64,11 @@ public class FakeApiServiceImpl extends FakeApiService { return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } @Override + public Response testBodyWithBinary(File body, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override public Response testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass, SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); diff --git a/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php b/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php index cb3da629aaa..a0b1238d92e 100644 --- a/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php +++ b/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php @@ -228,6 +228,30 @@ class FakeController extends Controller return response('How about implementing testGroupParameters as a delete method ?'); } + /** + * Operation testBodyWithBinary + * + * . + * + * + * @return Http response + */ + public function testBodyWithBinary() + { + $input = Request::all(); + + //path params validation + + + //not path params validation + if (!isset($input['body'])) { + throw new \InvalidArgumentException('Missing the required parameter $body when calling testBodyWithBinary'); + } + $body = $input['body']; + + + return response('How about implementing testBodyWithBinary as a put method ?'); + } /** * Operation testBodyWithFileSchema * diff --git a/samples/server/petstore/php-laravel/lib/routes/api.php b/samples/server/petstore/php-laravel/lib/routes/api.php index 856cc66810a..fec2cea4a3c 100644 --- a/samples/server/petstore/php-laravel/lib/routes/api.php +++ b/samples/server/petstore/php-laravel/lib/routes/api.php @@ -63,10 +63,17 @@ Route::get('/v2/fake', 'FakeController@testEnumParameters'); */ Route::delete('/v2/fake', 'FakeController@testGroupParameters'); +/** + * put testBodyWithBinary + * Summary: + * Notes: For this test, the body has to be a binary file. + + */ +Route::put('/v2/fake/body-with-binary', 'FakeController@testBodyWithBinary'); /** * put testBodyWithFileSchema * Summary: - * Notes: For this test, the body for this request much reference a schema named `File`. + * Notes: For this test, the body for this request must reference a schema named `File`. */ Route::put('/v2/fake/body-with-file-schema', 'FakeController@testBodyWithFileSchema'); diff --git a/samples/server/petstore/php-lumen/lib/app/Http/Controllers/FakeApi.php b/samples/server/petstore/php-lumen/lib/app/Http/Controllers/FakeApi.php index 86e5ae7356f..e3b631dd097 100644 --- a/samples/server/petstore/php-lumen/lib/app/Http/Controllers/FakeApi.php +++ b/samples/server/petstore/php-lumen/lib/app/Http/Controllers/FakeApi.php @@ -224,6 +224,30 @@ class FakeApi extends Controller return response('How about implementing testGroupParameters as a delete method ?'); } + /** + * Operation testBodyWithBinary + * + * . + * + * + * @return Http response + */ + public function testBodyWithBinary() + { + $input = Request::all(); + + //path params validation + + + //not path params validation + if (!isset($input['body'])) { + throw new \InvalidArgumentException('Missing the required parameter $body when calling testBodyWithBinary'); + } + $body = $input['body']; + + + return response('How about implementing testBodyWithBinary as a put method ?'); + } /** * Operation testBodyWithFileSchema * diff --git a/samples/server/petstore/php-lumen/lib/routes/web.php b/samples/server/petstore/php-lumen/lib/routes/web.php index f159b8da780..9831967079f 100644 --- a/samples/server/petstore/php-lumen/lib/routes/web.php +++ b/samples/server/petstore/php-lumen/lib/routes/web.php @@ -79,10 +79,17 @@ $router->get('/v2/fake', 'FakeApi@testEnumParameters'); */ $router->delete('/v2/fake', 'FakeApi@testGroupParameters'); +/** + * put testBodyWithBinary + * Summary: + * Notes: For this test, the body has to be a binary file. + */ +$router->put('/v2/fake/body-with-binary', 'FakeApi@testBodyWithBinary'); + /** * put testBodyWithFileSchema * Summary: - * Notes: For this test, the body for this request much reference a schema named `File`. + * Notes: For this test, the body for this request must reference a schema named `File`. */ $router->put('/v2/fake/body-with-file-schema', 'FakeApi@testBodyWithFileSchema');