feat(classgen): add support for unknown types

This commit is contained in:
Johannes Kirschbauer
2025-05-20 15:49:56 +02:00
parent f6544d1cda
commit 42de68966b
3 changed files with 32 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import copy
import dataclasses
import inspect
import pathlib
from dataclasses import MISSING
from enum import EnumType
@@ -110,6 +111,12 @@ def type_to_dict(
if t is None:
return {"type": "null"}
if inspect.isclass(t) and t.__name__ == "Unknown":
# Empty should represent unknown
# We don't know anything about this type
# Nor about the nested fields, if there are any
return {}
if dataclasses.is_dataclass(t):
fields = dataclasses.fields(t)
properties = {}