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
  • !4443

[Python] Use Python 2.6 compatible dict definition

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/Metaswitch/python-26-dict into master 5 years ago
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 4

Created by: richardwhiuk

This changes the generated client to use a Python 2.6 compatible dictionary definition, which allows the client (on at least some APIs) to work on Python 2.6

This work was contributed by @nick-slack at @Metaswitch.

Python Technical Committee

@taxpon, @frol, @mbohlool, @cbornet, @kenjones-cisco, @tomplus, @Jyhess, @slash-arun

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Compare
  • master (base)

and
  • latest version
    06aac9bb
    2 commits, 2 years ago

4 files
+ 28
- 28

    Preferences

    File browser
    Compare changes
modules/openapi-gen‎erator/…/…/…/python‎
api_clien‎t.mustache‎ +7 -7
samples/cli‎ent/petstore‎
python-asynci‎o/petstore_api‎
api_cl‎ient.py‎ +7 -7
python-tornad‎o/petstore_api‎
api_cl‎ient.py‎ +7 -7
python/pe‎tstore_api‎
api_cl‎ient.py‎ +7 -7
modules/openapi-generator/src/main/resources/python/api_client.mustache
+ 7
- 7
  • View file @ 06aac9bb


@@ -231,12 +231,12 @@ class ApiClient(object):
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None}
obj_dict = dict([(obj.attribute_map[attr], getattr(obj, attr))
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None])
return {key: self.sanitize_for_serialization(val)
for key, val in six.iteritems(obj_dict)}
return dict([(key, self.sanitize_for_serialization(val))
for key, val in six.iteritems(obj_dict)])
def deserialize(self, response, response_type):
"""Deserializes response into an object.
@@ -279,8 +279,8 @@ class ApiClient(object):
if klass.startswith('dict('):
sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in six.iteritems(data)}
return dict([(k, self.__deserialize(v, sub_kls))
for k, v in six.iteritems(data)])
# convert str to class
if klass in self.NATIVE_TYPES_MAPPING:
samples/client/petstore/python/petstore_api/api_client.py
+ 7
- 7
  • View file @ 06aac9bb


@@ -224,12 +224,12 @@ class ApiClient(object):
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None}
obj_dict = dict([(obj.attribute_map[attr], getattr(obj, attr))
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None])
return {key: self.sanitize_for_serialization(val)
for key, val in six.iteritems(obj_dict)}
return dict([(key, self.sanitize_for_serialization(val))
for key, val in six.iteritems(obj_dict)])
def deserialize(self, response, response_type):
"""Deserializes response into an object.
@@ -272,8 +272,8 @@ class ApiClient(object):
if klass.startswith('dict('):
sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in six.iteritems(data)}
return dict([(k, self.__deserialize(v, sub_kls))
for k, v in six.iteritems(data)])
# convert str to class
if klass in self.NATIVE_TYPES_MAPPING:
samples/client/petstore/python-asyncio/petstore_api/api_client.py
+ 7
- 7
  • View file @ 06aac9bb


@@ -224,12 +224,12 @@ class ApiClient(object):
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None}
obj_dict = dict([(obj.attribute_map[attr], getattr(obj, attr))
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None])
return {key: self.sanitize_for_serialization(val)
for key, val in six.iteritems(obj_dict)}
return dict([(key, self.sanitize_for_serialization(val))
for key, val in six.iteritems(obj_dict)])
def deserialize(self, response, response_type):
"""Deserializes response into an object.
@@ -272,8 +272,8 @@ class ApiClient(object):
if klass.startswith('dict('):
sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in six.iteritems(data)}
return dict([(k, self.__deserialize(v, sub_kls))
for k, v in six.iteritems(data)])
# convert str to class
if klass in self.NATIVE_TYPES_MAPPING:
samples/client/petstore/python-tornado/petstore_api/api_client.py
+ 7
- 7
  • View file @ 06aac9bb


@@ -226,12 +226,12 @@ class ApiClient(object):
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None}
obj_dict = dict([(obj.attribute_map[attr], getattr(obj, attr))
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None])
return {key: self.sanitize_for_serialization(val)
for key, val in six.iteritems(obj_dict)}
return dict([(key, self.sanitize_for_serialization(val))
for key, val in six.iteritems(obj_dict)])
def deserialize(self, response, response_type):
"""Deserializes response into an object.
@@ -274,8 +274,8 @@ class ApiClient(object):
if klass.startswith('dict('):
sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in six.iteritems(data)}
return dict([(k, self.__deserialize(v, sub_kls))
for k, v in six.iteritems(data)])
# convert str to class
if klass in self.NATIVE_TYPES_MAPPING:
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
Client: Python Enhancement: Compatibility
2
Client: Python Enhancement: Compatibility
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
2
2 participants
Administrator
Tomasz Prus
Reference: OpenAPITools/openapi-generator!4443
Source branch: github/fork/Metaswitch/python-26-dict

Menu

Explore Projects Groups Snippets