GeoJSON object no longer receives a default type
Closed this issue · 1 comments
After upgrading from 0.4.3
to 0.6.2
the validation raises an exception for type
in FeatureCollection
, Feature
and Point
, in our code but also for the Usage example in the readme.md.
At version 0.4.3
GeoJSON objects received a default see below:
class FeatureCollection(GenericModel, Generic[Geom, Props], GeoInterfaceMixin):
"""FeatureCollection Model"""
type: str = Field("FeatureCollection", const=True)
The type
field changed in 0.6.0
to a Literal
and the default is removed:
class FeatureCollection(GenericModel, Generic[Geom, Props], GeoInterfaceMixin):
"""FeatureCollection Model"""
type: Literal["FeatureCollection"]
When I read the spec: A GeoJSON object has a member with the name "type". The value of the member MUST be one of the GeoJSON types.
, I think that it should receive a default. If that would be the case then it could be changed to:
class FeatureCollection(GenericModel, Generic[Geom, Props], GeoInterfaceMixin):
"""FeatureCollection Model"""
type: Literal["FeatureCollection"] = "FeatureCollection"
If this would be an issue, then it would be necessary to also change it for the other types: Feature
and Point
as well.
Hi @Jeffrey-Vervoort-KNMI
Sorry for the frustration, we changed this knowing it will be quite a breaking change but we also wanted to make sure the library was following the specification to the letter. (https://github.com/developmentseed/geojson-pydantic/blob/main/CHANGELOG.md#060a0---2023-04-04)
ref: #92 (comment)
a Feature, FeatureCollection and Geometry dictionary should have a type. If not we cannot discriminate between them. We do think that this make the library more robust but we also understand that this was a big breaking change
also already discussed in #124
Thanks for pointing out the error in the Readme, It will be fixed