Skip to content

Commit bdf902d

Browse files
authored
feat: add stapi_type and stapi_version (#54)
## What I'm changing - Added `stapi_type` and `stapi_version` to order and product, closing #53 - Added `STAPI_VERSION` constant to **stapi-pydantic** ## Checklist - [x] Tests pass: `uv run pytest` - [x] Checks pass: `uv run pre-commit --all-files` - [x] CHANGELOG is updated (if necessary)
1 parent 057aa5a commit bdf902d

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
CORE = "https://stapi.example.com/v0.1.0/core"
2-
OPPORTUNITIES = "https://stapi.example.com/v0.1.0/opportunities"
3-
ASYNC_OPPORTUNITIES = "https://stapi.example.com/v0.1.0/async-opportunities"
1+
from stapi_pydantic.constants import STAPI_VERSION
2+
3+
CORE = f"https://stapi.example.com/v{STAPI_VERSION}/core"
4+
OPPORTUNITIES = f"https://stapi.example.com/v{STAPI_VERSION}/opportunities"
5+
ASYNC_OPPORTUNITIES = f"https://stapi.example.com/v{STAPI_VERSION}/async-opportunities"

stapi-pydantic/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- `stapi_type` and `stapi_version` ([#54](https://github.com/stapi-spec/pystapi/pull/54))
12+
913
## [0.0.2] - 2025-04-02
1014

1115
### Changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
STAPI_VERSION = "0.1.0"
2+
"""The default STAPI version for this library."""

stapi-pydantic/src/stapi_pydantic/order.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
field_validator,
1414
)
1515

16+
from .constants import STAPI_VERSION
1617
from .datetime_interval import DatetimeInterval
1718
from .filter import CQL2Filter
1819
from .opportunity import OpportunityProperties
@@ -84,6 +85,8 @@ class Order[T: OrderStatus](_GeoJsonBase):
8485
# retrieve them via the API
8586
id: StrictStr
8687
type: Literal["Feature"] = "Feature"
88+
stapi_type: Literal["Order"] = "Order"
89+
stapi_version: str = STAPI_VERSION
8790

8891
geometry: Geometry = Field(...)
8992
properties: OrderProperties[T] = Field(...)

stapi-pydantic/src/stapi_pydantic/product.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from pydantic import AnyHttpUrl, BaseModel, Field
55

6+
from .constants import STAPI_VERSION
67
from .shared import Link
78

89
type Constraints = BaseModel
@@ -28,7 +29,9 @@ def __init__(self, url: AnyHttpUrl | str, **kwargs: Any) -> None:
2829

2930

3031
class Product(BaseModel):
31-
type_: Literal["Product"] = Field(default="Product", alias="type")
32+
type_: Literal["Collection"] = Field(default="Collection", alias="type")
33+
stapi_type: Literal["Product"] = "Product"
34+
stapi_version: str = STAPI_VERSION
3235
conformsTo: list[str] = Field(default_factory=list)
3336
id: str
3437
title: str = ""

0 commit comments

Comments
 (0)