Overview
Spatie Laravel Data (spatie/laravel-data) is widely used for type-safe Data Transfer Objects (DTOs), request validation, and API resource transformation in Laravel.
Geni provides first-class, opt-in static analysis support for spatie/laravel-data (v3 and v4). When a controller action accepts a Data class or returns one, Geni automatically generates matching OpenAPI schemas without requiring redundant Form Requests or annotations.
Request Injection
When a controller action parameter type-hints a class extendingSpatie\LaravelData\Data:
UserData class definition:
Inferred Request Body Schema
Geni automatically infers:name:type: string,minLength: 3,maxLength: 50, inrequiredarray.email:type: string,format: email, inrequiredarray.address: Nested object schema or$ref: '#/components/schemas/AddressData', not required (default is null).bio:type: string, not required (typed asOptional).
Response Transformation
Geni automatically recognizes Data responses across all common usage patterns:UserData::collect(...), Geni documents a 200 response with type: array whose items match the UserData schema.
Supported Validation Attributes
Geni statically parses attributes fromSpatie\LaravelData\Attributes\Validation\*:
Zero Runtime Dependency
Geni never requiresspatie/laravel-data in your production environment. If a project does not use Spatie Data, Geni ignores Data classes with zero runtime impact.