justapi — /docs

Error Messages

JustAPI returns structured error responses for validation failures:

{
  "detail": [
    {
      "type": "int_parsing",
      "loc": ["path", "item_id"],
      "msg": "Input should be a valid integer",
      "input": "foo"
    }
  ]
}

The detail array contains every validation error with: - type — error category - loc — where the error occurred (["path", "body", "query", "header"]) - msg — human-readable message - input — the value that was rejected

Debug Mode

app = JustAPIApp(debug=True)

Debug mode enables detailed tracebacks in responses.

:::warning Never use debug=True in production. It exposes internal details. :::

Common Errors

422 Validation Error

@app.get("/items/{item_id}")
def get_item(item_id: int):
    return {"item_id": item_id}

GET /items/foo returns 422 because "foo" is not a valid int.

Fix: Ensure the URL value matches the declared type.

404 Not Found

GET /nonexistent returns 404 with no body.

Fix: Check your route path and method.

405 Method Not Allowed

POST /items when only @app.get("/items") is defined returns 405.

Fix: Add the missing HTTP method decorator.

Logging

Use standard Python logging with JustAPI:

import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

@app.get("/items")
def list_items():
    logger.info("Listing items")
    return {"items": []}

See Also

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

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