Skip to main content

Purpose

It provides a formal definition of the successful response (HTTP 200/201), which is used to generate the OpenAPI specification. It ensures that the consumer of your API knows exactly what fields to expect in the JSON response.

Key Features

Property Definition

You add properties to the response using instances of AbstractProperty (e.g., StringProperty, IntegerProperty, FloatProperty, or reusable response objects).

Response Description

You can set a human-readable description for the response, which will appear in the Swagger UI.

Pagination Envelopes

Response pagination envelopes are produced automatically when your controller attaches a PaginationResponseInterface via $response->setPaginationResponse(...). The JsonRenderer emits the pagination key and the OpenAPI generator adds the corresponding envelope schema — no flag needs to be set on the documentation. See Pagination for the concrete response objects.

Full Example

Tip: Use Resource Responses for CRUD

If your endpoint follows the standard CRUD shape, use the pre-built Resource*Response classes instead of authoring response documentation yourself — they wire the data envelope, pagination, and OpenAPI schema from the resource definition. See Resource Responses.