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

Commit 166ca23

Browse files
author
Phil Varner
committed
Merge branch 'main' into pv/root-backend-abstraction
2 parents a151d25 + b3e4561 commit 166ca23

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ none
1414
### Changed
1515

1616
- RootBackend protocol uses `returns` library types Result and Maybe instead of exceptions.
17+
- Create Order endpoint from `.../order` to `.../orders`
18+
- Order field `id` must be a string, instead of previously allowing int. This is because while an
19+
order ID may an integral numeric value, it is not a "number" in the sense that math will be performed
20+
order ID values, so string represents this better.
1721

1822
### Deprecated
1923

src/stapi_fastapi/models/order.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
BaseModel,
99
ConfigDict,
1010
Field,
11-
StrictInt,
1211
StrictStr,
1312
)
1413

@@ -75,7 +74,7 @@ class OrderProperties(BaseModel):
7574
class Order(Feature[Geometry, OrderProperties]):
7675
# We need to enforce that orders have an id defined, as that is required to
7776
# retrieve them via the API
78-
id: StrictInt | StrictStr
77+
id: StrictStr
7978
type: Literal["Feature"] = "Feature"
8079
links: list[Link] = Field(default_factory=list)
8180

src/stapi_fastapi/routers/product_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def _create_order(
9191
]
9292

9393
self.add_api_route(
94-
path="/order",
94+
path="/orders",
9595
endpoint=_create_order,
9696
name=f"{self.root_router.name}:{self.product.id}:create-order",
9797
methods=["POST"],

tests/opportunity_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ def test_search_opportunities_response(
5858
except Exception as _:
5959
pytest.fail("response is not an opportunity collection")
6060

61-
assert_link(f"POST {url}", body, "create-order", f"/products/{product_id}/order")
61+
assert_link(f"POST {url}", body, "create-order", f"/products/{product_id}/orders")

tests/order_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def new_order_response(
4444
product_backend._allowed_payloads = create_order_allowed_payloads
4545

4646
res = stapi_client.post(
47-
f"products/{product_id}/order",
47+
f"products/{product_id}/orders",
4848
json=create_order_allowed_payloads[0].model_dump(),
4949
)
5050

tests/product_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_product_response_self_link(
3434
url, body, "order-parameters", f"/products/{product_id}/order-parameters"
3535
)
3636
assert_link(url, body, "opportunities", f"/products/{product_id}/opportunities")
37-
assert_link(url, body, "create-order", f"/products/{product_id}/order")
37+
assert_link(url, body, "create-order", f"/products/{product_id}/orders")
3838

3939

4040
@pytest.mark.parametrize("product_id", ["test-spotlight"])

0 commit comments

Comments
 (0)