Overview
Geni automatically infers response schemas by analyzing what your controller actions return. It resolvesJsonResource classes, Resource Collections, Eloquent models, paginators, plain PHP objects, and raw JSON responses.
Supported Return Patterns
1. JsonResource Instances
toArray() method of ArticleResource:
2. Resource Collections
Geni recognizes bothResource::collection() calls and custom collection classes:
3. LengthAwarePaginator
When a controller callspaginate() on an Eloquent query or returns a paginated resource:
data: Array of item schemaslinks: Navigation URLs (first,last,prev,next)meta: Pagination metadata (current_page,from,last_page,path,per_page,to,total)
4. Direct Eloquent Models
If a controller directly returns an Eloquent model:$hidden attributes where detectable.
5. Raw response()->json() Calls
If a controller returns a literal array via response()->json():
Component Reusability (#/components/schemas)
Whenever a JsonResource or Eloquent model is analyzed, Geni registers the schema under components.schemas in the OpenAPI document (e.g., #/components/schemas/ArticleResource).
This prevents duplicate definitions and keeps your OpenAPI specification concise and readable.