Documentation Index
Fetch the complete documentation index at: https://docs.apivalk.com/llms.txt
Use this file to discover all available pages before exploring further.
Creating a Request
Every request class must extendAbstractApivalkRequest and implement the getDocumentation() method.
Example
Accessing Data
Data is organized into “Bags”. The framework automatically populates these bags and casts the values to the types defined in your documentation.Magic Getters
ParameterBag supports magic getters for cleaner code:
Base vs. Runtime Documentation
Every request class exposes two documentation views:- Static —
RequestClass::getDocumentation(). Returns the baseApivalkRequestDocumentationas declared by the developer. Stable and independent of the route. - Instance —
$request->getRuntimeDocumentation(). Returns the base documentation merged with route-derived metadata (pagination query params, filter fields,order_by, available sort fields). This is what theRequestValidationMiddlewarevalidates against and what the population strategies consume.
getDocumentation(). The framework builds the runtime view for you in RequestDocumentationFactory::buildRuntimeDocumentation().
Automatic Request Documentation
When a route has sorting defined or pagination enabled, the framework automatically documents the corresponding query parameters (order_by, page, limit, offset, or cursor) in your OpenAPI specification.
This includes:
- Validation: Ensuring that only allowed values and correct formats are used.
- Example generation: Showcasing correct usage for sorting and pagination.
- Default values: Reflecting the configuration defined on the route (e.g.,
setMaxLimit).
- The
sorting()bag is automatically populated with default values if the user does not provide anorder_byparameter. - The
paginator()object is automatically created and accessible if pagination is enabled.
Validation
Validation happens automatically if you use theRequestValidationMiddleware. If the incoming data does not match your getDocumentation() definition, the framework will immediately return a 422 Unprocessable Entity response with detailed error messages.
Resource Requests
For endpoints backed by a resource CRUD controller you typically don’t author a request class at all — the framework uses a single sharedResourceRequest, and the runtime documentation is derived from your AbstractResource definition. See Resources.