Skip to main content

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 extending Spatie\LaravelData\Data:
Geni inspects the UserData class definition:

Inferred Request Body Schema

Geni automatically infers:
  • name: type: string, minLength: 3, maxLength: 50, in required array.
  • email: type: string, format: email, in 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 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 Spatie\LaravelData\Attributes\Validation\*:

Zero Runtime Dependency

Geni never requires spatie/laravel-data in your production environment. If a project does not use Spatie Data, Geni ignores Data classes with zero runtime impact.