fix: resolve nested ROS2 message types losing properties in JSON Schema generation

Array fields containing nested message types (e.g., Point[]) were serialized
as {type: object} without inner properties. Now correctly extracts and includes
all nested fields, required list, and title via NamespacedType introspection.

Made-with: Cursor
This commit is contained in:
Xuwznln
2026-03-22 01:25:04 +08:00
parent 97c76708cd
commit 03b3b1144c
2 changed files with 47 additions and 2 deletions

View File

@@ -277,9 +277,16 @@ class TypeInfo:
# Special handling for object types
if self.is_object and self.object_fields:
properties = {}
required_fields = []
for field_name, field_info in self.object_fields.items():
properties[field_name] = field_info.to_json_schema_property(include_constraints)
if field_info.has_constraint(ConstraintType.REQUIRED):
required_fields.append(field_name)
property_schema["properties"] = properties
if required_fields:
property_schema["required"] = required_fields
if self.field_name and self.field_name != Consts.ELEMENT_TYPE_INFO_SYMBOL:
property_schema["title"] = self.field_name
# Add description
if self.original_type: