Skip to content

Commit

Permalink
Add support for embed object into list
Browse files Browse the repository at this point in the history
  • Loading branch information
ehooo committed Oct 1, 2024
1 parent 9c69f3b commit a2734c0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lima_api/code_generator/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def parse(self):
schema = self.parser.process_schema(snake_to_camel(self.name), self.definition)
def_type = schema.attributes if schema.type != SchemaObjectType.OBJECT else schema.name
self.models.update(schema.models)
self.embed_cls = schema.embed_cls.pop() if schema.embed_cls else None
if schema.type == SchemaObjectType.ENUM:
self.enum = schema
elif schema.enums:
Expand Down Expand Up @@ -315,6 +316,11 @@ def process_schema(self, schema_name: str, schema_data: dict) -> SchemaObject:
new_schema.models.update(obj.models)
self.models.update(obj.models)
new_schema.set_as_alias(f"list[{obj}]")
elif array_type == SchemaObjectType.OBJECT:
obj = self.process_schema(schema_name, items)
new_schema.embed_cls.append(obj)
new_schema.models.update(obj.models)
new_schema.set_as_alias(f"list[{obj.name}]")
else:
raise NotImplementedError(f"Type for list '{array_type}' not supported")
case OpenApiType.BOOLEAN:
Expand Down

0 comments on commit a2734c0

Please sign in to comment.