Skip to content

Commit 639800c

Browse files
committed
templates all other python* generators
1 parent 6b50ed1 commit 639800c

25 files changed

Lines changed: 58 additions & 74 deletions

modules/openapi-generator/src/main/resources/python-aiohttp/controller.mustache

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import List, Dict
21
from aiohttp import web
32

43
{{#imports}}{{import}}
@@ -36,7 +35,7 @@ async def {{operationId}}(request: web.Request, {{#allParams}}{{paramName}}{{^re
3635
{{#isArray}}
3736
{{#items}}
3837
{{#isPrimitiveType}}
39-
:type {{paramName}}: List[{{>param_type}}]
38+
:type {{paramName}}: list[{{>param_type}}]
4039
{{/isPrimitiveType}}
4140
{{^isPrimitiveType}}
4241
:type {{paramName}}: list | bytes
@@ -46,7 +45,7 @@ async def {{operationId}}(request: web.Request, {{#allParams}}{{paramName}}{{^re
4645
{{#isMap}}
4746
{{#items}}
4847
{{#isPrimitiveType}}
49-
:type {{paramName}}: Dict[str, {{>param_type}}]
48+
:type {{paramName}}: dict[str, {{>param_type}}]
5049
{{/isPrimitiveType}}
5150
{{^isPrimitiveType}}
5251
:type {{paramName}}: dict | bytes

modules/openapi-generator/src/main/resources/python-aiohttp/model.mustache

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from datetime import date, datetime
44

5-
from typing import List, Dict, Type
6-
75
from {{modelPackage}}.base_model import Model
86
{{#models}}
97
{{#model}}

modules/openapi-generator/src/main/resources/python-aiohttp/security_controller.mustache

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import List
2-
31
{{#authMethods}}
42
{{#isOAuth}}
53

@@ -14,7 +12,7 @@ def info_from_{{name}}(token: str) -> dict:
1412
return {'scopes': ['read:pets', 'write:pets'], 'uid': 'user_id'}
1513

1614

17-
def validate_scope_{{name}}(required_scopes: List[str], token_scopes: List[str]) -> bool:
15+
def validate_scope_{{name}}(required_scopes: list[str], token_scopes: list[str]) -> bool:
1816
""" Validate required scopes are included in token scope """
1917
return set(required_scopes).issubset(set(token_scopes))
2018

modules/openapi-generator/src/main/resources/python-aiohttp/typing_utils.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ if sys.version_info < (3, 7):
1010
return type(klass) == typing.GenericMeta
1111

1212
def is_dict(klass):
13-
""" Determine whether klass is a Dict """
13+
""" Determine whether klass is a dict """
1414
return klass.__extra__ == dict
1515

1616
def is_list(klass):
17-
""" Determine whether klass is a List """
17+
""" Determine whether klass is a list """
1818
return klass.__extra__ == list
1919

2020
else:
@@ -24,9 +24,9 @@ else:
2424
return hasattr(klass, '__origin__')
2525

2626
def is_dict(klass):
27-
""" Determine whether klass is a Dict """
27+
""" Determine whether klass is a dict """
2828
return klass.__origin__ == dict
2929

3030
def is_list(klass):
31-
""" Determine whether klass is a List """
31+
""" Determine whether klass is a list """
3232
return klass.__origin__ == list

modules/openapi-generator/src/main/resources/python-aiohttp/util.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from typing import Union
55
from {{packageName}} import typing_utils
66

77
T = typing.TypeVar('T')
8-
Class = typing.Type[T]
8+
Class = type[T]
99

1010

1111
def _deserialize(data: Union[dict, list, str], klass: Union[Class, str]) -> Union[dict, list, Class, int, float, str, bool, datetime.date, datetime.datetime]:

modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/controllers/controller.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
3535
{{#isArray}}
3636
{{#items}}
3737
{{#isPrimitiveType}}
38-
:type {{paramName}}: List[{{#isString}}str{{/isString}}{{#isInteger}}int{{/isInteger}}{{#isLong}}int{{/isLong}}{{#isFloat}}float{{/isFloat}}{{#isDouble}}float{{/isDouble}}{{#isByteArray}}str{{/isByteArray}}{{#isBinary}}str{{/isBinary}}{{#isBoolean}}bool{{/isBoolean}}{{#isDate}}str{{/isDate}}{{#isDateTime}}str{{/isDateTime}}]
38+
:type {{paramName}}: list[{{#isString}}str{{/isString}}{{#isInteger}}int{{/isInteger}}{{#isLong}}int{{/isLong}}{{#isFloat}}float{{/isFloat}}{{#isDouble}}float{{/isDouble}}{{#isByteArray}}str{{/isByteArray}}{{#isBinary}}str{{/isBinary}}{{#isBoolean}}bool{{/isBoolean}}{{#isDate}}str{{/isDate}}{{#isDateTime}}str{{/isDateTime}}]
3939
{{/isPrimitiveType}}
4040
{{^isPrimitiveType}}
4141
:type {{paramName}}: list | bytes
@@ -45,7 +45,7 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
4545
{{#isMap}}
4646
{{#items}}
4747
{{#isPrimitiveType}}
48-
:type {{paramName}}: Dict[str, {{#isString}}str{{/isString}}{{#isInteger}}int{{/isInteger}}{{#isLong}}int{{/isLong}}{{#isFloat}}float{{/isFloat}}{{#isDouble}}float{{/isDouble}}{{#isByteArray}}str{{/isByteArray}}{{#isBinary}}str{{/isBinary}}{{#isBoolean}}bool{{/isBoolean}}{{#isDate}}str{{/isDate}}{{#isDateTime}}str{{/isDateTime}}]
48+
:type {{paramName}}: dict[str, {{#isString}}str{{/isString}}{{#isInteger}}int{{/isInteger}}{{#isLong}}int{{/isLong}}{{#isFloat}}float{{/isFloat}}{{#isDouble}}float{{/isDouble}}{{#isByteArray}}str{{/isByteArray}}{{#isBinary}}str{{/isBinary}}{{#isBoolean}}bool{{/isBoolean}}{{#isDate}}str{{/isDate}}{{#isDateTime}}str{{/isDateTime}}]
4949
{{/isPrimitiveType}}
5050
{{^isPrimitiveType}}
5151
:type {{paramName}}: dict | bytes

modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/base_model.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Model(object):
1717
attribute_map = {}
1818

1919
@classmethod
20-
def from_dict(cls: typing.Type[T], dikt) -> T:
20+
def from_dict(cls: type[T], dikt) -> T:
2121
"""Returns the dict as a model"""
2222
return util.deserialize_model(dikt, cls)
2323

modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/model.mustache

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from __future__ import absolute_import
44
from datetime import date, datetime # noqa: F401
55

6-
from typing import List, Dict # noqa: F401
7-
86
from {{modelPackage}}.base_model import Model
97
{{#imports}}{{import}} # noqa: F401,E501
108
{{/imports}}

modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/typing_utils.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ if sys.version_info < (3, 7):
1010
return type(klass) == typing.GenericMeta
1111

1212
def is_dict(klass):
13-
""" Determine whether klass is a Dict """
13+
""" Determine whether klass is a dict """
1414
return klass.__extra__ == dict
1515

1616
def is_list(klass):
17-
""" Determine whether klass is a List """
17+
""" Determine whether klass is a list """
1818
return klass.__extra__ == list
1919

2020
else:
@@ -24,9 +24,9 @@ else:
2424
return hasattr(klass, '__origin__')
2525

2626
def is_dict(klass):
27-
""" Determine whether klass is a Dict """
27+
""" Determine whether klass is a dict """
2828
return klass.__origin__ == dict
2929

3030
def is_list(klass):
31-
""" Determine whether klass is a List """
31+
""" Determine whether klass is a list """
3232
return klass.__origin__ == list

modules/openapi-generator/src/main/resources/python-fastapi/api.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# coding: utf-8
22

3-
from typing import Dict, List # noqa: F401
43
import importlib
54
import pkgutil
65

0 commit comments

Comments
 (0)