justapi — /docs

OpenAPI Callbacks

Callbacks define the schema for outbound requests your API makes:

from justapi import JustAPIApp
from pydantic import BaseModel

class Order(BaseModel):
    id: int
    status: str

app = JustAPIApp()

@app.post("/orders", callbacks={
    "on_order_complete": {
        "http://localhost:8000/webhook": {
            "post": {
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": Order.model_jsonschema()
                        }
                    }
                }
            }
        }
    }
})
def create_order(order: Order):
    return {"id": 1, "status": "pending"}

OpenAPI Webhooks

Define outbound webhook schemas:

@app.webhooks.post("new-order")
def new_order_webhook(order: Order):
    """
    This webhook is triggered when a new order is created.
    """
    pass

See Also

JustAPI v2.0.9 — Open Source MIT License · Built with WebTUI · GitHub

NORMAL master justapi/docs
utf-8 Top 1:1