Skip to content

OpenAPI docs don't show query params, request body schemas, or path params from request.path_params #1333

@sansyrox

Description

@sansyrox

Summary

Robyn's auto-generated OpenAPI docs (/docs and /openapi.json) don't document:

  1. Query parameters — handlers that read request.query_params show "No parameters"
  2. Request body schemas — POST/PATCH handlers that read request.json() show no body schema
  3. Path params via request.path_params — params extracted this way don't appear in the docs, and trigger a warning

Reproduction

from robyn import Robyn, Request, Response

app = Robyn(__file__)

@app.get("/v1/items")
async def list_items(request: Request) -> Response:
    # These query params don't appear in /docs
    limit = request.query_params.get("limit", "10")
    offset = request.query_params.get("offset", "0")
    return Response(status_code=200, description="{}", headers={})

@app.post("/v1/items")
async def create_item(request: Request) -> Response:
    # This body schema doesn't appear in /docs
    body = request.json()
    name = body.get("name", "")
    return Response(status_code=201, description="{}", headers={})

@app.get("/v1/items/:item_id")
async def get_item(request: Request) -> Response:
    # This path param doesn't appear in /docs and triggers a warning
    item_id = request.path_params.get("item_id", "")
    return Response(status_code=200, description="{}", headers={})

if __name__ == "__main__":
    app.start(host="0.0.0.0", port=8000)

Observed behavior

  • /docs shows all three routes but with "No parameters" for each
  • POST /v1/items shows no request body schema
  • Startup logs:
    WARNING:robyn.router: Route '/v1/items/:item_id' declares path params {'item_id'} but handler 'get_item' doesn't use them
    

Expected behavior

  • Query params should be inferred from request.query_params.get(...) calls, or declarable via a decorator/type hint
  • Request body should be documentable (even if just as a generic JSON object)
  • Path params should work regardless of whether they're function arguments or accessed via request.path_params
  • At minimum, provide a way to annotate routes with OpenAPI metadata (params, body schema, response types)

Context

Building a production API with 30+ endpoints. The auto-generated docs are unusable because none of the parameters or schemas appear. FastAPI solves this with Pydantic models and function signatures — Robyn could offer something similar, or at least a @app.get("/path", openapi={...}) escape hatch.

Environment

  • Robyn 0.81.0
  • Python 3.13
  • macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions