-
Notifications
You must be signed in to change notification settings - Fork 6k
Python Client [v2.X] Added inheritance/polymorphism (allOf) to python client #11968
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
base: master
Are you sure you want to change the base?
Changes from all commits
00fdb1a
cb86e8d
bb5fe77
ea55bdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,15 @@ import pprint | |
| import re # noqa: F401 | ||
|
|
||
| import six | ||
| {{#imports}}{{import}} # noqa: F401,E501 | ||
| {{/imports}} | ||
|
|
||
| from {{packageName}}.configuration import Configuration | ||
|
|
||
|
|
||
| {{#models}} | ||
| {{#model}} | ||
| class {{classname}}(object): | ||
| class {{classname}}({{#parent}}{{.}}{{/parent}}{{^parent}}object{{/parent}}): | ||
| """NOTE: This class is auto generated by the swagger code generator program. | ||
|
|
||
| Do not edit the class manually. | ||
|
|
@@ -34,15 +36,15 @@ class {{classname}}(object): | |
| and the value is json key in definition. | ||
| """ | ||
| swagger_types = { | ||
| {{#vars}} | ||
| {{#allVars}} | ||
| '{{name}}': '{{{datatype}}}'{{#hasMore}},{{/hasMore}} | ||
| {{/vars}} | ||
| {{/allVars}} | ||
| } | ||
|
|
||
| attribute_map = { | ||
| {{#vars}} | ||
| {{#allVars}} | ||
| '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} | ||
| {{/vars}} | ||
| {{/allVars}} | ||
|
Comment on lines
+39
to
+47
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to the way the deserializer works in the api_client, the parent values must be present in |
||
| } | ||
| {{#discriminator}} | ||
|
|
||
|
|
@@ -52,8 +54,12 @@ class {{classname}}(object): | |
| } | ||
| {{/discriminator}} | ||
|
|
||
| def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}, _configuration=None): # noqa: E501 | ||
| """{{classname}} - a model defined in Swagger""" # noqa: E501 | ||
| def __init__(self{{#allVars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/allVars}}, _configuration=None): # noqa: E501 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly because the values for the model are defined with the constructor rather than using setters for each property, the parent vars must be passed in the constructor as well as the properties belonging to this model |
||
| """{{classname}} - a model defined in Swagger""" # noqa: E501 | ||
| {{#parent}} | ||
| super().__init__({{#parentModel.vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/parentModel.vars}}) # noqa: E501 | ||
|
|
||
| {{/parent}} | ||
| if _configuration is None: | ||
| _configuration = Configuration() | ||
| self._configuration = _configuration | ||
|
|
||
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.
Only adds the parent class for importing as the python client does not need to know the type of the values it works with, but does need to import the parent class