StaffCoder
FastAPI
FastAPIFastAPI 0.139Python 3.13
7 modules · 28 challengesSign up
Module 7 · Metadata & Documentation

Branded API Metadata

easy—No data yet

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"
}

More in Metadata & Documentation

See the module
Described Path OperationsThis problem covers making a station directory explain itself to the people who call it, so that every operation it publishes arrives with a title, an explanation, the group it belongs to, a named shape for its answer, and a warning on the one route that is on its way out.—No data yeteasySchema ExamplesThis problem covers filling a service's published description with worked payloads, one for a whole order, one for each value it holds, and a named set callers can pick from, while the limits that refuse a bad order keep governing.—No data yeteasyPartner-Ready Public DocsThis problem covers publishing a service's whole public description as a contract: the name, contact and license behind it, described groupings for its operations, a title, an explanation and a lifecycle marker on each operation, worked payloads for the values it takes, its own addresses for the pages that describe it, and a fixed expectation the description is checked against.—No data yeteasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.