forked from loafle/openapi-generator-original
[Python] fix tags
with underscore for python (#3995)
* fix tag with underscore for python * remove log
This commit is contained in:
parent
2dcddb79bc
commit
5de338d781
@ -430,7 +430,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
// replace - with _ e.g. created-at => created_at
|
// replace - with _ e.g. created-at => created_at
|
||||||
name = name.replaceAll("-", "_");
|
name = name.replaceAll("-", "_");
|
||||||
|
|
||||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
// e.g. PhoneNumberApi.py => phone_number_api.py
|
||||||
return underscore(name) + "_api";
|
return underscore(name) + "_api";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,6 +609,12 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
p.example = example;
|
p.example = example;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String sanitizeTag(String tag) {
|
||||||
|
return sanitizeName(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeQuotationMark(String input) {
|
public String escapeQuotationMark(String input) {
|
||||||
// remove ' to avoid code injection
|
// remove ' to avoid code injection
|
||||||
|
@ -560,6 +560,29 @@ paths:
|
|||||||
'404':
|
'404':
|
||||||
description: User not found
|
description: User not found
|
||||||
|
|
||||||
|
/fake_classname_test:
|
||||||
|
patch:
|
||||||
|
tags:
|
||||||
|
- "fake_classname_tags 123#$%^"
|
||||||
|
summary: To test class name in snake case
|
||||||
|
descriptions: To test class name in snake case
|
||||||
|
operationId: testClassname
|
||||||
|
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'
|
||||||
/fake:
|
/fake:
|
||||||
patch:
|
patch:
|
||||||
tags:
|
tags:
|
||||||
|
@ -72,6 +72,7 @@ Class | Method | HTTP request | Description
|
|||||||
*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
|
*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
|
||||||
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
|
*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
|
||||||
|
*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||||
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
|
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
|
||||||
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
|
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||||
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
|
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
# petstore_api.FakeClassnameTags123Api
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**test_classname**](FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||||
|
|
||||||
|
|
||||||
|
# **test_classname**
|
||||||
|
> Client test_classname(body)
|
||||||
|
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```python
|
||||||
|
from __future__ import print_statement
|
||||||
|
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.FakeClassnameTags123Api()
|
||||||
|
body = petstore_api.Client() # Client | client model
|
||||||
|
|
||||||
|
try:
|
||||||
|
# To test class name in snake case
|
||||||
|
api_response = api_instance.test_classname(body)
|
||||||
|
pprint(api_response)
|
||||||
|
except ApiException as e:
|
||||||
|
print("Exception when calling FakeClassnameTags123Api->test_classname: %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)
|
||||||
|
|
@ -57,6 +57,7 @@ from .models.user import User
|
|||||||
|
|
||||||
# import apis into sdk package
|
# import apis into sdk package
|
||||||
from .apis.fake_api import FakeApi
|
from .apis.fake_api import FakeApi
|
||||||
|
from .apis.fake_classname_tags_123_api import FakeClassnameTags123Api
|
||||||
from .apis.pet_api import PetApi
|
from .apis.pet_api import PetApi
|
||||||
from .apis.store_api import StoreApi
|
from .apis.store_api import StoreApi
|
||||||
from .apis.user_api import UserApi
|
from .apis.user_api import UserApi
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
# import apis into api package
|
# import apis into api package
|
||||||
from .fake_api import FakeApi
|
from .fake_api import FakeApi
|
||||||
|
from .fake_classname_tags_123_api import FakeClassnameTags123Api
|
||||||
from .pet_api import PetApi
|
from .pet_api import PetApi
|
||||||
from .store_api import StoreApi
|
from .store_api import StoreApi
|
||||||
from .user_api import UserApi
|
from .user_api import UserApi
|
||||||
|
@ -0,0 +1,160 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
# python 2 and python 3 compatibility library
|
||||||
|
from six import iteritems
|
||||||
|
|
||||||
|
from ..configuration import Configuration
|
||||||
|
from ..api_client import ApiClient
|
||||||
|
|
||||||
|
|
||||||
|
class FakeClassnameTags123Api(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):
|
||||||
|
config = Configuration()
|
||||||
|
if api_client:
|
||||||
|
self.api_client = api_client
|
||||||
|
else:
|
||||||
|
if not config.api_client:
|
||||||
|
config.api_client = ApiClient()
|
||||||
|
self.api_client = config.api_client
|
||||||
|
|
||||||
|
def test_classname(self, body, **kwargs):
|
||||||
|
"""
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
|
||||||
|
This method makes a synchronous HTTP request by default. To make an
|
||||||
|
asynchronous HTTP request, please define a `callback` function
|
||||||
|
to be invoked when receiving the response.
|
||||||
|
>>> def callback_function(response):
|
||||||
|
>>> pprint(response)
|
||||||
|
>>>
|
||||||
|
>>> thread = api.test_classname(body, callback=callback_function)
|
||||||
|
|
||||||
|
:param callback function: The callback function
|
||||||
|
for asynchronous request. (optional)
|
||||||
|
: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('callback'):
|
||||||
|
return self.test_classname_with_http_info(body, **kwargs)
|
||||||
|
else:
|
||||||
|
(data) = self.test_classname_with_http_info(body, **kwargs)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def test_classname_with_http_info(self, body, **kwargs):
|
||||||
|
"""
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
|
||||||
|
This method makes a synchronous HTTP request by default. To make an
|
||||||
|
asynchronous HTTP request, please define a `callback` function
|
||||||
|
to be invoked when receiving the response.
|
||||||
|
>>> def callback_function(response):
|
||||||
|
>>> pprint(response)
|
||||||
|
>>>
|
||||||
|
>>> thread = api.test_classname_with_http_info(body, callback=callback_function)
|
||||||
|
|
||||||
|
:param callback function: The callback function
|
||||||
|
for asynchronous request. (optional)
|
||||||
|
:param Client body: client model (required)
|
||||||
|
:return: Client
|
||||||
|
If the method is called asynchronously,
|
||||||
|
returns the request thread.
|
||||||
|
"""
|
||||||
|
|
||||||
|
all_params = ['body']
|
||||||
|
all_params.append('callback')
|
||||||
|
all_params.append('_return_http_data_only')
|
||||||
|
|
||||||
|
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_classname" % 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_classname`")
|
||||||
|
|
||||||
|
|
||||||
|
collection_formats = {}
|
||||||
|
|
||||||
|
resource_path = '/fake_classname_test'.replace('{format}', 'json')
|
||||||
|
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'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
|
# 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(resource_path, '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,
|
||||||
|
callback=params.get('callback'),
|
||||||
|
_return_http_data_only=params.get('_return_http_data_only'),
|
||||||
|
collection_formats=collection_formats)
|
@ -0,0 +1,55 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import petstore_api
|
||||||
|
from petstore_api.rest import ApiException
|
||||||
|
from petstore_api.apis.fake_classname_tags_123_api import FakeClassnameTags123Api
|
||||||
|
|
||||||
|
|
||||||
|
class TestFakeClassnameTags123Api(unittest.TestCase):
|
||||||
|
""" FakeClassnameTags123Api unit test stubs """
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.api = petstore_api.apis.fake_classname_tags_123_api.FakeClassnameTags123Api()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_test_classname(self):
|
||||||
|
"""
|
||||||
|
Test case for test_classname
|
||||||
|
|
||||||
|
To test class name in snake case
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user