Skip to content
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

[python][experimental] remove hardcoded PetApi #7483

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{{#apiInfo}}
{{#apis}}
{{#-first}}
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from {{packageName}.apis import DefaultApi, PetApi
# from {{packageName}}.apis import {{classname}}
{{/-first}}
{{/apis}}
{{/apiInfo}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{{#apiInfo}}
{{#apis}}
{{#-first}}
# coding: utf-8

# flake8: noqa
Expand All @@ -7,16 +10,15 @@
# raise a `RecursionError`.
# In order to avoid this, import only the API that you directly need like:
#
# from {{packagename}}.api.pet_api import PetApi
# from {{packagename}}.api.{{classVarName}} import {{classname}}
#
# or import this package, but before doing it, use:
#
# import sys
# sys.setrecursionlimit(n)

# Import APIs into API package:
{{#apiInfo}}
{{#apis}}
{{/-first}}
from {{apiPackage}}.{{classVarName}} import {{classname}}
{{/apis}}
{{/apiInfo}}
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,13 @@ class Endpoint(object):
def __call__(self, *args, **kwargs):
""" This method is invoked when endpoints are called
Example:
pet_api = PetApi()
pet_api.add_pet # this is an instance of the class Endpoint
pet_api.add_pet() # this invokes pet_api.add_pet.__call__()
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
api_instance = {{classname}}()
api_instance.{{operationId}} # this is an instance of the class Endpoint
api_instance.{{operationId}}() # this invokes api_instance.{{operationId}}.__call__()
which then invokes the callable functions stored in that endpoint at
pet_api.add_pet.callable or self.callable in this class
api_instance.{{operationId}}.callable or self.callable in this class
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
"""
return self.callable(self, *args, **kwargs)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from {{packageName}.apis import DefaultApi, PetApi
# from petstore_api.apis import AnotherFakeApi
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,13 @@ def __gather_params(self, kwargs):
def __call__(self, *args, **kwargs):
""" This method is invoked when endpoints are called
Example:
pet_api = PetApi()
pet_api.add_pet # this is an instance of the class Endpoint
pet_api.add_pet() # this invokes pet_api.add_pet.__call__()

api_instance = AnotherFakeApi()
api_instance.call_123_test_special_tags # this is an instance of the class Endpoint
api_instance.call_123_test_special_tags() # this invokes api_instance.call_123_test_special_tags.__call__()
which then invokes the callable functions stored in that endpoint at
pet_api.add_pet.callable or self.callable in this class
api_instance.call_123_test_special_tags.callable or self.callable in this class

"""
return self.callable(self, *args, **kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# raise a `RecursionError`.
# In order to avoid this, import only the API that you directly need like:
#
# from .api.pet_api import PetApi
# from .api.another_fake_api import AnotherFakeApi
#
# or import this package, but before doing it, use:
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from {{packageName}.apis import DefaultApi, PetApi
# from x_auth_id_alias.apis import UsageApi
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,13 @@ def __gather_params(self, kwargs):
def __call__(self, *args, **kwargs):
""" This method is invoked when endpoints are called
Example:
pet_api = PetApi()
pet_api.add_pet # this is an instance of the class Endpoint
pet_api.add_pet() # this invokes pet_api.add_pet.__call__()

api_instance = UsageApi()
api_instance.any_key # this is an instance of the class Endpoint
api_instance.any_key() # this invokes api_instance.any_key.__call__()
which then invokes the callable functions stored in that endpoint at
pet_api.add_pet.callable or self.callable in this class
api_instance.any_key.callable or self.callable in this class

"""
return self.callable(self, *args, **kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# raise a `RecursionError`.
# In order to avoid this, import only the API that you directly need like:
#
# from .api.pet_api import PetApi
# from .api.usage_api import UsageApi
#
# or import this package, but before doing it, use:
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from {{packageName}.apis import DefaultApi, PetApi
# from dynamic_servers.apis import UsageApi
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,13 @@ def __gather_params(self, kwargs):
def __call__(self, *args, **kwargs):
""" This method is invoked when endpoints are called
Example:
pet_api = PetApi()
pet_api.add_pet # this is an instance of the class Endpoint
pet_api.add_pet() # this invokes pet_api.add_pet.__call__()

api_instance = UsageApi()
api_instance.custom_server # this is an instance of the class Endpoint
api_instance.custom_server() # this invokes api_instance.custom_server.__call__()
which then invokes the callable functions stored in that endpoint at
pet_api.add_pet.callable or self.callable in this class
api_instance.custom_server.callable or self.callable in this class

"""
return self.callable(self, *args, **kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# raise a `RecursionError`.
# In order to avoid this, import only the API that you directly need like:
#
# from .api.pet_api import PetApi
# from .api.usage_api import UsageApi
#
# or import this package, but before doing it, use:
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from {{packageName}.apis import DefaultApi, PetApi
# from petstore_api.apis import AnotherFakeApi
Original file line number Diff line number Diff line change
Expand Up @@ -736,11 +736,13 @@ def __gather_params(self, kwargs):
def __call__(self, *args, **kwargs):
""" This method is invoked when endpoints are called
Example:
pet_api = PetApi()
pet_api.add_pet # this is an instance of the class Endpoint
pet_api.add_pet() # this invokes pet_api.add_pet.__call__()

api_instance = AnotherFakeApi()
api_instance.call_123_test_special_tags # this is an instance of the class Endpoint
api_instance.call_123_test_special_tags() # this invokes api_instance.call_123_test_special_tags.__call__()
which then invokes the callable functions stored in that endpoint at
pet_api.add_pet.callable or self.callable in this class
api_instance.call_123_test_special_tags.callable or self.callable in this class

"""
return self.callable(self, *args, **kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# raise a `RecursionError`.
# In order to avoid this, import only the API that you directly need like:
#
# from .api.pet_api import PetApi
# from .api.another_fake_api import AnotherFakeApi
#
# or import this package, but before doing it, use:
#
Expand Down