Skip to content

Commit e9cb42e

Browse files
committed
Adds unit test
1 parent c81808b commit e9cb42e

File tree

8 files changed

+1096
-3
lines changed

8 files changed

+1096
-3
lines changed

modules/openapi-generator/src/test/resources/3_0/php/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,37 @@ paths:
311311
description: file to upload
312312
type: string
313313
format: binary
314+
'/pet/{petId}/uploadImageFullFormData':
315+
post:
316+
tags:
317+
- pet
318+
summary: uploads an image attached to a Pet object as formdata
319+
description: ''
320+
operationId: uploadImageFullFormData
321+
parameters:
322+
- name: petId
323+
in: path
324+
description: ID of pet to update
325+
required: true
326+
schema:
327+
type: integer
328+
format: int64
329+
responses:
330+
'200':
331+
description: successful operation
332+
content:
333+
application/json:
334+
schema:
335+
$ref: '#/components/schemas/ApiResponse'
336+
security:
337+
- petstore_auth:
338+
- 'write:pets'
339+
- 'read:pets'
340+
requestBody:
341+
content:
342+
multipart/form-data:
343+
schema:
344+
$ref: '#/components/schemas/PetWithFile'
314345
/store/inventory:
315346
get:
316347
tags:
@@ -1566,6 +1597,54 @@ components:
15661597
- sold
15671598
xml:
15681599
name: Pet
1600+
PetWithFile:
1601+
type: object
1602+
required:
1603+
- name
1604+
- photoUrls
1605+
properties:
1606+
id:
1607+
type: integer
1608+
format: int64
1609+
x-is-unique: true
1610+
category:
1611+
$ref: '#/components/schemas/Category'
1612+
name:
1613+
type: string
1614+
example: doggie
1615+
photoUrls:
1616+
type: array
1617+
xml:
1618+
name: photoUrl
1619+
wrapped: true
1620+
items:
1621+
type: string
1622+
uniqueItems: true
1623+
tags:
1624+
type: array
1625+
xml:
1626+
name: tag
1627+
wrapped: true
1628+
items:
1629+
$ref: '#/components/schemas/Tag'
1630+
status:
1631+
type: string
1632+
description: pet status in the store
1633+
enum:
1634+
- available
1635+
- pending
1636+
- sold
1637+
file:
1638+
description: file to upload
1639+
type: string
1640+
format: binary
1641+
multiple_files:
1642+
type: array
1643+
items:
1644+
type: string
1645+
format: binary
1646+
xml:
1647+
name: PetWithFile
15691648
ApiResponse:
15701649
type: object
15711650
properties:

samples/client/petstore/php/OpenAPIClient-php/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Class | Method | HTTP request | Description
107107
*PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
108108
*PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
109109
*PetApi* | [**uploadFileWithRequiredFile**](docs/Api/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
110+
*PetApi* | [**uploadImageFullFormData**](docs/Api/PetApi.md#uploadimagefullformdata) | **POST** /pet/{petId}/uploadImageFullFormData | uploads an image attached to a Pet object as formdata
110111
*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
111112
*StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
112113
*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID

samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati
1313
| [**updatePetWithForm()**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data |
1414
| [**uploadFile()**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image |
1515
| [**uploadFileWithRequiredFile()**](PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) |
16+
| [**uploadImageFullFormData()**](PetApi.md#uploadImageFullFormData) | **POST** /pet/{petId}/uploadImageFullFormData | uploads an image attached to a Pet object as formdata |
1617

1718

1819
## `addPet()`
@@ -612,3 +613,79 @@ try {
612613
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
613614
[[Back to Model list]](../../README.md#models)
614615
[[Back to README]](../../README.md)
616+
617+
## `uploadImageFullFormData()`
618+
619+
```php
620+
uploadImageFullFormData($pet_id, $name, $photo_urls, $id, $category, $tags, $status, $file, $multiple_files): \OpenAPI\Client\Model\ApiResponse
621+
```
622+
623+
uploads an image attached to a Pet object as formdata
624+
625+
626+
627+
### Example
628+
629+
```php
630+
<?php
631+
require_once(__DIR__ . '/vendor/autoload.php');
632+
633+
634+
// Configure OAuth2 access token for authorization: petstore_auth
635+
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
636+
637+
638+
$apiInstance = new OpenAPI\Client\Api\PetApi(
639+
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
640+
// This is optional, `GuzzleHttp\Client` will be used as default.
641+
new GuzzleHttp\Client(),
642+
$config
643+
);
644+
$pet_id = 56; // int | ID of pet to update
645+
$name = 'name_example'; // string
646+
$photo_urls = array('photo_urls_example'); // string[]
647+
$id = 56; // int
648+
$category = new \OpenAPI\Client\Model\Category(); // \OpenAPI\Client\Model\Category
649+
$tags = array(new \OpenAPI\Client\Model\\OpenAPI\Client\Model\Tag()); // \OpenAPI\Client\Model\Tag[]
650+
$status = 'status_example'; // string | pet status in the store
651+
$file = '/path/to/file.txt'; // \SplFileObject | file to upload
652+
$multiple_files = array('/path/to/file.txt'); // \SplFileObject[]
653+
654+
try {
655+
$result = $apiInstance->uploadImageFullFormData($pet_id, $name, $photo_urls, $id, $category, $tags, $status, $file, $multiple_files);
656+
print_r($result);
657+
} catch (Exception $e) {
658+
echo 'Exception when calling PetApi->uploadImageFullFormData: ', $e->getMessage(), PHP_EOL;
659+
}
660+
```
661+
662+
### Parameters
663+
664+
| Name | Type | Description | Notes |
665+
| ------------- | ------------- | ------------- | ------------- |
666+
| **pet_id** | **int**| ID of pet to update | |
667+
| **name** | **string**| | |
668+
| **photo_urls** | [**string[]**](../Model/string.md)| | |
669+
| **id** | **int**| | [optional] |
670+
| **category** | [**\OpenAPI\Client\Model\Category**](../Model/Category.md)| | [optional] |
671+
| **tags** | [**\OpenAPI\Client\Model\Tag[]**](../Model/\OpenAPI\Client\Model\Tag.md)| | [optional] |
672+
| **status** | **string**| pet status in the store | [optional] |
673+
| **file** | **\SplFileObject****\SplFileObject**| file to upload | [optional] |
674+
| **multiple_files** | **\SplFileObject[]**| | [optional] |
675+
676+
### Return type
677+
678+
[**\OpenAPI\Client\Model\ApiResponse**](../Model/ApiResponse.md)
679+
680+
### Authorization
681+
682+
[petstore_auth](../../README.md#petstore_auth)
683+
684+
### HTTP request headers
685+
686+
- **Content-Type**: `multipart/form-data`
687+
- **Accept**: `application/json`
688+
689+
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
690+
[[Back to Model list]](../../README.md#models)
691+
[[Back to README]](../../README.md)

0 commit comments

Comments
 (0)