forked from loafle/openapi-generator-original
[php] 2.3 - fix form params json encoding (#5701)
* fixed tests expectations not compatible with phpunit 4 * added test and endpoint definition, updated template * regenerated sample * regenerated security sample
This commit is contained in:
@@ -222,6 +222,17 @@ use {{invokerPackage}}\ObjectSerializer;
|
||||
}
|
||||
{{/bodyParams}}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}],
|
||||
[{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -237,22 +248,14 @@ use {{invokerPackage}}\ObjectSerializer;
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}],
|
||||
[{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
||||
);
|
||||
}
|
||||
|
||||
{{#authMethods}}
|
||||
{{#isApiKey}}
|
||||
// this endpoint requires API key authentication
|
||||
|
||||
@@ -872,6 +872,29 @@ paths:
|
||||
description: Output composite
|
||||
schema:
|
||||
$ref: '#/definitions/OuterComposite'
|
||||
/fake/jsonFormData:
|
||||
get:
|
||||
tags:
|
||||
- fake
|
||||
summary: test json serialization of form data
|
||||
description: ''
|
||||
operationId: testJsonFormData
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- name: param
|
||||
in: formData
|
||||
description: field1
|
||||
required: true
|
||||
type: string
|
||||
- name: param2
|
||||
in: formData
|
||||
description: field2
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
securityDefinitions:
|
||||
petstore_auth:
|
||||
type: oauth2
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
@@ -124,6 +124,17 @@ class FakeApi
|
||||
$formParams['test code inject */ ' " =end -- \r\n \n \r'] = ObjectSerializer::toFormValue($test_code_inject____end____rn_n_r);
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json', '*_/ \" =end --']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json', '*_/ \" =end --'],
|
||||
['application/json', '*_/ \" =end --']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -139,22 +150,14 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json', '*_/ \" =end --']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json', '*_/ \" =end --'],
|
||||
['application/json', '*_/ \" =end --']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
|
||||
@@ -82,6 +82,7 @@ Class | Method | HTTP request | Description
|
||||
*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
|
||||
*FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*Fake_classname_tags123Api* | [**testClassname**](docs/Api/Fake_classname_tags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
|
||||
@@ -11,6 +11,7 @@ Method | HTTP request | Description
|
||||
[**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
|
||||
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
|
||||
|
||||
# **fakeOuterBooleanSerialize**
|
||||
@@ -370,3 +371,49 @@ 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)
|
||||
|
||||
# **testJsonFormData**
|
||||
> testJsonFormData($param, $param2)
|
||||
|
||||
test json serialization of form data
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$param = "param_example"; // string | field1
|
||||
$param2 = "param2_example"; // string | field2
|
||||
|
||||
try {
|
||||
$api_instance->testJsonFormData($param, $param2);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->testJsonFormData: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**param** | **string**| field1 |
|
||||
**param2** | **string**| field2 |
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
@@ -126,6 +126,17 @@ class FakeApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -141,22 +152,14 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -273,6 +276,17 @@ class FakeApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -288,22 +302,14 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -420,6 +426,17 @@ class FakeApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -435,22 +452,14 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -567,6 +576,17 @@ class FakeApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -582,22 +602,14 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -718,6 +730,17 @@ class FakeApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
['application/json']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -733,22 +756,14 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
['application/json']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -1004,6 +1019,17 @@ class FakeApi
|
||||
$formParams['callback'] = ObjectSerializer::toFormValue($callback);
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml; charset=utf-8', 'application/json; charset=utf-8']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml; charset=utf-8', 'application/json; charset=utf-8'],
|
||||
['application/xml; charset=utf-8', 'application/json; charset=utf-8']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -1019,22 +1045,14 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml; charset=utf-8', 'application/json; charset=utf-8']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml; charset=utf-8', 'application/json; charset=utf-8'],
|
||||
['application/xml; charset=utf-8', 'application/json; charset=utf-8']
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires HTTP basic authentication
|
||||
if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
|
||||
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
|
||||
@@ -1183,6 +1201,17 @@ class FakeApi
|
||||
$formParams['enum_query_double'] = ObjectSerializer::toFormValue($enum_query_double);
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['*/*']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['*/*'],
|
||||
['*/*']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -1198,22 +1227,158 @@ class FakeApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
|
||||
$defaultHeaders = [];
|
||||
if ($this->config->getUserAgent()) {
|
||||
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||||
}
|
||||
|
||||
$headers = array_merge(
|
||||
$defaultHeaders,
|
||||
$headerParams,
|
||||
$headers
|
||||
);
|
||||
|
||||
$request = new Request(
|
||||
'GET',
|
||||
$url,
|
||||
$headers,
|
||||
$httpBody
|
||||
);
|
||||
|
||||
try {
|
||||
|
||||
try {
|
||||
$response = $this->client->send($request);
|
||||
} catch (RequestException $e) {
|
||||
throw new ApiException(
|
||||
"[{$e->getCode()}] {$e->getMessage()}",
|
||||
$e->getCode(),
|
||||
$e->getResponse() ? $e->getResponse()->getHeaders() : null
|
||||
);
|
||||
}
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
"[$statusCode] Error connecting to the API ($url)",
|
||||
$statusCode,
|
||||
$response->getHeaders(),
|
||||
$response->getBody()
|
||||
);
|
||||
}
|
||||
|
||||
return [null, $statusCode, $response->getHeaders()];
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Operation testJsonFormData
|
||||
*
|
||||
* test json serialization of form data
|
||||
*
|
||||
* @param string $param field1 (required)
|
||||
* @param string $param2 field2 (required)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return void
|
||||
*/
|
||||
public function testJsonFormData($param, $param2)
|
||||
{
|
||||
$this->testJsonFormDataWithHttpInfo($param, $param2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation testJsonFormDataWithHttpInfo
|
||||
*
|
||||
* test json serialization of form data
|
||||
*
|
||||
* @param string $param field1 (required)
|
||||
* @param string $param2 field2 (required)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
*/
|
||||
public function testJsonFormDataWithHttpInfo($param, $param2)
|
||||
{
|
||||
// verify the required parameter 'param' is set
|
||||
if ($param === null) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $param when calling testJsonFormData');
|
||||
}
|
||||
// verify the required parameter 'param2' is set
|
||||
if ($param2 === null) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $param2 when calling testJsonFormData');
|
||||
}
|
||||
|
||||
$resourcePath = '/fake/jsonFormData';
|
||||
$formParams = [];
|
||||
$queryParams = [];
|
||||
$headerParams = [];
|
||||
$httpBody = '';
|
||||
$multipart = false;
|
||||
$returnType = '';
|
||||
|
||||
|
||||
|
||||
// form params
|
||||
if ($param !== null) {
|
||||
$formParams['param'] = ObjectSerializer::toFormValue($param);
|
||||
}
|
||||
// form params
|
||||
if ($param2 !== null) {
|
||||
$formParams['param2'] = ObjectSerializer::toFormValue($param2);
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['*/*']
|
||||
[]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['*/*'],
|
||||
['*/*']
|
||||
[],
|
||||
['application/json']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
|
||||
} elseif (count($formParams) > 0) {
|
||||
if ($multipart) {
|
||||
$multipartContents = [];
|
||||
foreach ($formParams as $formParamName => $formParamValue) {
|
||||
$multipartContents[] = [
|
||||
'name' => $formParamName,
|
||||
'contents' => $formParamValue
|
||||
];
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
|
||||
@@ -130,6 +130,17 @@ class Fake_classname_tags123Api
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
['application/json']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -145,22 +156,14 @@ class Fake_classname_tags123Api
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
['application/json']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
|
||||
@@ -129,6 +129,17 @@ class PetApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
['application/json', 'application/xml']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -144,22 +155,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
['application/json', 'application/xml']
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
@@ -270,6 +273,17 @@ class PetApi
|
||||
}
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -285,22 +299,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
@@ -409,6 +415,17 @@ class PetApi
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -424,22 +441,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
@@ -566,6 +575,17 @@ class PetApi
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -581,22 +601,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
@@ -720,6 +732,17 @@ class PetApi
|
||||
}
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -735,22 +758,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires API key authentication
|
||||
$apiKey = $this->config->getApiKeyWithPrefix('api_key');
|
||||
if ($apiKey !== null) {
|
||||
@@ -875,6 +890,17 @@ class PetApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
['application/json', 'application/xml']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -890,22 +916,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
['application/json', 'application/xml']
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
@@ -1022,6 +1040,17 @@ class PetApi
|
||||
$formParams['status'] = ObjectSerializer::toFormValue($status);
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
['application/x-www-form-urlencoded']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -1037,22 +1066,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
['application/x-www-form-urlencoded']
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
@@ -1171,6 +1192,17 @@ class PetApi
|
||||
$formParams['file'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb');
|
||||
}
|
||||
|
||||
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)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -1186,22 +1218,14 @@ class PetApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
['multipart/form-data']
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
|
||||
@@ -128,6 +128,17 @@ class StoreApi
|
||||
}
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -143,22 +154,14 @@ class StoreApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -250,6 +253,17 @@ class StoreApi
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -265,22 +279,14 @@ class StoreApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// this endpoint requires API key authentication
|
||||
$apiKey = $this->config->getApiKeyWithPrefix('api_key');
|
||||
if ($apiKey !== null) {
|
||||
@@ -412,6 +418,17 @@ class StoreApi
|
||||
}
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -427,22 +444,14 @@ class StoreApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -563,6 +572,17 @@ class StoreApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -578,22 +598,14 @@ class StoreApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
|
||||
@@ -129,6 +129,17 @@ class UserApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -144,22 +155,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -261,6 +264,17 @@ class UserApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -276,22 +290,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -393,6 +399,17 @@ class UserApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -408,22 +425,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -524,6 +533,17 @@ class UserApi
|
||||
}
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -539,22 +559,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -656,6 +668,17 @@ class UserApi
|
||||
}
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -671,22 +694,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -816,6 +831,17 @@ class UserApi
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -831,22 +857,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -955,6 +973,17 @@ class UserApi
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -970,22 +999,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
@@ -1097,6 +1118,17 @@ class UserApi
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -1112,22 +1144,14 @@ class UserApi
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/xml', 'application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/xml', 'application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$query = \GuzzleHttp\Psr7\build_query($queryParams);
|
||||
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');
|
||||
|
||||
@@ -6,12 +6,13 @@ use GuzzleHttp\Client;
|
||||
|
||||
class ExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Swagger\Client\ApiException
|
||||
* @expectedExceptionCode 404
|
||||
* @expectedExceptionMessage http://petstore.swagger.io/INVALID_URL/store/inventory
|
||||
*/
|
||||
public function testNotFound()
|
||||
{
|
||||
$this->expectException(ApiException::class);
|
||||
$this->expectExceptionCode(404);
|
||||
$this->expectExceptionMessage('http://petstore.swagger.io/INVALID_URL/store/inventory');
|
||||
|
||||
$config = new Configuration();
|
||||
$config->setHost('http://petstore.swagger.io/INVALID_URL');
|
||||
|
||||
@@ -22,11 +23,12 @@ class ExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
$api->getInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Swagger\Client\ApiException
|
||||
* @expectedExceptionMessage Could not resolve host
|
||||
*/
|
||||
public function testWrongHost()
|
||||
{
|
||||
$this->expectException(ApiException::class);
|
||||
$this->expectExceptionMessage('Could not resolve host');
|
||||
|
||||
$config = new Configuration();
|
||||
$config->setHost('http://wrong_host.zxc');
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Swagger\Client;
|
||||
|
||||
use Swagger\Client\Api\FakeApi;
|
||||
|
||||
class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/** @var FakeApi */
|
||||
private $api;
|
||||
/** @var FakeHttpClient */
|
||||
private $fakeClient;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->fakeClient = new FakeHttpClient();
|
||||
$this->api = new Api\FakeApi($this->fakeClient);
|
||||
}
|
||||
|
||||
public function testFormDataEncodingToJson()
|
||||
{
|
||||
$this->api->testJsonFormData('value', 'value2');
|
||||
|
||||
$request = $this->fakeClient->getLastRequest();
|
||||
$contentType = $request->getHeader('Content-Type');
|
||||
$this->assertEquals(['application/json'], $contentType);
|
||||
|
||||
$requestContent = $request->getBody()->getContents();
|
||||
|
||||
$expected = json_encode(['param' => 'value', 'param2' => 'value2']);
|
||||
$this->assertEquals($expected, $requestContent);
|
||||
}
|
||||
}
|
||||
@@ -37,13 +37,14 @@ class ResponseTypesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf(Pet::class, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Swagger\Client\ApiException
|
||||
* @expectedExceptionCode 400
|
||||
*/
|
||||
public function testDefinedErrorException()
|
||||
{
|
||||
$statusCode = 400;
|
||||
|
||||
$this->expectException(ApiException::class);
|
||||
$this->expectExceptionCode($statusCode);
|
||||
|
||||
$this->fakeHttpClient->setResponse(new Response($statusCode, [], '{}'));
|
||||
$this->api->getPetById(123);
|
||||
}
|
||||
@@ -67,13 +68,14 @@ class ResponseTypesTest extends \PHPUnit_Framework_TestCase
|
||||
// $this->assertInstanceOf(Error::class, $result);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @expectedException \Swagger\Client\ApiException
|
||||
* @expectedExceptionCode 404
|
||||
*/
|
||||
public function testDefaultErrorException()
|
||||
{
|
||||
$statusCode = 404;
|
||||
|
||||
$this->expectException(ApiException::class);
|
||||
$this->expectExceptionCode($statusCode);
|
||||
|
||||
$this->fakeHttpClient->setResponse(new Response($statusCode, [], '{}'));
|
||||
$this->api->getPetById(123);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user