Skip to main content
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 both v3 and v4. When a controller action accepts a Data class or returns one, Geni automatically generates matching OpenAPI schemas — no redundant Form Requests or manual annotations required.

Request Injection

When a controller action type-hints a class extending Spatie\LaravelData\Data, Geni inspects that class definition and builds the full request body schema from its constructor properties and validation attributes:

Inferred Request Body Schema

Geni reads each constructor property and its attributes to produce the following inferences:
  • name: type: string, minLength: 3, maxLength: 50, added to the required array.
  • email: type: string, format: email, added to the required array.
  • address: Nested object schema or $ref: '#/components/schemas/AddressData', not required (default is null).
  • bio: type: string, not required (typed as Optional).

Response Transformation

Geni automatically recognizes Data class responses across all common usage patterns:
When returning UserData::collect(...), Geni documents a 200 response with type: array whose items match the UserData schema.

Supported Validation Attributes

Geni statically parses attributes from the Spatie\LaravelData\Attributes\Validation\* namespace:
Geni never requires spatie/laravel-data in your production environment. Static analysis runs entirely at parse time. If a project does not use Spatie Data, Geni ignores Data classes with zero runtime impact.