Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !7483

[python][experimental] remove hardcoded PetApi

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged William Cheng requested to merge python-enhance into master 4 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 15
  • replaced hardcoded PetApi with actual values from the OpenAPI spec.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

cc @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @arun-nalla (2019/11) @spacether (2019/11)

Compare
  • master (base)

and
  • latest version
    42e15617
    1 commit, 2 years ago

15 files
+ 50
- 32

    Preferences

    File browser
    Compare changes
modules/…/…/…/…/…/‎python-experimental‎
__init__ap‎i.mustache‎ +7 -1
__init__ap‎is.mustache‎ +5 -3
api_clien‎t.mustache‎ +6 -4
sam‎ples‎
client/petstore‎/…/petstore_api‎
a‎pi‎
__ini‎t__.py‎ +1 -1
ap‎is‎
__ini‎t__.py‎ +1 -1
api_cl‎ient.py‎ +6 -4
openapi‎3/client‎
extensions/…/…/‎x_auth_id_alias‎
a‎pi‎
__ini‎t__.py‎ +1 -1
ap‎is‎
__ini‎t__.py‎ +1 -1
api_cl‎ient.py‎ +6 -4
features/…/…/d‎ynamic_servers‎
a‎pi‎
__ini‎t__.py‎ +1 -1
ap‎is‎
__ini‎t__.py‎ +1 -1
api_cl‎ient.py‎ +6 -4
petstore/…/‎petstore_api‎
a‎pi‎
__ini‎t__.py‎ +1 -1
ap‎is‎
__ini‎t__.py‎ +1 -1
api_cl‎ient.py‎ +6 -4
modules/openapi-generator/src/main/resources/python/python-experimental/__init__api.mustache
+ 7
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE

{{#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
\ No newline at end of file
# from {{packageName}}.apis import {{classname}}
{{/-first}}
{{/apis}}
{{/apiInfo}}
modules/openapi-generator/src/main/resources/python/python-experimental/__init__api.mustache
+ 7
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE

{{#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
\ No newline at end of file
# from {{packageName}}.apis import {{classname}}
{{/-first}}
{{/apis}}
{{/apiInfo}}
modules/openapi-generator/src/main/resources/python/python-experimental/__init__apis.mustache
+ 5
- 3
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


{{#apiInfo}}
{{#apis}}
{{#-first}}
# coding: utf-8
# flake8: noqa
@@ -7,7 +10,7 @@
# 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:
#
@@ -15,8 +18,7 @@
# sys.setrecursionlimit(n)
# Import APIs into API package:
{{#apiInfo}}
{{#apis}}
{{/-first}}
from {{apiPackage}}.{{classVarName}} import {{classname}}
{{/apis}}
{{/apiInfo}}
modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache
+ 6
- 4
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


@@ -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)
samples/client/petstore/python-experimental/petstore_api/api/__init__.py
+ 1
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE

# 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
\ No newline at end of file
# from petstore_api.apis import AnotherFakeApi
samples/client/petstore/python-experimental/petstore_api/apis/__init__.py
+ 1
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


@@ -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:
#
samples/client/petstore/python-experimental/petstore_api/api_client.py
+ 6
- 4
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


@@ -729,11 +729,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__()
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)
samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/x_auth_id_alias/api/__init__.py
+ 1
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE

# 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
\ No newline at end of file
# from x_auth_id_alias.apis import UsageApi
samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/x_auth_id_alias/apis/__init__.py
+ 1
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


@@ -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:
#
samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/x_auth_id_alias/api_client.py
+ 6
- 4
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


@@ -729,11 +729,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__()
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)
samples/openapi3/client/features/dynamic-servers/python-experimental/dynamic_servers/api/__init__.py
+ 1
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE

# 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
\ No newline at end of file
# from dynamic_servers.apis import UsageApi
samples/openapi3/client/features/dynamic-servers/python-experimental/dynamic_servers/apis/__init__.py
+ 1
- 1
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


@@ -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:
#
samples/openapi3/client/features/dynamic-servers/python-experimental/dynamic_servers/api_client.py
+ 6
- 4
  • View file @ 42e15617

  • Edit in single-file editor

  • Open in Web IDE


@@ -729,11 +729,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__()
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)
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
Client: Python Enhancement: General
2
Client: Python Enhancement: General
    Assign labels
  • Manage project labels

Milestone
5.0.0
5.0.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
2
2 participants
William Cheng
Tomasz Prus
Reference: OpenAPITools/openapi-generator!7483
Source branch: python-enhance

Menu

Explore Projects Groups Snippets