Skip to content

Commit

Permalink
Add geometry discriminator. Related developmentseed#93.
Browse files Browse the repository at this point in the history
  • Loading branch information
eseglem committed Jan 31, 2023
1 parent 49af995 commit f15bb60
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions geojson_pydantic/geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import abc
from typing import Any, Dict, Iterator, List, Literal, Union

from pydantic import BaseModel, ValidationError, validator
from pydantic import BaseModel, Field, ValidationError, validator
from pydantic.error_wrappers import ErrorWrapper
from typing_extensions import Annotated

from geojson_pydantic.types import (
LinearRing,
Expand Down Expand Up @@ -208,7 +209,10 @@ def _wkt_coordinates(self) -> str:
)


Geometry = Union[Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon]
Geometry = Annotated[
Union[Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon],
Field(discriminator="type"),
]


class GeometryCollection(BaseModel):
Expand Down

0 comments on commit f15bb60

Please sign in to comment.