feat: support object-level descriptions #78

Merged
mikix merged 2 commits from model-desc into main 2026-01-14 19:14:35 +00:00
2 changed files with 16 additions and 0 deletions
Showing only changes of commit 2fd092cd8e - Show all commits

View File

@@ -36,6 +36,8 @@ class EnumTypeParser(GenericTypeParser):
# Create a new Enum type dynamically
enum_type = Enum(name, {str(value).upper(): value for value in enum_values}) # type: ignore
enum_type.__doc__ = properties.get("description")
parsed_properties = self.mappings_properties_builder(properties, **kwargs)
if "default" in parsed_properties and parsed_properties["default"] is not None:

View File

@@ -49,6 +49,20 @@ class TestEnumTypeParser(TestCase):
)
self.assertEqual(parsed_properties, {"default": None})
def test_enum_type_parser_creates_enum_with_description(self):
parser = EnumTypeParser()
schema = {
"description": "an enum",
"enum": ["value1"],
}
parsed_type, parsed_properties = parser.from_properties_impl(
"TestEnum",
schema,
)
self.assertEqual(parsed_type.__doc__, "an enum")
def test_enum_type_parser_creates_enum_with_default(self):
parser = EnumTypeParser()