added some changes to generator and added server and test client

This commit is contained in:
2026-08-15 18:44:28 +03:30
parent 313d1d4a99
commit d94840c8c7
12 changed files with 416 additions and 4 deletions
+5 -1
View File
@@ -16,6 +16,7 @@ class Field:
type: str
description: str | None = None
imports: set[str] | None = None
optional: bool = False
@dataclass
@@ -32,6 +33,7 @@ class PythonGenerator(BaseGenerator):
"number": "float",
"boolean": "bool",
"object": "dict",
"float": "float",
}
FORMAT_MAP = {
@@ -176,7 +178,7 @@ class PythonGenerator(BaseGenerator):
field_type = type_info.type
if field_name not in required:
field_type = f"{field_type} | None"
field_type = f"{field_type} | None = None"
fields.append(
Field(
@@ -184,8 +186,10 @@ class PythonGenerator(BaseGenerator):
type=field_type,
description=field_schema.get("description"),
imports=type_info.imports,
optional=field_name not in required,
)
)
fields.sort(key=lambda field: field.optional)
return Model(
name=name,