Is your feature request related to a problem? Please describe.
using geo:json and geo specific requests is a powerful feature of FIWARE.
Currently, there is no validation for "geo:json"-type.
However, luckily there is already a pydantic library for geo:json.
Describe the solution you'd like
Define "geo:json" Attribute.
Enforce validation by restricting the value to the models from geojson-pydantic
Describe alternatives you've considered
Leave it to the user.
Additional context
from geojson_pydantic import (
Point,
MultiPoint,
LineString,
MultiLineString,
Polygon,
MultiPolygon,
Feature,
FeatureCollection,
)
class GeoJsonAttribute(ContextAttribute):
"""
https://fiware-orion.readthedocs.io/en/master/orion-api.html#geospatial-properties-of-entities
"""
type: Literal["geo:json"] = FieldInfo.merge_field_infos(
CustomContextAttribute.model_fields["type"],
title="Type of the GeoJSON attribute",
default="geo:json",
frozen=True,
validate_default=True,
description="Type of GeoJSON attribute.",
)
value: Union[
Point,
MultiPoint,
LineString,
MultiLineString,
Polygon,
MultiPolygon,
Feature,
FeatureCollection,
] = FieldInfo.merge_field_infos(
CustomContextAttribute.model_fields["value"],
title="GeoJSON object",
description="GeoJSON object. Allowed types are `Point`, `MultiPoint`, "
"`LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`, "
"`Feature` and `FeatureCollection`",
examples=[{"type": "Point", "coordinates": [125.6, 10.1]}],
)
Is your feature request related to a problem? Please describe. using geo:json and geo specific requests is a powerful feature of FIWARE. Currently, there is no validation for "geo:json"-type. However, luckily there is already a pydantic library for geo:json.
Describe the solution you'd like
geojson-pydantic
Describe alternatives you've considered Leave it to the user.
Additional context