A FastAPI + Pydantic extension for simplifying hypermedia-driven API development.
Project description
FastAPI-HyperModel
Simple hypermedia for FastAPI
Documentation: https://jtc42.github.io/fastapi-hypermodel/
Source Code: https://github.com/jtc42/fastapi-hypermodel
FastAPI-HyperModel is a FastAPI + Pydantic extension for simplifying hypermedia-driven API development.
This module adds a new Pydantic model base-class, supporting dynamic href
generation based on object data.
Model | Response |
---|---|
class ItemSummary(HyperModel):
name: str
id: str
href = UrlFor(
"read_item", {"item_id": "<id>"}
)
|
{
"name": "Foo",
"id": "item01",
"href": "/items/item01"
}
|
class ItemSummary(HyperModel):
name: str
id: str
link = HALFor(
"read_item", {"item_id": "<id>"},
description="Read an item"
)
|
{
"name": "Foo",
"id": "item01",
"link": {
"href": "/items/item01",
"method": "GET",
"description": "Read an item"
}
}
|
Installation
pip install fastapi-hypermodel
Limitations
Currently, query parameters will not resolve correctly. When generating a resource URL, ensure all parameters passed are path parameters, not query parameters.
This is an upstream issue, being tracked here.
Attributions
Some functionality is based on Flask-Marshmallow URLFor
class.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for fastapi_hypermodel-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cb3f3db1ecd58bb54e95d6c0139ffc19821ccd7d669abdb1f769ebb42726c29 |
|
MD5 | 779921e883ff816e02e68b47f9472a4a |
|
BLAKE2b-256 | b9a05206cc8abd2074fd5a26f937e70f258ea7490d22cbc8586cd45b63a6b678 |