Skip to content

Constants & tags

Typed Rel and MediaType enums that kill stringly-typed rel/type bugs, plus OpenAPI tag helpers.

Rel and MediaType

Rel and MediaType are StrEnums, so their members are strings — they drop straight into Link(rel=Rel.SELF, type=MediaType.JSON) and serialize as their plain value, while giving you autocomplete and catching typos that a bare string wouldn't. Rel covers the IANA/OGC relations (self, root, next, prev, items, collection, ...); MediaType the common types (application/json, application/geo+json, application/problem+json, ...). Full lists in the reference.

from gazebo.link import Link
from gazebo.rels import MediaType, Rel

# StrEnum members are plain strings, so they drop straight into a Link.
link = Link(
    href='https://api.example.com/items.geojson',
    rel=Rel.NEXT,
    type=MediaType.GEOJSON,
)
assert link.rel == 'next'

OpenAPI tags

Tag/TagDocs model OpenAPI tags (with external_docs serializing as externalDocs), and tags_metadata(*tags) builds the list FastAPI wants for openapi_tags. Optional sugar for grouping endpoints in the Swagger UI — reach for it once you have enough routes to want sections.

from gazebo.tags import Tag, tags_metadata

openapi_tags = tags_metadata(
    Tag(name='plants', description='Browse and create plants'),
)
# pass to FastAPI(openapi_tags=openapi_tags) to group endpoints in the docs UI

Reference

See gazebo.rels and gazebo.tags.