Problem statement
Build a parcel relay application that presents itself to partners with its own name, contact, license, tag descriptions and documentation paths.
Sample Data
The relay in app/store.py starts with three parcels, under the tracking codes PR-4471, PR-4472 and PR-4488, and the two carriers that move them.
API Endpoints to Implement
create_app in app/core/application.py builds the application that app/main.py serves. Every setting below belongs there.
Service identity
- The published name is Parcel Relay API and the published version is 2.4.0.
- The published description is exactly this line, markdown included:
Partner access to the **Parcel Relay**. Terms at [relay.example.com/terms](https://relay.example.com/terms).
- The contact is published under three keys, name, url and email, holding Relay Partner Desk, https://relay.example.com/partners and partners@relay.example.com.
- The license is published under two keys, name and url, holding Apache 2.0 and https://www.apache.org/licenses/LICENSE-2.0.html.
- The published document reports all five under info, taken from the application itself, not written by hand.
Tag descriptions
The three tags the operations are filed under are published in this order, each carrying a name and a description and nothing else:
- operations, described as Service status checks.
- parcels, described as Parcels the relay has accepted.
- carriers, described as Partners that move parcels between depots.
The application carries this list itself, in this order, which is neither alphabetical nor the order the routers are attached in.
The four provided operations are filed under these tags:
- GET /parcels and GET /parcels/{tracking_code} under parcels
- GET /carriers under carriers
- GET /status under operations
Documentation paths
- The application carries three documentation paths of its own: the document at /partners/schema.json, the interactive page at /partners/docs, and the reference page at /partners/reference.
- Both pages read the document from /partners/schema.json and take their heading from the published name.
- The three framework defaults, /docs, /redoc and /openapi.json, are retired. Nothing is registered at any of them, so each answers 404 with the body {"detail": "Not Found"}.
Sample Requests & Responses
GET /parcels
Response (200 OK):
[
{"tracking_code": "PR-4471", "destination": "Aldgate Depot", "carrier_id": 1, "status": "in_transit"},
{"tracking_code": "PR-4472", "destination": "Cold Harbour", "carrier_id": 2, "status": "delivered"},
{"tracking_code": "PR-4488", "destination": "Northgate Yard", "carrier_id": 1, "status": "accepted"}
]
GET /carriers
Response (200 OK):
[
{"id": 1, "name": "Northbridge Freight", "depot": "Aldgate"},
{"id": 2, "name": "Silt Road Haulage", "depot": "Cold Harbour"}
]
GET /status
Response (200 OK):
{
"status": "ok"
}
GET /docs
Response (404 Not Found):
{
"detail": "Not Found"
}
