Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit ba130c4

Browse files
committed
standardize links on models
1 parent 5948e22 commit ba130c4

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/stapi_fastapi/models/opportunity.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from geojson_pydantic import Feature, FeatureCollection
44
from geojson_pydantic.geometries import Geometry
5-
from pydantic import BaseModel, ConfigDict
5+
from pydantic import BaseModel, ConfigDict, Field
66

77
from stapi_fastapi.models.shared import Link
88
from stapi_fastapi.types.datetime_interval import DatetimeInterval
@@ -29,8 +29,9 @@ class OpportunityRequest(BaseModel):
2929

3030
class Opportunity(Feature[G, P]):
3131
type: Literal["Feature"] = "Feature"
32-
links: list[Link] = []
32+
links: list[Link] = Field(default_factory=list)
3333

3434

3535
class OpportunityCollection(FeatureCollection[Opportunity[G, P]]):
3636
type: Literal["FeatureCollection"] = "FeatureCollection"
37+
links: list[Link] = Field(default_factory=list)

src/stapi_fastapi/models/order.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from geojson_pydantic import Feature, FeatureCollection
44
from geojson_pydantic.geometries import Geometry
5-
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
5+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
66

77
from stapi_fastapi.models.shared import Link
88
from stapi_fastapi.types.datetime_interval import DatetimeInterval
@@ -18,8 +18,9 @@ class Order(Feature[Geometry, OrderProperties]):
1818
# retrieve them via the API
1919
id: StrictInt | StrictStr # type: ignore
2020
type: Literal["Feature"] = "Feature"
21-
links: list[Link]
21+
links: list[Link] = Field(default_factory=list)
2222

2323

2424
class OrderCollection(FeatureCollection[Order]):
2525
type: Literal["FeatureCollection"] = "FeatureCollection"
26+
links: list[Link] = Field(default_factory=list)

src/stapi_fastapi/models/product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Product(BaseModel):
4141
keywords: list[str] = Field(default_factory=list)
4242
license: str
4343
providers: list[Provider] = Field(default_factory=list)
44-
links: list[Link]
44+
links: list[Link] = Field(default_factory=list)
4545

4646
# we don't want to include these in the model fields
4747
_constraints: type[OpportunityPropertiesBase]

0 commit comments

Comments
 (0)