forked from loafle/openapi-generator-original
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:
@@ -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 |
|
||||
|
||||
57
samples/client/petstore/python/docs/AnotherFakeApi.md
Normal file
57
samples/client/petstore/python/docs/AnotherFakeApi.md
Normal 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
44
samples/client/petstore/python/test/test_another_fake_api.py
Normal file
44
samples/client/petstore/python/test/test_another_fake_api.py
Normal 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()
|
||||
Reference in New Issue
Block a user