Download the PHP package fnematov/scramble-laravel-data without Composer
On this page you can find all versions of the php package fnematov/scramble-laravel-data. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fnematov/scramble-laravel-data
More information about fnematov/scramble-laravel-data
Files in fnematov/scramble-laravel-data
Package scramble-laravel-data
Short Description Automatic generation of API documentation for Laravel applications.
License MIT
Homepage https://github.com/fnematov/scramble-laravel-data
Informations about the package scramble-laravel-data
Scramble for Laravel Data
A fork of dedoc/scramble that teaches Scramble to understand
spatie/laravel-data Data classes.
Scramble generates OpenAPI 3.1.0 documentation for a Laravel application straight from your code, without
asking you to write PHPDoc annotations. Upstream Scramble infers types from plain PHP, Eloquent models and
API resources — but it does not know about Spatie\LaravelData\Data, so a Data class used as a request
payload or returned from a controller ends up documented as a bare object. This fork fills that gap.
Heads up: this fork ships under the
Fnematov\ScrambleLaravelData\namespace, notDedoc\Scramble\. It registers the samescrambleconfig file, views and/docs/apiroutes as upstream, so install one or the other — not both.
Installation
The service provider is auto-discovered. After install you have two routes:
/docs/api— UI viewer for your documentation/docs/api.json— the OpenAPI document describing your API
By default these are available only in the local environment. You can change that
by defining the viewApiDocs gate.
What this fork adds
Data classes as request payloads
Type-hint a Data class on a controller action and its public properties are documented as the request body —
or as query parameters for GET, HEAD and DELETE routes.
A property is marked required unless its type allows null or it declares a default value.
If the Data class also defines rules(), only one schema is produced — the extractor tells Scramble's
form-request path to stand down, so you no longer get a duplicated request body.
Validation attributes become schema constraints
Spatie validation attributes are translated into real OpenAPI keywords instead of being dropped:
| Attribute | OpenAPI output |
|---|---|
#[Email] |
format: email |
#[Url] |
format: uri |
#[Uuid] / #[Ulid] |
format: uuid / format: ulid |
#[IP], #[IPv4] |
format: ipv4 |
#[IPv6] |
format: ipv6 |
#[DateFormat('Y-m-d')] |
format: date |
#[DateFormat('Y-m-d H:i:s')] |
format: date-time |
#[Min], #[Max], #[Size], #[Between] |
minLength/maxLength, minimum/maximum or minItems/maxItems, picked from the property type |
#[Regex] |
pattern, with the PHP delimiters stripped |
#[Nullable] |
nullable type |
List and paginated responses
Add the HasPaginatedResponse trait to a Data class to return documented collection responses:
paginated() documents and returns:
list() documents and returns { "items": [...] }. The item schema is a $ref to the Data class, so it
is not inlined at every call site.
Property types Scramble now resolves
- Backed enums — rendered as an
enumof their values, including arrays of enums (Status[]), which previously collapsed toarray[string] UploadedFileandUploadedFile[]—stringwithformat: binaryandcontentMediaType: application/octet-stream- Array shapes from
@vardocblocks —array{name: string, age?: int}becomes a real object schema with the right required keys, instead ofarray[string] - Collections —
array<string, T>,T[],DataCollection<T>andCollection<T> - Self-referencing
Dataclasses — emitted as a$refrather than nesting forever
Documentation
Everything not listed above behaves exactly like upstream Scramble, whose full documentation lives at scramble.dedoc.co.
Credits
Scramble is built by Roman Lytvynenko and the
dedoc team. This fork only adds the spatie/laravel-data layer on top; all
credit for the documentation generator itself belongs upstream.
License
MIT. See LICENSE.md.
All versions of scramble-laravel-data with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
myclabs/deep-copy Version ^1.12
nikic/php-parser Version ^5.0
phpstan/phpdoc-parser Version ^1.10|^2.0
spatie/laravel-data Version ^4.0
spatie/laravel-package-tools Version ^1.9.2