Skip to content

Response body parameter is named 'description' — confusing API #1337

@sansyrox

Description

@sansyrox

Description

The Response class uses description as the parameter name for the HTTP response body:

Response(status_code=200, description='{"ok": true}', headers={...})

This is confusing because description reads like metadata or documentation, not the actual response payload. Every project using Robyn ends up writing a wrapper to avoid the cognitive overhead:

def _json_response(body: dict, status: int = 200) -> Response:
    return Response(
        status_code=status,
        description=json.dumps(body),  # "description" = body??
        headers={"Content-Type": "application/json"},
    )

Suggestion

Add body (or content) as an alias for description in the Response constructor, so both work:

# New (intuitive):
Response(status_code=200, body='{"ok": true}')

# Old (still works for backwards compat):
Response(status_code=200, description='{"ok": true}')

This is a non-breaking change — just an alias.

Environment

  • Robyn version: 0.81.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions