Better logic to handle tags with special characters (#6466)

* better logic to handle tag with special characters

* update test cases

* comment out swift test cases

* restore the swift tests
This commit is contained in:
wing328 2017-09-12 11:41:14 +08:00 committed by GitHub
parent 9e0911b376
commit 591149bcb7
16 changed files with 736 additions and 40 deletions

View File

@ -3498,20 +3498,14 @@ public class DefaultCodegen {
* @return Sanitized tag
*/
public String sanitizeTag(String tag) {
// remove spaces and make strong case
String[] parts = tag.split(" ");
StringBuilder buf = new StringBuilder();
for (String part : parts) {
if (StringUtils.isNotEmpty(part)) {
buf.append(StringUtils.capitalize(part));
}
}
String returnTag = buf.toString().replaceAll("[^a-zA-Z0-9_]", "");
if (returnTag.matches("\\d.*")) {
return "_" + returnTag;
} else {
return returnTag;
tag = camelize(sanitizeName(tag));
// tag starts with numbers
if (tag.matches("^\\d.*")) {
tag = "_" + tag;
}
return tag;
}
/**

View File

@ -18,7 +18,7 @@ public class CodegenTest {
final DefaultCodegen codegen = new DefaultCodegen();
Assert.assertEquals(codegen.sanitizeTag("foo"), "Foo");
Assert.assertEquals(codegen.sanitizeTag("foo bar"), "FooBar");
Assert.assertEquals(codegen.sanitizeTag("foo_bar"), "Foo_bar");
Assert.assertEquals(codegen.sanitizeTag("foo_bar"), "FooBar");
Assert.assertEquals(codegen.sanitizeTag("foo1 bar2"), "Foo1Bar2");
Assert.assertEquals(codegen.sanitizeTag("foo bar 1"), "FooBar1");
Assert.assertEquals(codegen.sanitizeTag("1foo"), "_1foo");

View File

@ -898,6 +898,29 @@ paths:
responses:
'200':
description: successful operation
/another-fake/dummy:
patch:
tags:
- "$another-fake?"
summary: To test special tags
description: To test special tags
operationId: test_special_tags
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: client model
required: true
schema:
$ref: '#/definitions/Client'
responses:
'200':
description: successful operation
schema:
$ref: '#/definitions/Client'
securityDefinitions:
petstore_auth:
type: oauth2

View File

@ -56,14 +56,14 @@ Please follow the [installation procedure](#installation--usage) and then run th
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\FakeApi();
$body = new \Swagger\Client\Model\OuterBoolean(); // \Swagger\Client\Model\OuterBoolean | Input boolean as post body
$api_instance = new Swagger\Client\Api\AnotherFakeApi();
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
try {
$result = $api_instance->fakeOuterBooleanSerialize($body);
$result = $api_instance->testSpecialTags($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeOuterBooleanSerialize: ', $e->getMessage(), PHP_EOL;
echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL;
}
?>
@ -75,6 +75,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**testSpecialTags**](docs/Api/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
@ -83,7 +84,7 @@ Class | Method | HTTP request | Description
*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
*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.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
*PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status

View File

@ -0,0 +1,54 @@
# Swagger\Client\AnotherFakeApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testSpecialTags**](AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
# **testSpecialTags**
> \Swagger\Client\Model\Client testSpecialTags($body)
To test special tags
To test special tags
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\AnotherFakeApi(new \Http\Adapter\Guzzle6\Client());
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
try {
$result = $api_instance->testSpecialTags($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL;
}
?>
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**\Swagger\Client\Model\Client**](../Model/Client.md)| client model |
### Return type
[**\Swagger\Client\Model\Client**](../Model/Client.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **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)

View File

@ -1,10 +1,10 @@
# Swagger\Client\Fake_classname_tags123Api
# Swagger\Client\FakeClassnameTags123Api
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testClassname**](Fake_classname_tags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
# **testClassname**
@ -22,14 +22,14 @@ Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key_quer
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer');
$api_instance = new Swagger\Client\Api\Fake_classname_tags123Api(new \Http\Adapter\Guzzle6\Client());
$api_instance = new Swagger\Client\Api\FakeClassnameTags123Api(new \Http\Adapter\Guzzle6\Client());
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
try {
$result = $api_instance->testClassname($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling Fake_classname_tags123Api->testClassname: ', $e->getMessage(), PHP_EOL;
echo 'Exception when calling FakeClassnameTags123Api->testClassname: ', $e->getMessage(), PHP_EOL;
}
?>
```

View File

@ -0,0 +1,309 @@
<?php
/**
* AnotherFakeApi
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Swagger 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
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
namespace Swagger\Client\Api;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use Swagger\Client\ApiException;
use Swagger\Client\Configuration;
use Swagger\Client\HeaderSelector;
use Swagger\Client\ObjectSerializer;
/**
* AnotherFakeApi Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class AnotherFakeApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
}
/**
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* Operation testSpecialTags
*
* To test special tags
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @throws \Swagger\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \Swagger\Client\Model\Client
*/
public function testSpecialTags($body)
{
list($response) = $this->testSpecialTagsWithHttpInfo($body);
return $response;
}
/**
* Operation testSpecialTagsWithHttpInfo
*
* To test special tags
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @throws \Swagger\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \Swagger\Client\Model\Client, HTTP status code, HTTP response headers (array of strings)
*/
public function testSpecialTagsWithHttpInfo($body)
{
$returnType = '\Swagger\Client\Model\Client';
$request = $this->testSpecialTagsRequest($body);
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 ({$request->getUri()})",
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$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(), '\Swagger\Client\Model\Client', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testSpecialTagsAsync
*
* To test special tags
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testSpecialTagsAsync($body)
{
return $this->testSpecialTagsAsyncWithHttpInfo($body)->then(function ($response) {
return $response[0];
});
}
/**
* Operation testSpecialTagsAsyncWithHttpInfo
*
* To test special tags
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testSpecialTagsAsyncWithHttpInfo($body)
{
$returnType = '\Swagger\Client\Model\Client';
$request = $this->testSpecialTagsRequest($body);
return $this->client->sendAsync($request)->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(
"[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})",
$statusCode,
$response->getHeaders(),
$response->getBody()
);
});
}
/**
* Create request for operation 'testSpecialTags'
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function testSpecialTagsRequest($body)
{
// verify the required parameter 'body' is set
if ($body === null) {
throw new \InvalidArgumentException('Missing the required parameter $body when calling testSpecialTags');
}
$resourcePath = '/another-fake/dummy';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// body params
$_tempBody = null;
if (isset($body)) {
$_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
} 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 : '');
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
return new Request(
'PATCH',
$url,
$headers,
$httpBody
);
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Fake_classname_tags123Api
* FakeClassnameTags123Api
* PHP version 5
*
* @category Class
@ -39,14 +39,14 @@ use Swagger\Client\HeaderSelector;
use Swagger\Client\ObjectSerializer;
/**
* Fake_classname_tags123Api Class Doc Comment
* FakeClassnameTags123Api Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class Fake_classname_tags123Api
class FakeClassnameTags123Api
{
/**
* @var ClientInterface

View File

@ -0,0 +1,83 @@
<?php
/**
* AnotherFakeApiTest
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Swagger 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
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Please update the test case below to test the endpoint.
*/
namespace Swagger\Client;
use \Swagger\Client\Configuration;
use \Swagger\Client\ApiException;
use \Swagger\Client\ObjectSerializer;
/**
* AnotherFakeApiTest Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class AnotherFakeApiTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test cases
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test case for testSpecialTags
*
* To test special tags.
*
*/
public function testTestSpecialTags()
{
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Fake_classname_tags123ApiTest
* FakeClassnameTags123ApiTest
* PHP version 5
*
* @category Class
@ -29,19 +29,18 @@
namespace Swagger\Client;
use \Swagger\Client\Configuration;
use \Swagger\Client\ApiClient;
use \Swagger\Client\ApiException;
use \Swagger\Client\ObjectSerializer;
/**
* Fake_classname_tags123ApiTest Class Doc Comment
* FakeClassnameTags123ApiTest Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class Fake_classname_tags123ApiTest extends \PHPUnit_Framework_TestCase
class FakeClassnameTags123ApiTest extends \PHPUnit_Framework_TestCase
{
/**
@ -49,7 +48,6 @@ class Fake_classname_tags123ApiTest extends \PHPUnit_Framework_TestCase
*/
public static function setUpBeforeClass()
{
}
/**
@ -57,7 +55,6 @@ class Fake_classname_tags123ApiTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
}
/**
@ -65,7 +62,6 @@ class Fake_classname_tags123ApiTest extends \PHPUnit_Framework_TestCase
*/
public function tearDown()
{
}
/**
@ -73,7 +69,6 @@ class Fake_classname_tags123ApiTest extends \PHPUnit_Framework_TestCase
*/
public static function tearDownAfterClass()
{
}
/**
@ -84,7 +79,5 @@ class Fake_classname_tags123ApiTest extends \PHPUnit_Framework_TestCase
*/
public function testTestClassname()
{
}
}

View File

@ -51,14 +51,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterBoolean() # OuterBoolean | Input boolean as post body (optional)
api_instance = petstore_api.AnotherFakeApi()
body = petstore_api.Client() # Client | client model
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
# To test special tags
api_response = api_instance.test_special_tags(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e)
```
@ -68,6 +69,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |

View File

@ -0,0 +1,57 @@
# petstore_api.AnotherFakeApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
# **test_special_tags**
> Client test_special_tags(body)
To test special tags
To test special tags
### Example
```python
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.AnotherFakeApi()
body = petstore_api.Client() # Client | client model
try:
# To test special tags
api_response = api_instance.test_special_tags(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |
### Return type
[**Client**](Client.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **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)

View File

@ -52,6 +52,7 @@ from .models.cat import Cat
from .models.dog import Dog
# import apis into sdk package
from .apis.another_fake_api import AnotherFakeApi
from .apis.fake_api import FakeApi
from .apis.fake_classname_tags_123_api import FakeClassnameTags123Api
from .apis.pet_api import PetApi

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import
# import apis into api package
from .another_fake_api import AnotherFakeApi
from .fake_api import FakeApi
from .fake_classname_tags_123_api import FakeClassnameTags123Api
from .pet_api import PetApi

View File

@ -0,0 +1,134 @@
# coding: utf-8
"""
Swagger 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
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import sys
import os
import re
# python 2 and python 3 compatibility library
from six import iteritems
from ..api_client import ApiClient
class AnotherFakeApi(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
def test_special_tags(self, body, **kwargs):
"""
To test special tags
To test special tags
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.test_special_tags(body, async=True)
>>> result = thread.get()
:param async bool
:param Client body: client model (required)
:return: Client
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.test_special_tags_with_http_info(body, **kwargs)
else:
(data) = self.test_special_tags_with_http_info(body, **kwargs)
return data
def test_special_tags_with_http_info(self, body, **kwargs):
"""
To test special tags
To test special tags
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.test_special_tags_with_http_info(body, async=True)
>>> result = thread.get()
:param async bool
:param Client body: client model (required)
:return: Client
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['body']
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method test_special_tags" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'body' is set
if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `test_special_tags`")
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json'])
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/json'])
# Authentication setting
auth_settings = []
return self.api_client.call_api('/another-fake/dummy', 'PATCH',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Client',
auth_settings=auth_settings,
async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

View File

@ -0,0 +1,44 @@
# coding: utf-8
"""
Swagger 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
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import os
import sys
import unittest
import petstore_api
from petstore_api.rest import ApiException
from petstore_api.apis.another_fake_api import AnotherFakeApi
class TestAnotherFakeApi(unittest.TestCase):
""" AnotherFakeApi unit test stubs """
def setUp(self):
self.api = petstore_api.apis.another_fake_api.AnotherFakeApi()
def tearDown(self):
pass
def test_test_special_tags(self):
"""
Test case for test_special_tags
To test special tags
"""
pass
if __name__ == '__main__':
unittest.main()