Skip to content

Commit dfdafa8

Browse files
committed
some progress
1 parent 3460810 commit dfdafa8

5 files changed

Lines changed: 30 additions & 48 deletions

File tree

pystapi-schema-generator/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = "Schema Generator for the Satellite Tasking API (STAPI) Specificat
55
readme = "README.md"
66
authors = [
77
{ name = "Tobias Rohnstock", email = "tobias.rohnstock@live-eo.com" },
8+
{ name = "Justin Trautmann", email = "justin@live-eo.com" },
89
]
910
requires-python = ">=3.10"
1011
dependencies = [

pystapi-schema-generator/src/pystapi_schema_generator/application.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from fastapi import FastAPI
2-
from stapi_fastapi.conformance import CORE, OPPORTUNITIES
32
from stapi_pydantic import Product
43

54
from pystapi_schema_generator.router import RootRouter
65

7-
router = RootRouter(conformances=[CORE, OPPORTUNITIES])
6+
router = RootRouter()
87
router.add_product(
98
Product(
109
id="{productId}",

pystapi-schema-generator/src/pystapi_schema_generator/router.py

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import Any
22

3-
from fastapi import APIRouter, Path, Request
4-
from stapi_fastapi.conformance import CORE
3+
from fastapi import APIRouter, Path
54
from stapi_fastapi.responses import GeoJSONResponse
65
from stapi_pydantic import (
76
Conformance,
@@ -18,27 +17,8 @@
1817

1918

2019
class RootRouter(APIRouter):
21-
def __init__(
22-
self,
23-
conformances: list[str] = [CORE],
24-
name: str = "root",
25-
openapi_endpoint_name: str = "openapi",
26-
docs_endpoint_name: str = "swagger_ui_html",
27-
*args: Any,
28-
**kwargs: Any,
29-
) -> None:
20+
def __init__(self, *args: Any, **kwargs: Any) -> None:
3021
super().__init__(*args, **kwargs)
31-
32-
self.conformances = conformances
33-
self.name = name
34-
self.openapi_endpoint_name = openapi_endpoint_name
35-
self.docs_endpoint_name = docs_endpoint_name
36-
self.product_ids: list[str] = []
37-
38-
# A dict is used to track the product routers so we can ensure
39-
# idempotentcy in case a product is added multiple times, and also to
40-
# manage clobbering if multiple products with the same product_id are
41-
# added.
4222
self.product_routers: dict[str, ProductRouter] = {}
4323

4424
# Core endpoints
@@ -47,17 +27,29 @@ def __init__(
4727
self.get_root,
4828
methods=["GET"],
4929
tags=["Core"],
50-
summary="landing page",
51-
description="...",
30+
summary="STAPI root endpoint for API discovery and metadata",
31+
description=(
32+
"This endpoint serves as the entry point for API discovery and navigation. "
33+
"Returns the STAPI root endpoint response containing the API's metadata: "
34+
"a unique identifier, descriptive text, implemented conformance classes, "
35+
"and hypermedia links to available resources and documentation."
36+
),
5237
)
5338

5439
self.add_api_route(
5540
"/conformance",
5641
self.get_conformance,
5742
methods=["GET"],
5843
tags=["Core"],
59-
summary="information about specifications that this API conforms to",
60-
description="A list of all conformance classes specified in a standard that the server conforms to.",
44+
summary="List of implemented STAPI and OGC conformance classes",
45+
description=(
46+
"Returns a list of conformance classes implemented by this API, following "
47+
"the OGC API Features conformance structure. While the core STAPI "
48+
"conformance classes are already communicated in the root endpoint, "
49+
"OGC API requires this duplicate conformance information at this "
50+
"/conformance endpoint. Includes both STAPI-specific conformance classes "
51+
"(e.g., core, order statuses, searches) and relevant OGC conformance classes."
52+
),
6153
)
6254

6355
# Orders endpoints - w/o specific {productId}/orders endpoints
@@ -105,32 +97,23 @@ def add_product(self, product: Product, *args: Any, **kwargs: Any) -> None:
10597
product_router = ProductRouter(product, self, *args, **kwargs)
10698
self.include_router(product_router, prefix=f"/products/{product.id}")
10799
self.product_routers[product.id] = product_router
108-
self.product_ids = [*self.product_routers.keys()]
109100

110-
def get_root(self, request: Request) -> RootResponse:
101+
def get_root(self) -> RootResponse:
111102
return None # type: ignore
112103

113104
def get_conformance(self) -> Conformance:
114105
return None # type: ignore
115106

116-
def get_products(self, request: Request) -> ProductsCollection:
107+
def get_products(self) -> ProductsCollection:
117108
return None # type: ignore
118109

119-
def get_orders(self, request: Request) -> OrderCollection[OrderStatus]:
110+
def get_orders(self) -> OrderCollection[OrderStatus]:
120111
return None # type: ignore
121112

122113
def get_order(
123-
self,
124-
request: Request,
125-
order_id: str = Path(alias="orderId", description="local identifier of an order"),
114+
self, order_id: str = Path(alias="orderId", description="local identifier of an order")
126115
) -> Order[OrderStatus]:
127116
return None # type: ignore
128117

129-
def get_order_statuses(
130-
self,
131-
order_id: str,
132-
request: Request,
133-
next: str | None = None,
134-
limit: int = 10,
135-
) -> OrderStatuses: # type: ignore
118+
def get_order_statuses(self, order_id: str, next: str | None = None, limit: int = 10) -> OrderStatuses: # type: ignore
136119
return None # type: ignore

stapi-pydantic/src/stapi_pydantic/conformance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
class Conformance(BaseModel):
5-
conforms_to: list[str] = Field(serialization_alias="conformsTo")
5+
conforms_to: list[str] = Field(default_factory=list, serialization_alias="conformsTo")
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from pydantic import BaseModel, Field
2-
from pydantic.json_schema import SkipJsonSchema
32

43
from .shared import Link
54

65

76
class RootResponse(BaseModel):
8-
conforms_to: list[str] = Field(serialization_alias="conformsTo")
97
id: str
10-
title: str | SkipJsonSchema[None] = None
11-
description: str
12-
links: list[Link]
8+
conformsTo: list[str] = Field(default_factory=list)
9+
title: str = ""
10+
description: str = ""
11+
links: list[Link] = Field(default_factory=list)

0 commit comments

Comments
 (0)