-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[Python] fix api file name & api var name #11051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 180 additions & 0 deletions
180
samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| # coding: utf-8 | ||
|
|
||
| """ | ||
| OpenAPI 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: \" \\ # noqa: E501 | ||
|
|
||
| The version of the OpenAPI document: 1.0.0 | ||
| Generated by: https://openapi-generator.tech | ||
| """ | ||
|
|
||
|
|
||
| from __future__ import absolute_import | ||
|
|
||
| import re # noqa: F401 | ||
|
|
||
| # python 2 and python 3 compatibility library | ||
| import six | ||
|
|
||
| from petstore_api.api_client import ApiClient | ||
| from petstore_api.exceptions import ( # noqa: F401 | ||
| ApiTypeError, | ||
| ApiValueError | ||
| ) | ||
|
|
||
|
|
||
| class FakeClassnameTags123Api(object): | ||
| """NOTE: This class is auto generated by OpenAPI Generator | ||
| Ref: https://openapi-generator.tech | ||
|
|
||
| Do not edit the class manually. | ||
| """ | ||
|
|
||
| def __init__(self, api_client=None): | ||
| if api_client is None: | ||
| api_client = ApiClient() | ||
| self.api_client = api_client | ||
|
|
||
| def test_classname(self, body, **kwargs): # noqa: E501 | ||
| """To test class name in snake case # noqa: E501 | ||
|
|
||
| To test class name in snake case # noqa: E501 | ||
| This method makes a synchronous HTTP request by default. To make an | ||
| asynchronous HTTP request, please pass async_req=True | ||
|
|
||
| >>> thread = api.test_classname(body, async_req=True) | ||
| >>> result = thread.get() | ||
|
|
||
| :param body: client model (required) | ||
| :type body: Client | ||
| :param async_req: Whether to execute the request asynchronously. | ||
| :type async_req: bool, optional | ||
| :param _preload_content: if False, the urllib3.HTTPResponse object will | ||
| be returned without reading/decoding response | ||
| data. Default is True. | ||
| :type _preload_content: bool, optional | ||
| :param _request_timeout: timeout setting for this request. If one | ||
| number provided, it will be total request | ||
| timeout. It can also be a pair (tuple) of | ||
| (connection, read) timeouts. | ||
| :return: Returns the result object. | ||
| If the method is called asynchronously, | ||
| returns the request thread. | ||
| :rtype: Client | ||
| """ | ||
| kwargs['_return_http_data_only'] = True | ||
| return self.test_classname_with_http_info(body, **kwargs) # noqa: E501 | ||
|
|
||
| def test_classname_with_http_info(self, body, **kwargs): # noqa: E501 | ||
| """To test class name in snake case # noqa: E501 | ||
|
|
||
| To test class name in snake case # noqa: E501 | ||
| This method makes a synchronous HTTP request by default. To make an | ||
| asynchronous HTTP request, please pass async_req=True | ||
|
|
||
| >>> thread = api.test_classname_with_http_info(body, async_req=True) | ||
| >>> result = thread.get() | ||
|
|
||
| :param body: client model (required) | ||
| :type body: Client | ||
| :param async_req: Whether to execute the request asynchronously. | ||
| :type async_req: bool, optional | ||
| :param _return_http_data_only: response data without head status code | ||
| and headers | ||
| :type _return_http_data_only: bool, optional | ||
| :param _preload_content: if False, the urllib3.HTTPResponse object will | ||
| be returned without reading/decoding response | ||
| data. Default is True. | ||
| :type _preload_content: bool, optional | ||
| :param _request_timeout: timeout setting for this request. If one | ||
| number provided, it will be total request | ||
| timeout. It can also be a pair (tuple) of | ||
| (connection, read) timeouts. | ||
| :param _request_auth: set to override the auth_settings for an a single | ||
| request; this effectively ignores the authentication | ||
| in the spec for a single request. | ||
| :type _request_auth: dict, optional | ||
| :type _content_type: string, optional: force content-type for the request | ||
| :return: Returns the result object. | ||
| If the method is called asynchronously, | ||
| returns the request thread. | ||
| :rtype: tuple(Client, status_code(int), headers(HTTPHeaderDict)) | ||
| """ | ||
|
|
||
| local_var_params = locals() | ||
|
|
||
| all_params = [ | ||
| 'body' | ||
| ] | ||
| all_params.extend( | ||
| [ | ||
| 'async_req', | ||
| '_return_http_data_only', | ||
| '_preload_content', | ||
| '_request_timeout', | ||
| '_request_auth', | ||
| '_content_type' | ||
| ] | ||
| ) | ||
|
|
||
| for key, val in six.iteritems(local_var_params['kwargs']): | ||
| if key not in all_params: | ||
| raise ApiTypeError( | ||
| "Got an unexpected keyword argument '%s'" | ||
| " to method test_classname" % key | ||
| ) | ||
| local_var_params[key] = val | ||
| del local_var_params['kwargs'] | ||
| # verify the required parameter 'body' is set | ||
| if self.api_client.client_side_validation and ('body' not in local_var_params or # noqa: E501 | ||
| local_var_params['body'] is None): # noqa: E501 | ||
| raise ApiValueError("Missing the required parameter `body` when calling `test_classname`") # noqa: E501 | ||
|
|
||
| collection_formats = {} | ||
|
|
||
| path_params = {} | ||
|
|
||
| query_params = [] | ||
|
|
||
| header_params = {} | ||
|
|
||
| form_params = [] | ||
| local_var_files = {} | ||
|
|
||
| body_params = None | ||
| if 'body' in local_var_params: | ||
| body_params = local_var_params['body'] | ||
| # HTTP header `Accept` | ||
| header_params['Accept'] = self.api_client.select_header_accept( | ||
| ['application/json']) # noqa: E501 | ||
|
|
||
| # HTTP header `Content-Type` | ||
| header_params['Content-Type'] = local_var_params.get('_content_type', | ||
| self.api_client.select_header_content_type( | ||
| ['application/json'], | ||
| 'PATCH', body_params)) # noqa: E501 | ||
|
|
||
| # Authentication setting | ||
| auth_settings = ['api_key_query'] # noqa: E501 | ||
|
|
||
| response_types_map = { | ||
| 200: "Client", | ||
| } | ||
|
|
||
| return self.api_client.call_api( | ||
| '/fake_classname_test', 'PATCH', | ||
| path_params, | ||
| query_params, | ||
| header_params, | ||
| body=body_params, | ||
| post_params=form_params, | ||
| files=local_var_files, | ||
| response_types_map=response_types_map, | ||
| auth_settings=auth_settings, | ||
| async_req=local_var_params.get('async_req'), | ||
| _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 | ||
| _preload_content=local_var_params.get('_preload_content', True), | ||
| _request_timeout=local_var_params.get('_request_timeout'), | ||
| collection_formats=collection_formats, | ||
| _request_auth=local_var_params.get('_request_auth')) |
40 changes: 40 additions & 0 deletions
40
samples/client/petstore/python-asyncio/test/test_fake_classname_tags123_api.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # coding: utf-8 | ||
|
|
||
| """ | ||
| OpenAPI 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: \" \\ # noqa: E501 | ||
|
|
||
| The version of the OpenAPI document: 1.0.0 | ||
| Generated by: https://openapi-generator.tech | ||
| """ | ||
|
|
||
|
|
||
| from __future__ import absolute_import | ||
|
|
||
| import unittest | ||
|
|
||
| import petstore_api | ||
| from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api # noqa: E501 | ||
| from petstore_api.rest import ApiException | ||
|
|
||
|
|
||
| class TestFakeClassnameTags123Api(unittest.TestCase): | ||
| """FakeClassnameTags123Api unit test stubs""" | ||
|
|
||
| def setUp(self): | ||
| self.api = petstore_api.api.fake_classname_tags_123_api.FakeClassnameTags123Api() # noqa: E501 | ||
|
|
||
| def tearDown(self): | ||
| pass | ||
|
|
||
| def test_test_classname(self): | ||
| """Test case for test_classname | ||
|
|
||
| To test class name in snake case # noqa: E501 | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when name length is 0 with your update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after update, it will call method:
toApiName(name)this method will get default name where name length is 0