You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But in the generated from_dict() method, it incorrectly tries to call List[...] as a function:
"coordinates": [
[List[LineStringCoordinatesInner].from_dict(_inner_item) for _inner_item in _item]
for _item in obj["coordinates"]
]
Model Class
class RoofLayerFeature(geojson_pydantic.Feature):
pass
Generated DTO class
class MultiPolygon(BaseModel):
"""
MultiPolygon Model
""" # noqa: E501
bbox: Optional[Bbox] = None
coordinates: List[List[Annotated[List[LineStringCoordinatesInner], Field(min_length=4)]]]
type: StrictStr
__properties: ClassVar[List[str]] = ["bbox", "coordinates", "type"]
# ...
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of MultiPolygon from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"bbox": Bbox.from_dict(obj["bbox"]) if obj.get("bbox") is not None else None,
"coordinates": [
[List[LineStringCoordinatesInner].from_dict(_inner_item) for _inner_item in _item]
for _item in obj["coordinates"]
] if obj.get("coordinates") is not None else None,
"type": obj.get("type")
})
return _obj
This leads to a runtime error since List[...] is not callable.
openapi-generator version
Generate a Python client using a schema that includes a deeply nested array (like MultiPolygon) and try to use the generated from_dict() method. It will fail due to misuse of List[...] as a constructor.
Description
openapi-generator
produces broken Python code when generating models with nested arrays, such as in aMultiPolygon
structure.The generated model looks like this:
But in the generated from_dict() method, it incorrectly tries to call List[...] as a function:
Model Class
Generated DTO class
This leads to a runtime error since List[...] is not callable.
openapi-generator version
@openapitools/[email protected]
Steps to Reproduce
Generate a Python client using a schema that includes a deeply nested array (like
MultiPolygon
) and try to use the generatedfrom_dict()
method. It will fail due to misuse ofList[...]
as a constructor.Currently I'm using fastapi + https://github.com/developmentseed/geojson-pydantic
The text was updated successfully, but these errors were encountered: