Skip to content

Commit 59a4272

Browse files
wheelsandmetalJakob Schmutz
authored andcommitted
fix circular import issue in python flask
This is very similar change to 3678eaf All it intends to do is fix the problem of cirular imports (which was already fixed for python) in the python flask server.
1 parent 3abeb82 commit 59a4272

File tree

19 files changed

+797
-807
lines changed

19 files changed

+797
-807
lines changed

modules/openapi-generator/src/main/resources/flaskConnexion/model.mustache

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ from datetime import date, datetime # noqa: F401
66
from typing import List, Dict # noqa: F401
77

88
from {{modelPackage}}.base_model_ import Model
9-
{{#imports}}{{import}} # noqa: F401,E501
10-
{{/imports}}
119
from {{packageName}} import util
1210

1311

@@ -27,7 +25,7 @@ class {{classname}}(Model):
2725
{{/-last}}
2826
{{/enumVars}}{{/allowableValues}}
2927

30-
def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{dataType}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
28+
def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: '{{dataType}}'{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
3129
"""{{classname}} - a model defined in OpenAPI
3230

3331
{{#vars}}
@@ -37,7 +35,7 @@ class {{classname}}(Model):
3735
"""
3836
self.openapi_types = {
3937
{{#vars}}
40-
'{{name}}': {{{dataType}}}{{#hasMore}},{{/hasMore}}
38+
'{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}}
4139
{{/vars}}
4240
}
4341

@@ -64,7 +62,7 @@ class {{classname}}(Model):
6462

6563
{{/-first}}
6664
@property
67-
def {{name}}(self){{^supportPython2}} -> {{dataType}}{{/supportPython2}}:
65+
def {{name}}(self){{^supportPython2}} -> '{{dataType}}'{{/supportPython2}}:
6866
"""Gets the {{name}} of this {{classname}}.
6967

7068
{{#description}}
@@ -77,7 +75,7 @@ class {{classname}}(Model):
7775
return self._{{name}}
7876

7977
@{{name}}.setter
80-
def {{name}}(self, {{name}}{{^supportPython2}}: {{dataType}}{{/supportPython2}}):
78+
def {{name}}(self, {{name}}{{^supportPython2}}: '{{dataType}}'{{/supportPython2}}):
8179
"""Sets the {{name}} of this {{classname}}.
8280

8381
{{#description}}
@@ -158,4 +156,4 @@ class {{classname}}(Model):
158156
{{/vars}}
159157

160158
{{/model}}
161-
{{/models}}
159+
{{/models}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-SNAPSHOT
1+
3.3.0-SNAPSHOT

samples/server/petstore/flaskConnexion-python2/openapi_server/models/api_response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def __init__(self, code=None, type=None, message=None): # noqa: E501
2626
:type message: str
2727
"""
2828
self.openapi_types = {
29-
'code': int,
30-
'type': str,
31-
'message': str
29+
'code': 'int',
30+
'type': 'str',
31+
'message': 'str'
3232
}
3333

3434
self.attribute_map = {

samples/server/petstore/flaskConnexion-python2/openapi_server/models/category.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def __init__(self, id=None, name=None): # noqa: E501
2424
:type name: str
2525
"""
2626
self.openapi_types = {
27-
'id': long,
28-
'name': str
27+
'id': 'long',
28+
'name': 'str'
2929
}
3030

3131
self.attribute_map = {

samples/server/petstore/flaskConnexion-python2/openapi_server/models/order.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=N
3232
:type complete: bool
3333
"""
3434
self.openapi_types = {
35-
'id': long,
36-
'pet_id': long,
37-
'quantity': int,
38-
'ship_date': datetime,
39-
'status': str,
40-
'complete': bool
35+
'id': 'long',
36+
'pet_id': 'long',
37+
'quantity': 'int',
38+
'ship_date': 'datetime',
39+
'status': 'str',
40+
'complete': 'bool'
4141
}
4242

4343
self.attribute_map = {

samples/server/petstore/flaskConnexion-python2/openapi_server/models/pet.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from typing import List, Dict # noqa: F401
77

88
from openapi_server.models.base_model_ import Model
9-
from openapi_server.models.category import Category # noqa: F401,E501
10-
from openapi_server.models.tag import Tag # noqa: F401,E501
119
from openapi_server import util
1210

1311

@@ -34,12 +32,12 @@ def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None
3432
:type status: str
3533
"""
3634
self.openapi_types = {
37-
'id': long,
38-
'category': Category,
39-
'name': str,
40-
'photo_urls': List[str],
41-
'tags': List[Tag],
42-
'status': str
35+
'id': 'long',
36+
'category': 'Category',
37+
'name': 'str',
38+
'photo_urls': 'List[str]',
39+
'tags': 'List[Tag]',
40+
'status': 'str'
4341
}
4442

4543
self.attribute_map = {

samples/server/petstore/flaskConnexion-python2/openapi_server/models/tag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def __init__(self, id=None, name=None): # noqa: E501
2424
:type name: str
2525
"""
2626
self.openapi_types = {
27-
'id': long,
28-
'name': str
27+
'id': 'long',
28+
'name': 'str'
2929
}
3030

3131
self.attribute_map = {

samples/server/petstore/flaskConnexion-python2/openapi_server/models/user.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def __init__(self, id=None, username=None, first_name=None, last_name=None, emai
3636
:type user_status: int
3737
"""
3838
self.openapi_types = {
39-
'id': long,
40-
'username': str,
41-
'first_name': str,
42-
'last_name': str,
43-
'email': str,
44-
'password': str,
45-
'phone': str,
46-
'user_status': int
39+
'id': 'long',
40+
'username': 'str',
41+
'first_name': 'str',
42+
'last_name': 'str',
43+
'email': 'str',
44+
'password': 'str',
45+
'phone': 'str',
46+
'user_status': 'int'
4747
}
4848

4949
self.attribute_map = {

0 commit comments

Comments
 (0)