sera-2 1.14.5__py3-none-any.whl → 1.14.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1104,7 +1104,19 @@ def make_typescript_data_model(schema: Schema, target_pkg: Package):
|
|
1104
1104
|
for dep in tstype.deps:
|
1105
1105
|
program.import_(dep, True)
|
1106
1106
|
tsprop = [
|
1107
|
-
(
|
1107
|
+
(
|
1108
|
+
expr.ExprIdent("datatype"),
|
1109
|
+
(
|
1110
|
+
expr.ExprConstant(tstype.type)
|
1111
|
+
if tstype.type not in schema.enums
|
1112
|
+
else expr.ExprConstant("enum")
|
1113
|
+
),
|
1114
|
+
),
|
1115
|
+
*(
|
1116
|
+
[(expr.ExprIdent("enumType"), expr.ExprIdent(tstype.type))]
|
1117
|
+
if tstype.type in schema.enums
|
1118
|
+
else []
|
1119
|
+
),
|
1108
1120
|
(
|
1109
1121
|
expr.ExprIdent("isRequired"),
|
1110
1122
|
expr.ExprConstant(
|
sera/misc/_utils.py
CHANGED
@@ -4,6 +4,44 @@ import re
|
|
4
4
|
from typing import Any, Callable, Iterable, Optional, TypeVar
|
5
5
|
|
6
6
|
T = TypeVar("T")
|
7
|
+
reserved_keywords = {
|
8
|
+
"and",
|
9
|
+
"or",
|
10
|
+
"not",
|
11
|
+
"is",
|
12
|
+
"in",
|
13
|
+
"if",
|
14
|
+
"else",
|
15
|
+
"elif",
|
16
|
+
"for",
|
17
|
+
"while",
|
18
|
+
"def",
|
19
|
+
"class",
|
20
|
+
"return",
|
21
|
+
"yield",
|
22
|
+
"import",
|
23
|
+
"from",
|
24
|
+
"as",
|
25
|
+
"with",
|
26
|
+
"try",
|
27
|
+
"except",
|
28
|
+
"finally",
|
29
|
+
"raise",
|
30
|
+
"assert",
|
31
|
+
"break",
|
32
|
+
"continue",
|
33
|
+
"pass",
|
34
|
+
"del",
|
35
|
+
"global",
|
36
|
+
"nonlocal",
|
37
|
+
"lambda",
|
38
|
+
"async",
|
39
|
+
"await",
|
40
|
+
"True",
|
41
|
+
"False",
|
42
|
+
"None",
|
43
|
+
"self",
|
44
|
+
}
|
7
45
|
|
8
46
|
|
9
47
|
def to_snake_case(camelcase: str) -> str:
|
@@ -16,13 +54,21 @@ def to_snake_case(camelcase: str) -> str:
|
|
16
54
|
def to_camel_case(snake: str) -> str:
|
17
55
|
"""Convert snake_case to camelCase."""
|
18
56
|
components = snake.split("_")
|
19
|
-
|
57
|
+
out = components[0] + "".join(x.title() for x in components[1:])
|
58
|
+
# handle a corner case where the _ is added to the end of the string to avoid reserved keywords
|
59
|
+
if snake.endswith("_") and snake[:-1] in reserved_keywords:
|
60
|
+
out += "_"
|
61
|
+
return out
|
20
62
|
|
21
63
|
|
22
64
|
def to_pascal_case(snake: str) -> str:
|
23
65
|
"""Convert snake_case to PascalCase."""
|
24
66
|
components = snake.split("_")
|
25
|
-
|
67
|
+
out = "".join(x.title() for x in components)
|
68
|
+
# handle a corner case where the _ is added to the end of the string to avoid reserved keywords
|
69
|
+
if snake.endswith("_") and snake[:-1] in reserved_keywords:
|
70
|
+
out += "_"
|
71
|
+
return out
|
26
72
|
|
27
73
|
|
28
74
|
def assert_isinstance(x: Any, cls: type[T]) -> T:
|
@@ -19,10 +19,10 @@ sera/make/make_app.py,sha256=n9NtW73O3s_5Q31VHIRmnd-jEIcpDO7ksAsOdovde2s,5999
|
|
19
19
|
sera/make/make_python_api.py,sha256=iXGbKQ3IJvsY1ur_fhurr_THFNnH66E3Wl85o0emUbw,26853
|
20
20
|
sera/make/make_python_model.py,sha256=cRb-fuHX0WH7XPAAliu6lycC0iEjE5kcKg4bBU40GwQ,61275
|
21
21
|
sera/make/make_python_services.py,sha256=0ZpWLwQ7Nwfn8BXAikAB4JRpNknpSJyJgY5b1cjtxV4,2073
|
22
|
-
sera/make/make_typescript_model.py,sha256=
|
22
|
+
sera/make/make_typescript_model.py,sha256=3F-1TAbVb2-vidj5wKIi_U442JkBXZU3UYCZkodWRRM,64466
|
23
23
|
sera/misc/__init__.py,sha256=Dh4uDq0D4N53h3zhvmwfa5a0TPVRSUvLzb0hkFuPirk,411
|
24
24
|
sera/misc/_formatter.py,sha256=aCGYL08l8f3aLODHxSocxBBwkRYEo3K1QzCDEn3suj0,1685
|
25
|
-
sera/misc/_utils.py,sha256=
|
25
|
+
sera/misc/_utils.py,sha256=vBfbEChf7IMdLDj3CbdOXTUAdWNQTLLpAWwBoUcF3u0,2315
|
26
26
|
sera/models/__init__.py,sha256=vJC5Kzo_N7wd16ocNPy1VvAZDGNiWeiAhWJ4ihATKvA,780
|
27
27
|
sera/models/_class.py,sha256=1J4Bd_LanzhhDWwZFHWGtFYD7lupe_alaB3D02ebNDI,2862
|
28
28
|
sera/models/_collection.py,sha256=ZnQEriKC4X88Zz48Kn1AVZKH-1_l8OgWa-zf2kcQOOE,1414
|
@@ -36,6 +36,6 @@ sera/models/_parse.py,sha256=MaGZty29lsVUFumWqNanIjAwptBNOMbVZMXLZ2A9_2g,12317
|
|
36
36
|
sera/models/_property.py,sha256=2rSLs9JjSesrxrEugE7krYaBQOivKU882I8mZN94FlI,7017
|
37
37
|
sera/models/_schema.py,sha256=VxJEiqgVvbXgcSUK4UW6JnRcggk4nsooVSE6MyXmfNY,1636
|
38
38
|
sera/typing.py,sha256=Fl4-UzLJu1GdLLk_g87fA7nT9wQGelNnGzag6dg_0gs,980
|
39
|
-
sera_2-1.14.
|
40
|
-
sera_2-1.14.
|
41
|
-
sera_2-1.14.
|
39
|
+
sera_2-1.14.7.dist-info/METADATA,sha256=r_FKuEQXlq3cQU-xQqcbdd61agMD-dvcg7Ar0n2Hq4s,852
|
40
|
+
sera_2-1.14.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
41
|
+
sera_2-1.14.7.dist-info/RECORD,,
|
File without changes
|