JsonResource classes, resource collections, Eloquent models, paginators, plain PHP objects, and raw JSON responses — all through static AST traversal with no database connection and no application boot required.
Supported Return Patterns
JsonResource Instances
When a controller returns aJsonResource instance directly or via a static factory, Geni inspects the toArray() method of that resource class:
ArticleResource:
Resource Collections
Geni recognizes bothResource::collection() calls and custom collection classes. The item resource schema is inferred and wrapped in an array response:
LengthAwarePaginator
When a controller callspaginate() on an Eloquent query or returns a paginated resource, Geni infers the complete standard Laravel pagination envelope:
data: Array of item schemas (e.g.,ArticleResourceobjects).links: Navigation URLs —first,last,prev,next.meta: Pagination metadata —current_page,from,last_page,path,per_page,to,total.
Direct Eloquent Models
If a controller directly returns an Eloquent model, Geni resolves the underlying table schema from your migrations and builds an object schema containing all model columns, respecting$hidden attributes where statically detectable:
Raw response()->json() Calls
When a controller returns a literal array via response()->json(), Geni reconstructs an object schema with matching literal keys and inferred value types:
status as type: string and timestamp as type: integer.
Component Reusability
Whenever Geni analyzes aJsonResource or Eloquent model, it registers the resulting schema under components.schemas in the OpenAPI document (e.g., #/components/schemas/ArticleResource). Subsequent references to the same resource resolve to a $ref rather than an inline schema, keeping your OpenAPI specification concise and free of duplicate definitions.