diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache index 286bedb7569c..a8c7da4a34c2 100644 --- a/modules/openapi-generator/src/main/resources/go/api.mustache +++ b/modules/openapi-generator/src/main/resources/go/api.mustache @@ -177,6 +177,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{#hasFormParams}} {{#formParams}} {{#isFile}} +{{#required}} + localVarFile := {{paramName}} +{{/required}} {{^required}} var localVarFile {{dataType}} if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() { diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index c276aaa3fdca..53a15cad7521 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -272,6 +272,43 @@ paths: - petstore_auth: - 'write:pets' - 'read:pets' + '/pet/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFileWithRequiredFile + consumes: + - multipart/form-data + produces: + - application/json + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + type: integer + format: int64 + - name: additionalMetadata + in: formData + description: Additional data to pass to server + required: false + type: string + - name: file + in: formData + description: file to upload + required: true + type: file + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' /store/inventory: get: tags: 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 54517a7aa036..3989ad4f0b97 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 @@ -67,7 +67,6 @@ paths: description: Status values that need to be considered for filter required: true style: form - explode: false schema: type: array items: @@ -112,7 +111,6 @@ paths: description: Tags to filter by required: true style: form - explode: false schema: type: array items: @@ -267,6 +265,47 @@ paths: description: file to upload type: string format: binary + '/pet/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFileWithRequiredFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + required: + - file /store/inventory: get: tags: @@ -436,7 +475,7 @@ paths: type: integer format: int32 X-Expires-After: - description: date in UTC when toekn expires + description: date in UTC when token expires schema: type: string format: date-time @@ -573,7 +612,6 @@ paths: parameters: - name: enum_header_string_array in: header - explode: true description: Header parameter enum test (string array) schema: type: array @@ -876,6 +914,26 @@ paths: type: string description: request body required: true + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true /another-fake/dummy: patch: tags: @@ -892,9 +950,6 @@ paths: $ref: '#/components/schemas/Client' requestBody: $ref: '#/components/requestBodies/Client' -externalDocs: - description: Find out more about Swagger - url: 'http://swagger.io' components: requestBodies: UserArray: @@ -1394,6 +1449,7 @@ components: type: string OuterBoolean: type: boolean + x-codegen-body-parameter-name: boolean_post_body _special_model.name_: properties: '$special[property.name]': diff --git a/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION b/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION index 82602aa4190d..282895a8f8f1 100644 --- a/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION +++ b/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.3-SNAPSHOT \ No newline at end of file +3.0.3 \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index b23f5f4e161f..2f44cf6ab749 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -50,6 +50,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **Put** /pet | Update an existing pet *PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **Post** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **Post** /pet/{petId}/uploadImage | uploads an image +*PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **Post** /pet/{petId}/uploadImageWithRequiredFile | uploads an image *StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **Delete** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **Get** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **Get** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/go/go-petstore/api/openapi.yaml b/samples/client/petstore/go/go-petstore/api/openapi.yaml index 9d5d91e96dd7..2e5dbfa3f311 100644 --- a/samples/client/petstore/go/go-petstore/api/openapi.yaml +++ b/samples/client/petstore/go/go-petstore/api/openapi.yaml @@ -282,6 +282,46 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + required: + - file + required: true + responses: + 200: + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities diff --git a/samples/client/petstore/go/go-petstore/api_pet.go b/samples/client/petstore/go/go-petstore/api_pet.go index 37db3a5b3535..f44bbc804da4 100644 --- a/samples/client/petstore/go/go-petstore/api_pet.go +++ b/samples/client/petstore/go/go-petstore/api_pet.go @@ -696,3 +696,106 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt return localVarReturnValue, localVarHttpResponse, nil } + +/* +PetApiService uploads an image + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param petId ID of pet to update + * @param file file to upload + * @param optional nil or *UploadFileWithRequiredFileOpts - Optional Parameters: + * @param "AdditionalMetadata" (optional.String) - Additional data to pass to server +@return ApiResponse +*/ + +type UploadFileWithRequiredFileOpts struct { + AdditionalMetadata optional.String +} + +func (a *PetApiService) UploadFileWithRequiredFile(ctx context.Context, petId int64, file *os.File, localVarOptionals *UploadFileWithRequiredFileOpts) (ApiResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ApiResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/pet/{petId}/uploadImageWithRequiredFile" + localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"multipart/form-data"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.AdditionalMetadata.IsSet() { + localVarFormParams.Add("additionalMetadata", parameterToString(localVarOptionals.AdditionalMetadata.Value(), "")) + } + localVarFile := file + if localVarFile != nil { + fbs, _ := ioutil.ReadAll(localVarFile) + localVarFileBytes = fbs + localVarFileName = localVarFile.Name() + localVarFile.Close() + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v ApiResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md index 9a78c747da00..402f31e72910 100644 --- a/samples/client/petstore/go/go-petstore/docs/PetApi.md +++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**UpdatePet**](PetApi.md#UpdatePet) | **Put** /pet | Update an existing pet [**UpdatePetWithForm**](PetApi.md#UpdatePetWithForm) | **Post** /pet/{petId} | Updates a pet in the store with form data [**UploadFile**](PetApi.md#UploadFile) | **Post** /pet/{petId}/uploadImage | uploads an image +[**UploadFileWithRequiredFile**](PetApi.md#UploadFileWithRequiredFile) | **Post** /pet/{petId}/uploadImageWithRequiredFile | uploads an image # **AddPet** @@ -257,3 +258,40 @@ Name | Type | Description | Notes [[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) +# **UploadFileWithRequiredFile** +> ApiResponse UploadFileWithRequiredFile(ctx, petId, file, optional) +uploads an image + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **petId** | **int64**| ID of pet to update | + **file** | ***os.File*****os.File**| file to upload | + **optional** | ***UploadFileWithRequiredFileOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UploadFileWithRequiredFileOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + + **additionalMetadata** | **optional.String**| Additional data to pass to server | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 408ce7b41960..e6e5ba561a67 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -160,6 +160,26 @@ func TestUploadFile(t *testing.T) { } } +func TestUploadFileRequired(t *testing.T) { + return // remove when server supports this endpoint + file, _ := os.Open("../python/testfiles/foo.png") + + _, r, err := client.PetApi.UploadFileWithRequiredFile(context.Background(), 12830, + file, + &sw.UploadFileWithRequiredFileOpts{ + AdditionalMetadata: optional.NewString("golang"), + }) + + if err != nil { + t.Errorf("Error while uploading file") + t.Log(err) + } + + if r.StatusCode != 200 { + t.Log(r) + } +} + func TestDeletePet(t *testing.T) { r, err := client.PetApi.DeletePet(context.Background(), 12830, nil) diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java index 7373181773a9..da3cb0cd4ae5 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java @@ -182,4 +182,19 @@ public FindPetsByTagsQueryParams tags(final List value) { "Accept: application/json", }) ModelApiResponse uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + */ + @RequestLine("POST /pet/{petId}/uploadImageWithRequiredFile") + @Headers({ + "Content-Type: multipart/form-data", + "Accept: application/json", + }) + ModelApiResponse uploadFileWithRequiredFile(@Param("petId") Long petId, @Param("file") File file, @Param("additionalMetadata") String additionalMetadata); } diff --git a/samples/client/petstore/java/google-api-client/docs/PetApi.md b/samples/client/petstore/java/google-api-client/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/google-api-client/docs/PetApi.md +++ b/samples/client/petstore/java/google-api-client/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java index e35d5f87577c..7ee23a1e3fee 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java @@ -715,4 +715,93 @@ public HttpResponse uploadFileForHttpResponse(Long petId, Map pa } + /** + * uploads an image + *

200 - successful operation + * @param petId ID of pet to update + * @param file file to upload + * @param additionalMetadata Additional data to pass to server + * @return ModelApiResponse + * @throws IOException if an error occurs while attempting to invoke the API + **/ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws IOException { + HttpResponse response = uploadFileWithRequiredFileForHttpResponse(petId, file, additionalMetadata); + TypeReference typeRef = new TypeReference() {}; + return apiClient.getObjectMapper().readValue(response.getContent(), typeRef); + } + + /** + * uploads an image + *

200 - successful operation + * @param petId ID of pet to update + * @param file file to upload + * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. + * @return ModelApiResponse + * @throws IOException if an error occurs while attempting to invoke the API + **/ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, Map params) throws IOException { + HttpResponse response = uploadFileWithRequiredFileForHttpResponse(petId, file, params); + TypeReference typeRef = new TypeReference() {}; + return apiClient.getObjectMapper().readValue(response.getContent(), typeRef); + } + + public HttpResponse uploadFileWithRequiredFileForHttpResponse(Long petId, File file, String additionalMetadata) throws IOException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new IllegalArgumentException("Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + }// verify the required parameter 'file' is set + if (file == null) { + throw new IllegalArgumentException("Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + // create a map of path variables + final Map uriVariables = new HashMap(); + uriVariables.put("petId", petId); + UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/{petId}/uploadImageWithRequiredFile"); + + String url = uriBuilder.buildFromMap(uriVariables).toString(); + GenericUrl genericUrl = new GenericUrl(url); + + HttpContent content = apiClient.new JacksonJsonHttpContent(null); + return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + } + + public HttpResponse uploadFileWithRequiredFileForHttpResponse(Long petId, File file, Map params) throws IOException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new IllegalArgumentException("Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + }// verify the required parameter 'file' is set + if (file == null) { + throw new IllegalArgumentException("Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + // create a map of path variables + final Map uriVariables = new HashMap(); + uriVariables.put("petId", petId); + UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/{petId}/uploadImageWithRequiredFile"); + + // Copy the params argument if present, to allow passing in immutable maps + Map allParams = params == null ? new HashMap() : new HashMap(params); + + for (Map.Entry entry: allParams.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + + if (key != null && value != null) { + if (value instanceof Collection) { + uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); + } else if (value instanceof Object[]) { + uriBuilder = uriBuilder.queryParam(key, (Object[]) value); + } else { + uriBuilder = uriBuilder.queryParam(key, value); + } + } + } + + String url = uriBuilder.buildFromMap(uriVariables).toString(); + GenericUrl genericUrl = new GenericUrl(url); + + HttpContent content = apiClient.new JacksonJsonHttpContent(null); + return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + } + + } diff --git a/samples/client/petstore/java/jersey1/docs/PetApi.md b/samples/client/petstore/java/jersey1/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/jersey1/docs/PetApi.md +++ b/samples/client/petstore/java/jersey1/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/api/PetApi.java index dd97c0c220dc..7c9534e93375 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/api/PetApi.java @@ -385,6 +385,60 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File f + if (additionalMetadata != null) + localVarFormParams.put("additionalMetadata", additionalMetadata); +if (file != null) + localVarFormParams.put("file", file); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new ApiException(400, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile" + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + if (additionalMetadata != null) localVarFormParams.put("additionalMetadata", additionalMetadata); if (file != null) diff --git a/samples/client/petstore/java/jersey2-java6/docs/PetApi.md b/samples/client/petstore/java/jersey2-java6/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/jersey2-java6/docs/PetApi.md +++ b/samples/client/petstore/java/jersey2-java6/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java index fd98d4fe4b1f..fa6ff5792ed6 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java @@ -459,6 +459,72 @@ public ApiResponse uploadFileWithHttpInfo(Long petId, String a + if (additionalMetadata != null) + localVarFormParams.put("additionalMetadata", additionalMetadata); +if (file != null) + localVarFormParams.put("file", file); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws ApiException { + return uploadFileWithRequiredFileWithHttpInfo(petId, file, additionalMetadata).getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long petId, File file, String additionalMetadata) throws ApiException { + Object localVarPostBody = new Object(); + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new ApiException(400, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile" + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + if (additionalMetadata != null) localVarFormParams.put("additionalMetadata", additionalMetadata); if (file != null) diff --git a/samples/client/petstore/java/jersey2-java8/docs/PetApi.md b/samples/client/petstore/java/jersey2-java8/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/jersey2-java8/docs/PetApi.md +++ b/samples/client/petstore/java/jersey2-java8/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java index fd98d4fe4b1f..fa6ff5792ed6 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java @@ -459,6 +459,72 @@ public ApiResponse uploadFileWithHttpInfo(Long petId, String a + if (additionalMetadata != null) + localVarFormParams.put("additionalMetadata", additionalMetadata); +if (file != null) + localVarFormParams.put("file", file); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws ApiException { + return uploadFileWithRequiredFileWithHttpInfo(petId, file, additionalMetadata).getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long petId, File file, String additionalMetadata) throws ApiException { + Object localVarPostBody = new Object(); + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new ApiException(400, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile" + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + if (additionalMetadata != null) localVarFormParams.put("additionalMetadata", additionalMetadata); if (file != null) diff --git a/samples/client/petstore/java/jersey2/docs/PetApi.md b/samples/client/petstore/java/jersey2/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/jersey2/docs/PetApi.md +++ b/samples/client/petstore/java/jersey2/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java index fd98d4fe4b1f..fa6ff5792ed6 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java @@ -459,6 +459,72 @@ public ApiResponse uploadFileWithHttpInfo(Long petId, String a + if (additionalMetadata != null) + localVarFormParams.put("additionalMetadata", additionalMetadata); +if (file != null) + localVarFormParams.put("file", file); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws ApiException { + return uploadFileWithRequiredFileWithHttpInfo(petId, file, additionalMetadata).getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long petId, File file, String additionalMetadata) throws ApiException { + Object localVarPostBody = new Object(); + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new ApiException(400, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile" + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + if (additionalMetadata != null) localVarFormParams.put("additionalMetadata", additionalMetadata); if (file != null) diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/PetApi.md b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/PetApi.md +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java index 67962e30e015..b0ab91c18ef9 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java @@ -1063,4 +1063,144 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don apiClient.executeAsync(call, localVarReturnType, callback); return call; } + /** + * Build call for uploadFileWithRequiredFile + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call uploadFileWithRequiredFileCall(Long petId, File file, String additionalMetadata, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = new Object(); + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile" + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + if (additionalMetadata != null) + localVarFormParams.put("additionalMetadata", additionalMetadata); + if (file != null) + localVarFormParams.put("file", file); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call uploadFileWithRequiredFileValidateBeforeCall(Long petId, File file, String additionalMetadata, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException("Missing the required parameter 'petId' when calling uploadFileWithRequiredFile(Async)"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new ApiException("Missing the required parameter 'file' when calling uploadFileWithRequiredFile(Async)"); + } + + + com.squareup.okhttp.Call call = uploadFileWithRequiredFileCall(petId, file, additionalMetadata, progressListener, progressRequestListener); + return call; + + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws ApiException { + ApiResponse resp = uploadFileWithRequiredFileWithHttpInfo(petId, file, additionalMetadata); + return resp.getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long petId, File file, String additionalMetadata) throws ApiException { + com.squareup.okhttp.Call call = uploadFileWithRequiredFileValidateBeforeCall(petId, file, additionalMetadata, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * uploads an image (asynchronously) + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call uploadFileWithRequiredFileAsync(Long petId, File file, String additionalMetadata, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = uploadFileWithRequiredFileValidateBeforeCall(petId, file, additionalMetadata, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } } diff --git a/samples/client/petstore/java/okhttp-gson/docs/PetApi.md b/samples/client/petstore/java/okhttp-gson/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/PetApi.md +++ b/samples/client/petstore/java/okhttp-gson/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java index 67962e30e015..b0ab91c18ef9 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java @@ -1063,4 +1063,144 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don apiClient.executeAsync(call, localVarReturnType, callback); return call; } + /** + * Build call for uploadFileWithRequiredFile + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call uploadFileWithRequiredFileCall(Long petId, File file, String additionalMetadata, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = new Object(); + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile" + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + if (additionalMetadata != null) + localVarFormParams.put("additionalMetadata", additionalMetadata); + if (file != null) + localVarFormParams.put("file", file); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call uploadFileWithRequiredFileValidateBeforeCall(Long petId, File file, String additionalMetadata, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException("Missing the required parameter 'petId' when calling uploadFileWithRequiredFile(Async)"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new ApiException("Missing the required parameter 'file' when calling uploadFileWithRequiredFile(Async)"); + } + + + com.squareup.okhttp.Call call = uploadFileWithRequiredFileCall(petId, file, additionalMetadata, progressListener, progressRequestListener); + return call; + + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws ApiException { + ApiResponse resp = uploadFileWithRequiredFileWithHttpInfo(petId, file, additionalMetadata); + return resp.getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long petId, File file, String additionalMetadata) throws ApiException { + com.squareup.okhttp.Call call = uploadFileWithRequiredFileValidateBeforeCall(petId, file, additionalMetadata, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * uploads an image (asynchronously) + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call uploadFileWithRequiredFileAsync(Long petId, File file, String additionalMetadata, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = uploadFileWithRequiredFileValidateBeforeCall(petId, file, additionalMetadata, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } } diff --git a/samples/client/petstore/java/rest-assured/docs/PetApi.md b/samples/client/petstore/java/rest-assured/docs/PetApi.md index 97f4b82d7a94..fb3a0d8e1eea 100644 --- a/samples/client/petstore/java/rest-assured/docs/PetApi.md +++ b/samples/client/petstore/java/rest-assured/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -345,3 +346,46 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.uploadFileWithRequiredFile() + .petIdPath(petId) + .fileMultiPart(file).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java index ef84a7c4c785..bfc21ac2dc12 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java @@ -82,6 +82,10 @@ public UploadFileOper uploadFile() { return new UploadFileOper(reqSpec); } + public UploadFileWithRequiredFileOper uploadFileWithRequiredFile() { + return new UploadFileWithRequiredFileOper(reqSpec); + } + /** * Customise request specification * @param consumer consumer @@ -738,4 +742,108 @@ public UploadFileOper respSpec(Consumer consumer) { return this; } } + /** + * uploads an image + * + * + * @see #petIdPath ID of pet to update (required) + * @see #fileMultiPart file to upload (required) + * @see #additionalMetadataForm Additional data to pass to server (optional, default to null) + * return ModelApiResponse + */ + public class UploadFileWithRequiredFileOper { + + public static final String REQ_URI = "/pet/{petId}/uploadImageWithRequiredFile"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public UploadFileWithRequiredFileOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("multipart/form-data"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public UploadFileWithRequiredFileOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("multipart/form-data"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /pet/{petId}/uploadImageWithRequiredFile + * @param handler handler + * @param type + * @return type + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * POST /pet/{petId}/uploadImageWithRequiredFile + * @param handler handler + * @return ModelApiResponse + */ + public ModelApiResponse executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return execute(handler).as(type); + } + + public static final String PET_ID_PATH = "petId"; + + /** + * @param petId (Long) ID of pet to update (required) + * @return operation + */ + public UploadFileWithRequiredFileOper petIdPath(Object petId) { + reqSpec.addPathParam(PET_ID_PATH, petId); + return this; + } + + public static final String ADDITIONAL_METADATA_FORM = "additionalMetadata"; + + /** + * @param additionalMetadata (String) Additional data to pass to server (optional, default to null) + * @return operation + */ + public UploadFileWithRequiredFileOper additionalMetadataForm(Object... additionalMetadata) { + reqSpec.addFormParam(ADDITIONAL_METADATA_FORM, additionalMetadata); + return this; + } + + /** + * It will assume that the control name is file and the <content-type> is <application/octet-stream> + * @see #reqSpec for customise + * @param file (File) file to upload (required) + * @return operation + */ + public UploadFileWithRequiredFileOper fileMultiPart(File file) { + reqSpec.addMultiPart(file); + return this; + } + + /** + * Customise request specification + * @param consumer consumer + * @return operation + */ + public UploadFileWithRequiredFileOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + * @param consumer consumer + * @return operation + */ + public UploadFileWithRequiredFileOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } } \ No newline at end of file diff --git a/samples/client/petstore/java/resteasy/docs/PetApi.md b/samples/client/petstore/java/resteasy/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/resteasy/docs/PetApi.md +++ b/samples/client/petstore/java/resteasy/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/PetApi.java index ae62c12ede39..c186143a9791 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/PetApi.java @@ -363,6 +363,59 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File f + if (additionalMetadata != null) + localVarFormParams.put("additionalMetadata", additionalMetadata); +if (file != null) + localVarFormParams.put("file", file); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return a {@code ModelApiResponse} + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws ApiException { + Object localVarPostBody = new Object(); + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new ApiException(400, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + if (additionalMetadata != null) localVarFormParams.put("additionalMetadata", additionalMetadata); if (file != null) diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/PetApi.md b/samples/client/petstore/java/resttemplate-withXml/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/resttemplate-withXml/docs/PetApi.md +++ b/samples/client/petstore/java/resttemplate-withXml/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java index c1d31488ce71..4e07b0c0c439 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java @@ -352,6 +352,57 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File f String[] authNames = new String[] { "petstore_auth" }; + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } + /** + * uploads an image + * + *

200 - successful operation + * @param petId ID of pet to update + * @param file file to upload + * @param additionalMetadata Additional data to pass to server + * @return ModelApiResponse + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws RestClientException { + Object postBody = new Object(); + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + + // create path and map variables + final Map uriVariables = new HashMap(); + uriVariables.put("petId", petId); + String path = UriComponentsBuilder.fromPath("/pet/{petId}/uploadImageWithRequiredFile").buildAndExpand(uriVariables).toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + if (additionalMetadata != null) + formParams.add("additionalMetadata", additionalMetadata); + if (file != null) + formParams.add("file", new FileSystemResource(file)); + + final String[] accepts = { + "application/json" + }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { + "multipart/form-data" + }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } diff --git a/samples/client/petstore/java/resttemplate/docs/PetApi.md b/samples/client/petstore/java/resttemplate/docs/PetApi.md index 714ecc7ab829..eb47b476a1a8 100644 --- a/samples/client/petstore/java/resttemplate/docs/PetApi.md +++ b/samples/client/petstore/java/resttemplate/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java index c1d31488ce71..4e07b0c0c439 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java @@ -352,6 +352,57 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File f String[] authNames = new String[] { "petstore_auth" }; + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } + /** + * uploads an image + * + *

200 - successful operation + * @param petId ID of pet to update + * @param file file to upload + * @param additionalMetadata Additional data to pass to server + * @return ModelApiResponse + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, File file, String additionalMetadata) throws RestClientException { + Object postBody = new Object(); + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); + } + + // verify the required parameter 'file' is set + if (file == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile"); + } + + // create path and map variables + final Map uriVariables = new HashMap(); + uriVariables.put("petId", petId); + String path = UriComponentsBuilder.fromPath("/pet/{petId}/uploadImageWithRequiredFile").buildAndExpand(uriVariables).toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + if (additionalMetadata != null) + formParams.add("additionalMetadata", additionalMetadata); + if (file != null) + formParams.add("file", new FileSystemResource(file)); + + final String[] accepts = { + "application/json" + }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { + "multipart/form-data" + }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/api/PetApi.java index 9b01b4dec1fe..e20531160bb7 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/api/PetApi.java @@ -222,4 +222,34 @@ ModelApiResponse uploadFile( void uploadFile( @retrofit.http.Path("petId") Long petId, @retrofit.http.Part("additionalMetadata") String additionalMetadata, @retrofit.http.Part("file") TypedFile file, Callback cb ); + /** + * uploads an image + * Sync method + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return ModelApiResponse + */ + + @retrofit.http.Multipart + @POST("/pet/{petId}/uploadImageWithRequiredFile") + ModelApiResponse uploadFileWithRequiredFile( + @retrofit.http.Path("petId") Long petId, @retrofit.http.Part("file") TypedFile file, @retrofit.http.Part("additionalMetadata") String additionalMetadata + ); + + /** + * uploads an image + * Async method + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param cb callback method + */ + + @retrofit.http.Multipart + @POST("/pet/{petId}/uploadImageWithRequiredFile") + void uploadFileWithRequiredFile( + @retrofit.http.Path("petId") Long petId, @retrofit.http.Part("file") TypedFile file, @retrofit.http.Part("additionalMetadata") String additionalMetadata, Callback cb + ); } diff --git a/samples/client/petstore/java/retrofit2-play24/docs/PetApi.md b/samples/client/petstore/java/retrofit2-play24/docs/PetApi.md index db7fad1cdb23..cde9eda467e3 100644 --- a/samples/client/petstore/java/retrofit2-play24/docs/PetApi.md +++ b/samples/client/petstore/java/retrofit2-play24/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/api/PetApi.java index 72fb65870b5d..adb8fce7d5de 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/api/PetApi.java @@ -125,4 +125,18 @@ F.Promise> uploadFile( @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file") MultipartBody.Part file ); + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return Call<ModelApiResponse> + */ + @retrofit2.http.Multipart + @POST("pet/{petId}/uploadImageWithRequiredFile") + F.Promise> uploadFileWithRequiredFile( + @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("file") MultipartBody.Part file, @retrofit2.http.Part("additionalMetadata") String additionalMetadata + ); + } diff --git a/samples/client/petstore/java/retrofit2-play25/docs/PetApi.md b/samples/client/petstore/java/retrofit2-play25/docs/PetApi.md index db7fad1cdb23..cde9eda467e3 100644 --- a/samples/client/petstore/java/retrofit2-play25/docs/PetApi.md +++ b/samples/client/petstore/java/retrofit2-play25/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/api/PetApi.java index 4a0846d74d64..bb09b995d1d1 100644 --- a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/api/PetApi.java @@ -125,4 +125,18 @@ CompletionStage> uploadFile( @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file") MultipartBody.Part file ); + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return Call<ModelApiResponse> + */ + @retrofit2.http.Multipart + @POST("pet/{petId}/uploadImageWithRequiredFile") + CompletionStage> uploadFileWithRequiredFile( + @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("file") MultipartBody.Part file, @retrofit2.http.Part("additionalMetadata") String additionalMetadata + ); + } diff --git a/samples/client/petstore/java/retrofit2/docs/PetApi.md b/samples/client/petstore/java/retrofit2/docs/PetApi.md index db7fad1cdb23..cde9eda467e3 100644 --- a/samples/client/petstore/java/retrofit2/docs/PetApi.md +++ b/samples/client/petstore/java/retrofit2/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/api/PetApi.java index 37b70a26f5e6..0261620786e3 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/api/PetApi.java @@ -122,4 +122,18 @@ Call uploadFile( @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file") MultipartBody.Part file ); + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return Call<ModelApiResponse> + */ + @retrofit2.http.Multipart + @POST("pet/{petId}/uploadImageWithRequiredFile") + Call uploadFileWithRequiredFile( + @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("file") MultipartBody.Part file, @retrofit2.http.Part("additionalMetadata") String additionalMetadata + ); + } diff --git a/samples/client/petstore/java/retrofit2rx/docs/PetApi.md b/samples/client/petstore/java/retrofit2rx/docs/PetApi.md index db7fad1cdb23..cde9eda467e3 100644 --- a/samples/client/petstore/java/retrofit2rx/docs/PetApi.md +++ b/samples/client/petstore/java/retrofit2rx/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/api/PetApi.java index 3079b6fa5587..7929df96d2a5 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/api/PetApi.java @@ -122,4 +122,18 @@ Observable uploadFile( @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file") MultipartBody.Part file ); + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return Observable<ModelApiResponse> + */ + @retrofit2.http.Multipart + @POST("pet/{petId}/uploadImageWithRequiredFile") + Observable uploadFileWithRequiredFile( + @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("file") MultipartBody.Part file, @retrofit2.http.Part("additionalMetadata") String additionalMetadata + ); + } diff --git a/samples/client/petstore/java/retrofit2rx2/docs/PetApi.md b/samples/client/petstore/java/retrofit2rx2/docs/PetApi.md index db7fad1cdb23..cde9eda467e3 100644 --- a/samples/client/petstore/java/retrofit2rx2/docs/PetApi.md +++ b/samples/client/petstore/java/retrofit2rx2/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +File file = new File("null"); // File | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **File**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/api/PetApi.java index 8aee4e9b1ed7..a08da60b41a9 100644 --- a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/api/PetApi.java @@ -123,4 +123,18 @@ Observable uploadFile( @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file") MultipartBody.Part file ); + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return Observable<ModelApiResponse> + */ + @retrofit2.http.Multipart + @POST("pet/{petId}/uploadImageWithRequiredFile") + Observable uploadFileWithRequiredFile( + @retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("file") MultipartBody.Part file, @retrofit2.http.Part("additionalMetadata") String additionalMetadata + ); + } diff --git a/samples/client/petstore/java/vertx/docs/PetApi.md b/samples/client/petstore/java/vertx/docs/PetApi.md index 1040ebe5e726..c22e8f2438b4 100644 --- a/samples/client/petstore/java/vertx/docs/PetApi.md +++ b/samples/client/petstore/java/vertx/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image @@ -436,3 +437,58 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json + +# **uploadFileWithRequiredFile** +> ModelApiResponse uploadFileWithRequiredFile(petId, file, additionalMetadata) + +uploads an image + +### Example +```java +// Import classes: +//import org.openapitools.client.ApiClient; +//import org.openapitools.client.ApiException; +//import org.openapitools.client.Configuration; +//import org.openapitools.client.auth.*; +//import org.openapitools.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 56L; // Long | ID of pet to update +AsyncFile file = new AsyncFile(); // AsyncFile | file to upload +String additionalMetadata = "null"; // String | Additional data to pass to server +try { + ModelApiResponse result = apiInstance.uploadFileWithRequiredFile(petId, file, additionalMetadata); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFileWithRequiredFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **file** | **AsyncFile**| file to upload | [default to null] + **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApi.java index 5696685ffc4e..817a544ea775 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApi.java @@ -27,4 +27,6 @@ public interface PetApi { void uploadFile(Long petId, String additionalMetadata, AsyncFile file, Handler> handler); + void uploadFileWithRequiredFile(Long petId, AsyncFile file, String additionalMetadata, Handler> handler); + } diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApiImpl.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApiImpl.java index 9a75edd9db4a..a33fcb54af63 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApiImpl.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/PetApiImpl.java @@ -312,6 +312,50 @@ public void uploadFile(Long petId, String additionalMetadata, AsyncFile file, Ha // header params MultiMap localVarHeaderParams = MultiMap.caseInsensitiveMultiMap(); + // form params + // TODO: sending files within multipart/form-data is not supported yet (because of vertx web-client) + Map localVarFormParams = new HashMap<>(); + if (additionalMetadata != null) localVarFormParams.put("additionalMetadata", additionalMetadata); +if (file != null) localVarFormParams.put("file", file); + + String[] localVarAccepts = { "application/json" }; + String[] localVarContentTypes = { "multipart/form-data" }; + String[] localVarAuthNames = new String[] { "petstore_auth" }; + TypeReference localVarReturnType = new TypeReference() {}; + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarBody, localVarHeaderParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, localVarReturnType, resultHandler); + } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param resultHandler Asynchronous result handler + */ + public void uploadFileWithRequiredFile(Long petId, AsyncFile file, String additionalMetadata, Handler> resultHandler) { + Object localVarBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + resultHandler.handle(ApiException.fail(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile")); + return; + } + + // verify the required parameter 'file' is set + if (file == null) { + resultHandler.handle(ApiException.fail(400, "Missing the required parameter 'file' when calling uploadFileWithRequiredFile")); + return; + } + + // create path and map variables + String localVarPath = "/pet/{petId}/uploadImageWithRequiredFile".replaceAll("\\{" + "petId" + "\\}", petId.toString()); + + // query params + List localVarQueryParams = new ArrayList<>(); + + // header params + MultiMap localVarHeaderParams = MultiMap.caseInsensitiveMultiMap(); + // form params // TODO: sending files within multipart/form-data is not supported yet (because of vertx web-client) Map localVarFormParams = new HashMap<>(); diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/PetApi.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/PetApi.java index e3fcc4fd683c..ee1053e27946 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/PetApi.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/PetApi.java @@ -201,6 +201,31 @@ public Single rxUploadFile(Long petId, String additionalMetada delegate.uploadFile(petId, additionalMetadata, file, fut); })); } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param resultHandler Asynchronous result handler + */ + public void uploadFileWithRequiredFile(Long petId, AsyncFile file, String additionalMetadata, Handler> resultHandler) { + delegate.uploadFileWithRequiredFile(petId, file, additionalMetadata, resultHandler); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param file file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @return Asynchronous result handler (RxJava Single) + */ + public Single rxUploadFileWithRequiredFile(Long petId, AsyncFile file, String additionalMetadata) { + return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { + delegate.uploadFileWithRequiredFile(petId, file, additionalMetadata, fut); + })); + } public static PetApi newInstance(org.openapitools.client.api.PetApi arg) { return arg != null ? new PetApi(arg) : null; diff --git a/samples/client/petstore/php/OpenAPIClient-php/README.md b/samples/client/petstore/php/OpenAPIClient-php/README.md index 2cfbee0e6872..41d7335deb1f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/README.md +++ b/samples/client/petstore/php/OpenAPIClient-php/README.md @@ -99,6 +99,7 @@ Class | Method | HTTP request | Description *PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet *PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*PetApi* | [**uploadFileWithRequiredFile**](docs/Api/PetApi.md#uploadfilewithrequiredfile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image *StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md index 8af991745359..48a397fd6268 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image # **addPet** @@ -436,3 +437,58 @@ Name | Type | Description | Notes [[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) +# **uploadFileWithRequiredFile** +> \OpenAPI\Client\Model\ApiResponse uploadFileWithRequiredFile($pet_id, $file, $additional_metadata) + +uploads an image + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet to update +$file = "/path/to/file.txt"; // \SplFileObject | file to upload +$additional_metadata = 'additional_metadata_example'; // string | Additional data to pass to server + +try { + $result = $apiInstance->uploadFileWithRequiredFile($pet_id, $file, $additional_metadata); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->uploadFileWithRequiredFile: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **file** | **\SplFileObject****\SplFileObject**| file to upload | + **additional_metadata** | **string**| Additional data to pass to server | [optional] + +### Return type + +[**\OpenAPI\Client\Model\ApiResponse**](../Model/ApiResponse.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index 6326bfb40a2c..a2b2b7aed021 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -2174,6 +2174,316 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file ); } + /** + * Operation uploadFileWithRequiredFile + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\ApiResponse + */ + public function uploadFileWithRequiredFile($pet_id, $file, $additional_metadata = null) + { + list($response) = $this->uploadFileWithRequiredFileWithHttpInfo($pet_id, $file, $additional_metadata); + return $response; + } + + /** + * Operation uploadFileWithRequiredFileWithHttpInfo + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function uploadFileWithRequiredFileWithHttpInfo($pet_id, $file, $additional_metadata = null) + { + $request = $this->uploadFileWithRequiredFileRequest($pet_id, $file, $additional_metadata); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ('\OpenAPI\Client\Model\ApiResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation uploadFileWithRequiredFileAsync + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileWithRequiredFileAsync($pet_id, $file, $additional_metadata = null) + { + return $this->uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $file, $additional_metadata) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation uploadFileWithRequiredFileAsyncWithHttpInfo + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $file, $additional_metadata = null) + { + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $request = $this->uploadFileWithRequiredFileRequest($pet_id, $file, $additional_metadata); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'uploadFileWithRequiredFile' + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function uploadFileWithRequiredFileRequest($pet_id, $file, $additional_metadata = null) + { + // verify the required parameter 'pet_id' is set + if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $pet_id when calling uploadFileWithRequiredFile' + ); + } + // verify the required parameter 'file' is set + if ($file === null || (is_array($file) && count($file) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file when calling uploadFileWithRequiredFile' + ); + } + + $resourcePath = '/pet/{petId}/uploadImageWithRequiredFile'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($pet_id !== null) { + $resourcePath = str_replace( + '{' . 'petId' . '}', + ObjectSerializer::toPathValue($pet_id), + $resourcePath + ); + } + + // form params + if ($additional_metadata !== null) { + $formParams['additionalMetadata'] = ObjectSerializer::toFormValue($additional_metadata); + } + // form params + if ($file !== null) { + $multipart = true; + $formParams['file'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb'); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['multipart/form-data'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // 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); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $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( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Create http client option * diff --git a/samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php index 396865a83009..c24b9f47f573 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php @@ -150,4 +150,14 @@ public function testUpdatePetWithForm() public function testUploadFile() { } + + /** + * Test case for uploadFileWithRequiredFile + * + * uploads an image. + * + */ + public function testUploadFileWithRequiredFile() + { + } } diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index b149e113c7e2..98f08b8e3423 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -93,6 +93,7 @@ Class | Method | HTTP request | Description *Petstore::PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet *Petstore::PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data *Petstore::PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*Petstore::PetApi* | [**upload_file_with_required_file**](docs/PetApi.md#upload_file_with_required_file) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image *Petstore::StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *Petstore::StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *Petstore::StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index d64b1b8dc274..aecfde29f2c3 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet [**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data [**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image # **add_pet** @@ -418,3 +419,57 @@ Name | Type | Description | Notes +# **upload_file_with_required_file** +> ApiResponse upload_file_with_required_file(pet_id, file, opts) + +uploads an image + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +pet_id = 56 # Integer | ID of pet to update +file = File.new('/path/to/file') # File | file to upload +opts = { + additional_metadata: 'additional_metadata_example' # String | Additional data to pass to server +} + +begin + #uploads an image + result = api_instance.upload_file_with_required_file(pet_id, file, opts) + p result +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->upload_file_with_required_file: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet to update | + **file** | **File**| file to upload | + **additional_metadata** | **String**| Additional data to pass to server | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + + diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 0f5a698843c2..21d536302d15 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -438,5 +438,67 @@ def upload_file_with_http_info(pet_id, opts = {}) end return data, status_code, headers end + # uploads an image + # @param pet_id ID of pet to update + # @param file file to upload + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @return [ApiResponse] + def upload_file_with_required_file(pet_id, file, opts = {}) + data, _status_code, _headers = upload_file_with_required_file_with_http_info(pet_id, file, opts) + data + end + + # uploads an image + # @param pet_id ID of pet to update + # @param file file to upload + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @return [Array<(ApiResponse, Fixnum, Hash)>] ApiResponse data, response status code and response headers + def upload_file_with_required_file_with_http_info(pet_id, file, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.upload_file_with_required_file ...' + end + # verify the required parameter 'pet_id' is set + if @api_client.config.client_side_validation && pet_id.nil? + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file_with_required_file" + end + # verify the required parameter 'file' is set + if @api_client.config.client_side_validation && file.nil? + fail ArgumentError, "Missing the required parameter 'file' when calling PetApi.upload_file_with_required_file" + end + # resource path + local_var_path = '/pet/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + + # form parameters + form_params = {} + form_params['file'] = file + form_params['additionalMetadata'] = opts[:'additional_metadata'] if !opts[:'additional_metadata'].nil? + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'ApiResponse') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#upload_file_with_required_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md index 04e36d807a2a..e4d699fe972a 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md @@ -84,6 +84,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | *FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | +*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 *FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters @@ -98,6 +99,7 @@ Class | Method | HTTP request | Description *PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet *PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*PetApi* | [**uploadFileWithRequiredFile**](docs/Api/PetApi.md#uploadfilewithrequiredfile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image *StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md index 45a911754739..c8559d8ebc72 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md @@ -8,6 +8,7 @@ Method | HTTP request | Description [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | +[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters @@ -211,6 +212,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) +# **testBodyWithQueryParams** +> testBodyWithQueryParams($query, $user) + + + +### Example +```php +testBodyWithQueryParams($query, $user); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testBodyWithQueryParams: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query** | **string**| | + **user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **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) + # **testClientModel** > \OpenAPI\Client\Model\Client testClientModel($client) diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md index 8af991745359..48a397fd6268 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /pet/{petId}/uploadImageWithRequiredFile | uploads an image # **addPet** @@ -436,3 +437,58 @@ Name | Type | Description | Notes [[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) +# **uploadFileWithRequiredFile** +> \OpenAPI\Client\Model\ApiResponse uploadFileWithRequiredFile($pet_id, $file, $additional_metadata) + +uploads an image + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet to update +$file = "/path/to/file.txt"; // \SplFileObject | file to upload +$additional_metadata = 'additional_metadata_example'; // string | Additional data to pass to server + +try { + $result = $apiInstance->uploadFileWithRequiredFile($pet_id, $file, $additional_metadata); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->uploadFileWithRequiredFile: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **file** | **\SplFileObject****\SplFileObject**| file to upload | + **additional_metadata** | **string**| Additional data to pass to server | [optional] + +### Return type + +[**\OpenAPI\Client\Model\ApiResponse**](../Model/ApiResponse.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index 9ef029ccea5b..d8e2182d8685 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -1151,6 +1151,236 @@ protected function fakeOuterStringSerializeRequest($body = null) ); } + /** + * Operation testBodyWithQueryParams + * + * @param string $query query (required) + * @param \OpenAPI\Client\Model\User $user user (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testBodyWithQueryParams($query, $user) + { + $this->testBodyWithQueryParamsWithHttpInfo($query, $user); + } + + /** + * Operation testBodyWithQueryParamsWithHttpInfo + * + * @param string $query (required) + * @param \OpenAPI\Client\Model\User $user (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 testBodyWithQueryParamsWithHttpInfo($query, $user) + { + $request = $this->testBodyWithQueryParamsRequest($query, $user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation testBodyWithQueryParamsAsync + * + * + * + * @param string $query (required) + * @param \OpenAPI\Client\Model\User $user (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testBodyWithQueryParamsAsync($query, $user) + { + return $this->testBodyWithQueryParamsAsyncWithHttpInfo($query, $user) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testBodyWithQueryParamsAsyncWithHttpInfo + * + * + * + * @param string $query (required) + * @param \OpenAPI\Client\Model\User $user (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testBodyWithQueryParamsAsyncWithHttpInfo($query, $user) + { + $returnType = ''; + $request = $this->testBodyWithQueryParamsRequest($query, $user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testBodyWithQueryParams' + * + * @param string $query (required) + * @param \OpenAPI\Client\Model\User $user (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testBodyWithQueryParamsRequest($query, $user) + { + // verify the required parameter 'query' is set + if ($query === null || (is_array($query) && count($query) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $query when calling testBodyWithQueryParams' + ); + } + // verify the required parameter 'user' is set + if ($user === null || (is_array($user) && count($user) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $user when calling testBodyWithQueryParams' + ); + } + + $resourcePath = '/fake/body-with-query-params'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + if ($query !== null) { + $queryParams['query'] = ObjectSerializer::toQueryValue($query); + } + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // 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 testClientModel * diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index 6326bfb40a2c..07652826b2f3 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -756,7 +756,7 @@ protected function findPetsByStatusRequest($status) // query params if (is_array($status)) { - $status = ObjectSerializer::serializeCollection($status, 'csv', true); + $status = ObjectSerializer::serializeCollection($status, 'multi', true); } if ($status !== null) { $queryParams['status'] = ObjectSerializer::toQueryValue($status); @@ -1040,7 +1040,7 @@ protected function findPetsByTagsRequest($tags) // query params if (is_array($tags)) { - $tags = ObjectSerializer::serializeCollection($tags, 'csv', true); + $tags = ObjectSerializer::serializeCollection($tags, 'multi', true); } if ($tags !== null) { $queryParams['tags'] = ObjectSerializer::toQueryValue($tags); @@ -2174,6 +2174,316 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file ); } + /** + * Operation uploadFileWithRequiredFile + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\ApiResponse + */ + public function uploadFileWithRequiredFile($pet_id, $file, $additional_metadata = null) + { + list($response) = $this->uploadFileWithRequiredFileWithHttpInfo($pet_id, $file, $additional_metadata); + return $response; + } + + /** + * Operation uploadFileWithRequiredFileWithHttpInfo + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function uploadFileWithRequiredFileWithHttpInfo($pet_id, $file, $additional_metadata = null) + { + $request = $this->uploadFileWithRequiredFileRequest($pet_id, $file, $additional_metadata); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ('\OpenAPI\Client\Model\ApiResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation uploadFileWithRequiredFileAsync + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileWithRequiredFileAsync($pet_id, $file, $additional_metadata = null) + { + return $this->uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $file, $additional_metadata) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation uploadFileWithRequiredFileAsyncWithHttpInfo + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $file, $additional_metadata = null) + { + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $request = $this->uploadFileWithRequiredFileRequest($pet_id, $file, $additional_metadata); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'uploadFileWithRequiredFile' + * + * @param int $pet_id ID of pet to update (required) + * @param \SplFileObject $file file to upload (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function uploadFileWithRequiredFileRequest($pet_id, $file, $additional_metadata = null) + { + // verify the required parameter 'pet_id' is set + if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $pet_id when calling uploadFileWithRequiredFile' + ); + } + // verify the required parameter 'file' is set + if ($file === null || (is_array($file) && count($file) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file when calling uploadFileWithRequiredFile' + ); + } + + $resourcePath = '/pet/{petId}/uploadImageWithRequiredFile'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($pet_id !== null) { + $resourcePath = str_replace( + '{' . 'petId' . '}', + ObjectSerializer::toPathValue($pet_id), + $resourcePath + ); + } + + // form params + if ($additional_metadata !== null) { + $formParams['additionalMetadata'] = ObjectSerializer::toFormValue($additional_metadata); + } + // form params + if ($file !== null) { + $multipart = true; + $formParams['file'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb'); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['multipart/form-data'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // 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); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $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( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Create http client option * diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php index 0de20e6ffe21..4d8c1678b2a8 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php @@ -111,6 +111,16 @@ public function testFakeOuterStringSerialize() { } + /** + * Test case for testBodyWithQueryParams + * + * . + * + */ + public function testTestBodyWithQueryParams() + { + } + /** * Test case for testClientModel * diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php index 396865a83009..c24b9f47f573 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php @@ -150,4 +150,14 @@ public function testUpdatePetWithForm() public function testUploadFile() { } + + /** + * Test case for uploadFileWithRequiredFile + * + * uploads an image. + * + */ + public function testUploadFileWithRequiredFile() + { + } } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/api/PetApi.java index b2d413186224..f134cb8ce5eb 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/api/PetApi.java @@ -134,9 +134,22 @@ public interface PetApi { @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) - @ApiOperation(value = "uploads an image", tags={ "pet" }) + @ApiOperation(value = "uploads an image", tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment fileDetail); + + /** + * uploads an image + * + */ + @POST + @Path("/pet/{petId}/uploadImageWithRequiredFile") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + public ModelApiResponse uploadFileWithRequiredFile(@PathParam("petId") Long petId, @Multipart(value = "file" ) Attachment fileDetail, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata); } diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java index 5b48303cc587..ca3e7093ff1e 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java @@ -111,5 +111,15 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Attac return null; } + /** + * uploads an image + * + */ + public ModelApiResponse uploadFileWithRequiredFile(Long petId, Attachment fileDetail, String additionalMetadata) { + // TODO: Implement... + + return null; + } + } diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/AnotherFakeApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/AnotherFakeApiTest.java index 79ec92b357f1..210ea87532bd 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/AnotherFakeApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/AnotherFakeApiTest.java @@ -1,12 +1,12 @@ /** - * Swagger Petstore + * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,7 @@ /** - * Swagger Petstore + * OpenAPI Petstore * *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeApiTest.java index 56a239eebf86..e3e9186319e8 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeApiTest.java @@ -1,12 +1,12 @@ /** - * Swagger Petstore + * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,7 +54,7 @@ /** - * Swagger Petstore + * OpenAPI Petstore * *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * @@ -84,8 +84,8 @@ public void setup() { */ @Test public void fakeOuterBooleanSerializeTest() { - Boolean booleanPostBody = null; - //Boolean response = api.fakeOuterBooleanSerialize(booleanPostBody); + Boolean body = null; + //Boolean response = api.fakeOuterBooleanSerialize(body); //assertNotNull(response); // TODO: test validations @@ -231,7 +231,7 @@ public void testEnumParametersTest() { */ @Test public void testInlineAdditionalPropertiesTest() { - String requestBody = null; + Map requestBody = null; //api.testInlineAdditionalProperties(requestBody); // TODO: test validations diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeClassnameTags123ApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeClassnameTags123ApiTest.java index c798a9e7b716..63a8e61733a0 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeClassnameTags123ApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/FakeClassnameTags123ApiTest.java @@ -1,12 +1,12 @@ /** - * Swagger Petstore + * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,7 @@ /** - * Swagger Petstore + * OpenAPI Petstore * *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/PetApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/PetApiTest.java index 8dd432fed9c4..8b0f3f9560f3 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/PetApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/PetApiTest.java @@ -1,12 +1,12 @@ /** - * Swagger Petstore + * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,7 +49,7 @@ /** - * Swagger Petstore + * OpenAPI Petstore * *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * @@ -212,4 +212,22 @@ public void uploadFileTest() { } + /** + * uploads an image + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileWithRequiredFileTest() { + Long petId = null; + org.apache.cxf.jaxrs.ext.multipart.Attachment file = null; + String additionalMetadata = null; + //ModelApiResponse response = api.uploadFileWithRequiredFile(petId, file, additionalMetadata); + //assertNotNull(response); + // TODO: test validations + + + } + } diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/StoreApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/StoreApiTest.java index eebc070db508..c2d3a5783686 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/StoreApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/StoreApiTest.java @@ -1,12 +1,12 @@ /** - * Swagger Petstore + * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -48,7 +48,7 @@ /** - * Swagger Petstore + * OpenAPI Petstore * *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/UserApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/UserApiTest.java index 27e54fe390a5..147227059eac 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/UserApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/org/openapitools/api/UserApiTest.java @@ -1,12 +1,12 @@ /** - * Swagger Petstore + * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -48,7 +48,7 @@ /** - * Swagger Petstore + * OpenAPI Petstore * *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * diff --git a/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApi.java index c915d919bab9..fd404b7bb7a7 100644 --- a/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApi.java @@ -208,4 +208,25 @@ public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true throws NotFoundException { return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail,securityContext); } + @POST + @Path("/{petId}/uploadImageWithRequiredFile") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + public Response uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId +, + @FormDataParam("file") InputStream fileInputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail +,@ApiParam(value = "Additional data to pass to server", defaultValue="null")@FormDataParam("additionalMetadata") String additionalMetadata +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.uploadFileWithRequiredFile(petId,fileInputStream, fileDetail,additionalMetadata,securityContext); + } } diff --git a/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApiService.java b/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApiService.java index ebd89ee5c3a0..47299bb5daf9 100644 --- a/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApiService.java +++ b/samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApiService.java @@ -27,4 +27,5 @@ public abstract class PetApiService { public abstract Response updatePet(Pet pet,SecurityContext securityContext) throws NotFoundException; public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException; public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; + public abstract Response uploadFileWithRequiredFile(Long petId,InputStream fileInputStream, FormDataContentDisposition fileDetail,String additionalMetadata,SecurityContext securityContext) throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs-datelib-j8/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-datelib-j8/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java index 366b2e4e1337..b282f8833f9b 100644 --- a/samples/server/petstore/jaxrs-datelib-j8/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-datelib-j8/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java @@ -59,4 +59,9 @@ public Response uploadFile(Long petId, String additionalMetadata, InputStream fi // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + @Override + public Response uploadFileWithRequiredFile(Long petId, InputStream fileInputStream, FormDataContentDisposition fileDetail, String additionalMetadata, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } } diff --git a/samples/server/petstore/jaxrs-spec-interface/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs-spec-interface/src/gen/java/org/openapitools/api/PetApi.java index ea35664ca3c2..1507e6e229b0 100644 --- a/samples/server/petstore/jaxrs-spec-interface/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs-spec-interface/src/gen/java/org/openapitools/api/PetApi.java @@ -118,9 +118,24 @@ public interface PetApi { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet" }) + }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) ModelApiResponse uploadFile(@PathParam("petId") @ApiParam("ID of pet to update") Long petId,@FormParam(value = "additionalMetadata") String additionalMetadata, @FormParam(value = "file") InputStream fileInputStream, @FormParam(value = "file") Attachment fileDetail); + + @POST + @Path("/{petId}/uploadImageWithRequiredFile") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", notes = "", authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + ModelApiResponse uploadFileWithRequiredFile(@PathParam("petId") @ApiParam("ID of pet to update") Long petId, @FormParam(value = "file") InputStream fileInputStream, + @FormParam(value = "file") Attachment fileDetail,@FormParam(value = "additionalMetadata") String additionalMetadata); } diff --git a/samples/server/petstore/jaxrs-spec-interface/src/main/openapi/openapi.yaml b/samples/server/petstore/jaxrs-spec-interface/src/main/openapi/openapi.yaml index 5a18f6c71c33..fa165f2bff1b 100644 --- a/samples/server/petstore/jaxrs-spec-interface/src/main/openapi/openapi.yaml +++ b/samples/server/petstore/jaxrs-spec-interface/src/main/openapi/openapi.yaml @@ -298,6 +298,48 @@ paths: - pet x-tags: - tag: pet + /pet/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + required: + - file + required: true + responses: + 200: + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image + tags: + - pet + x-tags: + - tag: pet /store/inventory: get: description: Returns a map of status codes to quantities diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/org/openapitools/api/PetApi.java index ec2658d28ced..7f06dbe8d0c6 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/org/openapitools/api/PetApi.java @@ -139,7 +139,7 @@ public Response updatePetWithForm(@PathParam("petId") @ApiParam("ID of pet that @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet" }) + }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @@ -147,4 +147,22 @@ public Response uploadFile(@PathParam("petId") @ApiParam("ID of pet to update") @FormParam(value = "file") Attachment fileDetail) { return Response.ok().entity("magic!").build(); } + + @POST + @Path("/{petId}/uploadImageWithRequiredFile") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) + }) + public Response uploadFileWithRequiredFile(@PathParam("petId") @ApiParam("ID of pet to update") Long petId, @FormParam(value = "file") InputStream fileInputStream, + @FormParam(value = "file") Attachment fileDetail,@FormParam(value = "additionalMetadata") String additionalMetadata) { + return Response.ok().entity("magic!").build(); + } } diff --git a/samples/server/petstore/jaxrs-spec/src/main/openapi/openapi.yaml b/samples/server/petstore/jaxrs-spec/src/main/openapi/openapi.yaml index 5a18f6c71c33..fa165f2bff1b 100644 --- a/samples/server/petstore/jaxrs-spec/src/main/openapi/openapi.yaml +++ b/samples/server/petstore/jaxrs-spec/src/main/openapi/openapi.yaml @@ -298,6 +298,48 @@ paths: - pet x-tags: - tag: pet + /pet/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + required: + - file + required: true + responses: + 200: + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image + tags: + - pet + x-tags: + - tag: pet /store/inventory: get: description: Returns a map of status codes to quantities diff --git a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java index 45e52ad46631..a15e47db2b6e 100644 --- a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java @@ -177,7 +177,7 @@ public Response updatePetWithForm( @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet" }) + }, tags={ "pet", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) public Response uploadFile( @@ -189,4 +189,25 @@ public Response uploadFile( throws NotFoundException { return delegate.uploadFile(petId,additionalMetadata,inputStream, fileDetail,securityContext); } + @POST + + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet" }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + public Response uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId, + @FormDataParam("file") InputStream inputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail, + @FormDataParam("additionalMetadata") String additionalMetadata, + @Context SecurityContext securityContext) + throws NotFoundException { + return delegate.uploadFileWithRequiredFile(petId,inputStream, fileDetail,additionalMetadata,securityContext); + } } diff --git a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApiService.java b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApiService.java index 9af313fd74a1..ce8c271d31a8 100644 --- a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApiService.java @@ -38,4 +38,6 @@ public abstract Response updatePetWithForm(Long petId,String name,String status, throws NotFoundException; public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; + public abstract Response uploadFileWithRequiredFile(Long petId,InputStream fileInputStream, FormDataContentDisposition fileDetail,String additionalMetadata,SecurityContext securityContext) + throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs/jersey1-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs/jersey1-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java index 4531f4b4b697..ade99c7c99ab 100644 --- a/samples/server/petstore/jaxrs/jersey1-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/jersey1-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java @@ -70,4 +70,10 @@ public Response uploadFile(Long petId, String additionalMetadata, InputStream fi // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + @Override + public Response uploadFileWithRequiredFile(Long petId, InputStream fileInputStream, FormDataContentDisposition fileDetail, String additionalMetadata, SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } } diff --git a/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApi.java index 4d6288f5ef5b..8b130f30f0e5 100644 --- a/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApi.java @@ -177,7 +177,7 @@ public Response updatePetWithForm( @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet" }) + }, tags={ "pet", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) public Response uploadFile( @@ -189,4 +189,25 @@ public Response uploadFile( throws NotFoundException { return delegate.uploadFile(petId,additionalMetadata,inputStream, fileDetail,securityContext); } + @POST + @Path("/{petId}/uploadImageWithRequiredFile") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet" }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + public Response uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId, + @FormDataParam("file") InputStream inputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail, + @FormDataParam("additionalMetadata") String additionalMetadata, + @Context SecurityContext securityContext) + throws NotFoundException { + return delegate.uploadFileWithRequiredFile(petId,inputStream, fileDetail,additionalMetadata,securityContext); + } } diff --git a/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApiService.java b/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApiService.java index 9af313fd74a1..ce8c271d31a8 100644 --- a/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/jersey1/src/gen/java/org/openapitools/api/PetApiService.java @@ -38,4 +38,6 @@ public abstract Response updatePetWithForm(Long petId,String name,String status, throws NotFoundException; public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; + public abstract Response uploadFileWithRequiredFile(Long petId,InputStream fileInputStream, FormDataContentDisposition fileDetail,String additionalMetadata,SecurityContext securityContext) + throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs/jersey1/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs/jersey1/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java index 4531f4b4b697..ade99c7c99ab 100644 --- a/samples/server/petstore/jaxrs/jersey1/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/jersey1/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java @@ -70,4 +70,10 @@ public Response uploadFile(Long petId, String additionalMetadata, InputStream fi // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + @Override + public Response uploadFileWithRequiredFile(Long petId, InputStream fileInputStream, FormDataContentDisposition fileDetail, String additionalMetadata, SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } } diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java index 03aafa4190cb..45e26077a753 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java @@ -208,4 +208,25 @@ public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true throws NotFoundException { return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail,securityContext); } + @POST + + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + public Response uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId +, + @FormDataParam("file") InputStream fileInputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail +,@ApiParam(value = "Additional data to pass to server", defaultValue="null")@FormDataParam("additionalMetadata") String additionalMetadata +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.uploadFileWithRequiredFile(petId,fileInputStream, fileDetail,additionalMetadata,securityContext); + } } diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApiService.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApiService.java index ebd89ee5c3a0..47299bb5daf9 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApiService.java @@ -27,4 +27,5 @@ public abstract class PetApiService { public abstract Response updatePet(Pet pet,SecurityContext securityContext) throws NotFoundException; public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException; public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; + public abstract Response uploadFileWithRequiredFile(Long petId,InputStream fileInputStream, FormDataContentDisposition fileDetail,String additionalMetadata,SecurityContext securityContext) throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java index 366b2e4e1337..b282f8833f9b 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java @@ -59,4 +59,9 @@ public Response uploadFile(Long petId, String additionalMetadata, InputStream fi // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + @Override + public Response uploadFileWithRequiredFile(Long petId, InputStream fileInputStream, FormDataContentDisposition fileDetail, String additionalMetadata, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } } diff --git a/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApi.java index c915d919bab9..fd404b7bb7a7 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApi.java @@ -208,4 +208,25 @@ public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true throws NotFoundException { return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail,securityContext); } + @POST + @Path("/{petId}/uploadImageWithRequiredFile") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + public Response uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId +, + @FormDataParam("file") InputStream fileInputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail +,@ApiParam(value = "Additional data to pass to server", defaultValue="null")@FormDataParam("additionalMetadata") String additionalMetadata +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.uploadFileWithRequiredFile(petId,fileInputStream, fileDetail,additionalMetadata,securityContext); + } } diff --git a/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApiService.java b/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApiService.java index ebd89ee5c3a0..47299bb5daf9 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApiService.java @@ -27,4 +27,5 @@ public abstract class PetApiService { public abstract Response updatePet(Pet pet,SecurityContext securityContext) throws NotFoundException; public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException; public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; + public abstract Response uploadFileWithRequiredFile(Long petId,InputStream fileInputStream, FormDataContentDisposition fileDetail,String additionalMetadata,SecurityContext securityContext) throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs/jersey2/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs/jersey2/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java index 366b2e4e1337..b282f8833f9b 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/jersey2/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java @@ -59,4 +59,9 @@ public Response uploadFile(Long petId, String additionalMetadata, InputStream fi // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + @Override + public Response uploadFileWithRequiredFile(Long petId, InputStream fileInputStream, FormDataContentDisposition fileDetail, String additionalMetadata, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } } diff --git a/samples/server/petstore/php-lumen/lib/app/Http/Controllers/PetApi.php b/samples/server/petstore/php-lumen/lib/app/Http/Controllers/PetApi.php index 71ef5b76b169..ad7097f7db43 100644 --- a/samples/server/petstore/php-lumen/lib/app/Http/Controllers/PetApi.php +++ b/samples/server/petstore/php-lumen/lib/app/Http/Controllers/PetApi.php @@ -202,4 +202,24 @@ public function uploadFile($pet_id) return response('How about implementing uploadFile as a post method ?'); } + /** + * Operation uploadFileWithRequiredFile + * + * uploads an image. + * + * @param int $pet_id ID of pet to update (required) + * + * @return Http response + */ + public function uploadFileWithRequiredFile($pet_id) + { + $input = Request::all(); + + //path params validation + + + //not path params validation + + return response('How about implementing uploadFileWithRequiredFile as a post method ?'); + } } diff --git a/samples/server/petstore/php-lumen/lib/app/Http/routes.php b/samples/server/petstore/php-lumen/lib/app/Http/routes.php index 2875b96fcb58..e2dfa91a7e31 100644 --- a/samples/server/petstore/php-lumen/lib/app/Http/routes.php +++ b/samples/server/petstore/php-lumen/lib/app/Http/routes.php @@ -161,6 +161,13 @@ * Output-Formats: [application/json] */ $app->post('/v2/pet/{petId}/uploadImage', 'PetApi@uploadFile'); +/** + * post uploadFileWithRequiredFile + * Summary: uploads an image + * Notes: + * Output-Formats: [application/json] + */ +$app->post('/v2/pet/{petId}/uploadImageWithRequiredFile', 'PetApi@uploadFileWithRequiredFile'); /** * get getInventory * Summary: Returns pet inventories by status diff --git a/samples/server/petstore/php-slim/index.php b/samples/server/petstore/php-slim/index.php index 0800a1087742..60eebdf19580 100644 --- a/samples/server/petstore/php-slim/index.php +++ b/samples/server/petstore/php-slim/index.php @@ -293,6 +293,21 @@ }); +/** + * POST uploadFileWithRequiredFile + * Summary: uploads an image + * Notes: + * Output-Formats: [application/json] + */ +$app->POST('/v2/pet/{petId}/uploadImageWithRequiredFile', function($request, $response, $args) { + $petId = $args['petId']; + $additionalMetadata = $request->getParsedBodyParam('additionalMetadata'); + $file = (key_exists('file', $request->getUploadedFiles())) ? $request->getUploadedFiles()['file'] : null; + $response->write('How about implementing uploadFileWithRequiredFile as a POST method ?'); + return $response; +}); + + /** * GET getInventory * Summary: Returns pet inventories by status diff --git a/samples/server/petstore/php-ze-ph/application/config/path_handler.yml b/samples/server/petstore/php-ze-ph/application/config/path_handler.yml index 4b1717af8e38..fc5c123eff14 100644 --- a/samples/server/petstore/php-ze-ph/application/config/path_handler.yml +++ b/samples/server/petstore/php-ze-ph/application/config/path_handler.yml @@ -39,6 +39,7 @@ Articus\PathHandler\Router\FastRouteAnnotation: - App\Handler\PetFindByTags - App\Handler\PetPetId - App\Handler\PetPetIdUploadImage + - App\Handler\PetPetIdUploadImageWithRequiredFile - App\Handler\StoreInventory - App\Handler\StoreOrder - App\Handler\StoreOrderOrderId @@ -65,6 +66,7 @@ Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory: App\Handler\PetFindByTags: [] App\Handler\PetPetId: [] App\Handler\PetPetIdUploadImage: [] + App\Handler\PetPetIdUploadImageWithRequiredFile: [] App\Handler\StoreInventory: [] App\Handler\StoreOrder: [] App\Handler\StoreOrderOrderId: [] diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/PetPetIdUploadImageWithRequiredFile.php b/samples/server/petstore/php-ze-ph/src/App/Handler/PetPetIdUploadImageWithRequiredFile.php new file mode 100644 index 000000000000..2c475050d683 --- /dev/null +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/PetPetIdUploadImageWithRequiredFile.php @@ -0,0 +1,33 @@ +> uploadFile(@ApiParam } + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default CompletableFuture> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + return CompletableFuture.supplyAsync(()-> { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + }, Runnable::run); + + } + } diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java index 9559bbf098d5..155da0b9f179 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java @@ -219,4 +219,30 @@ default ResponseEntity uploadFile(@ApiParam(value = "ID of pet } + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java index e9dc9c37ccef..b207d39f84cd 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java @@ -143,4 +143,19 @@ public interface PetApi { method = RequestMethod.POST) ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata); + } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java index 20ea8d651a4f..722ed3221e84 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java @@ -109,4 +109,15 @@ public ResponseEntity uploadFile(@ApiParam(value = "ID of pet } + public ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java index e9dc9c37ccef..b207d39f84cd 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java @@ -143,4 +143,19 @@ public interface PetApi { method = RequestMethod.POST) ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata); + } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApiController.java index b01cdf874b30..80fb91e825e9 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApiController.java @@ -109,4 +109,15 @@ public ResponseEntity uploadFile(@ApiParam(value = "ID of pet } + public ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java index 8cab0b706a9f..a9cd158432a0 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java @@ -163,4 +163,21 @@ default ResponseEntity uploadFile(@ApiParam(value = "ID of pet return getDelegate().uploadFile(petId, additionalMetadata, file); } + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + return getDelegate().uploadFileWithRequiredFile(petId, file, additionalMetadata); + } + } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java index 88a778effd80..a5b1f721cd10 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -138,4 +138,22 @@ default ResponseEntity uploadFile( Long petId, } + /** + * @see PetApi#uploadFileWithRequiredFile + */ + default ResponseEntity uploadFileWithRequiredFile( Long petId, + MultipartFile file, + String additionalMetadata) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java index e9dc9c37ccef..b207d39f84cd 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java @@ -143,4 +143,19 @@ public interface PetApi { method = RequestMethod.POST) ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata); + } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java index 4e56a5931446..b39c37857f0a 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java @@ -63,4 +63,8 @@ public ResponseEntity uploadFile(@ApiParam(value = "ID of pet return delegate.uploadFile(petId, additionalMetadata, file); } + public ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + return delegate.uploadFileWithRequiredFile(petId, file, additionalMetadata); + } + } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java index 13f6acf44c70..0251e06b3c3a 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -62,4 +62,11 @@ ResponseEntity uploadFile( Long petId, String additionalMetadata, MultipartFile file); + /** + * @see PetApi#uploadFileWithRequiredFile + */ + ResponseEntity uploadFileWithRequiredFile( Long petId, + MultipartFile file, + String additionalMetadata); + } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java index e15f482431fb..11e98f37aead 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java @@ -236,4 +236,32 @@ default ResponseEntity uploadFile(@ApiParam(value = "ID of pet } + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiImplicitParams({ + }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java index e747a234faa5..a483be41ccdf 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java @@ -224,4 +224,30 @@ default ResponseEntity> uploadFile(@ApiParam(value = "ID } + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default ResponseEntity> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, ServerWebExchange exchange) { + Mono result = Mono.empty(); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + result = ApiUtil.getExampleResponse(exchange, "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}") + .then(Mono.empty()); + break; + } + } + return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body(result); + + } + } diff --git a/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml index b9ad008e6b3c..b09398ca5e11 100644 --- a/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml @@ -310,6 +310,50 @@ paths: x-accepts: application/json x-tags: - tag: pet + /pet/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + required: + - file + required: true + responses: + 200: + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image + tags: + - pet + x-contentType: multipart/form-data + x-accepts: application/json + x-tags: + - tag: pet /store/inventory: get: description: Returns a map of status codes to quantities diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java index aeea6e160aaf..65ffc288c478 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java @@ -219,4 +219,30 @@ default ResponseEntity uploadFile(@ApiParam(value = "ID of pet } + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + } diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java index 9559bbf098d5..155da0b9f179 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java @@ -219,4 +219,30 @@ default ResponseEntity uploadFile(@ApiParam(value = "ID of pet } + + @ApiOperation(value = "uploads an image", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + }