Releases
What’s Changed
- Added support of variables used in validation rules by @chaikivskyi in #1005
- Fixed
isInstanceOfcould’ve returnednullfor template type. - Fixed infinite recursion for cases when
@mixinof the class alias is used on the same class 😵💫
New Contributors
- @chaikivskyi made their first contribution in #1005
What’s Changed
- Expose more internal type inference related APIs by @romalytvynenko in #1006
What’s Changed
- Compatibility with Scramble 0.13.x
While this release has no breaking changes itself, the resulting OpenAPI document may be more accurate for your specific application, and hence may be considered as the one containing breaking changes. Due to this, I’ve decided to mark this release as 0.13.x. It means that you’ll need to explicitly update the version in composer.json if you rely on ^0.12.0 or earlier versions.
Full type inference
Starting from Laravel 11.x (and especially from 12.x), Laravel comes with great and accurate PHPDoc annotations. With Scramble supporting these types, you’ll enjoy focusing more on the app codebase rather than writing type annotations.
use App\Models\Appointment;
Route::get('/appointments', function (Request $request) {
$items = Appointment::query()
->where('status', $request->string('status'))
->get();
return $items;
});
In this case, Scramble can infer the type of $items: it is a collection of appointments, specifically: Illuminate\Database\Eloquent\Collection<int, App\Models\Appointment>!
This gives nice documentation just by analyzing the source, without any additional annotations.
Closure-based routes support
Previously, Scramble only supported controller-based routes. Now, the routes defined using closures also get their share of love and are documented automatically.
Closure-based routes support all the attributes (for manual parameters, headers, responses, etc.) that are supported by controller-based methods.
What’s Changed
- Add closure routes support by @romalytvynenko in #971
- Infer null coalescing operator by @jrdnrc in #980
- Added analysis of types coming from PHPDoc annotations in vendor by @romalytvynenko in #988
- Support more integer types by @Neol3108 in #996
- Add
Request@usermethod support for better post-installation experience by @romalytvynenko in #1001
New Contributors
- @Neol3108 made their first contribution in #996
What’s Changed
- Added config for flattening query object parameters
- Replace api path only if it appears at the beginning
- Improve
date_formatrule documentation - Added enum names extension property support
- Add support for wildcard array keys in validation rules
What’s Changed
- Add custom
paginationInformationmethod support
What’s Changed
- Remove
MissingValuein combination with Carbon/ CarbonImmutable when transforming by @chrisvanlier2005 in #960 - Add
paginationInformationresource’s method support by @romalytvynenko in #962 - Add support for transforming @var list<T> by @chrisvanlier2005 in #961
- Pin
@stoplight/elementsto 8.4.2 to avoid tags duplication by @romalytvynenko in #964 - Add
unsetsupport and provide$paginatedtype topaginationInformationby @romalytvynenko in #968
What’s Changed
- Patch for Stoplight Elements UI dark mode 🫠 by @romalytvynenko in #953
What’s Changed
- Added
Rule::whensupport by @romalytvynenko in #951
What’s Changed
- Updated templates inference for JSON API collections
What’s Changed
- Add support
operationIdsupport viaEndpointattribute by @jrdnrc in #941 - Fix
throwstatements showing as unknown “string” type in match expressions by @finalgamer in #944 - Improve type template inference by @romalytvynenko in #948
- Fix
Rule::requiredIftreated asrequiredby @apasquini95 in #939
New Contributors
What’s Changed
- Fixed paginator links in JSON API resource collection being not marked as optional when a resource didn’t have relationships
What’s Changed
- Fixed for JSON API identifiers for resource collections relationships
- Compatibility fixes with Scramble
0.12.31by @romalytvynenko in #72
What’s Changed
- Fixed paginated data collections documentation when the type is inferred
- Correct JSON API response content type (
application/vnd.api+json) by @romalytvynenko in #70
What’s Changed
- Add support for transforming inferred paginator types by @romalytvynenko in #931
- Add support for transforming response type with headers to schema and improve collection responses type to schema transformation by @romalytvynenko in #932
- Add support for
systemcolor theme by @macbookandrew in #923
New Contributors
- @macbookandrew made their first contribution in #923
Paginated data collections inference
Previously, you had to manually specify the type of data collection returned from a controller method to generate documentation for it:
use Spatie\LaravelData\PaginatedDataCollection;
public function index(Request $request)
{
return CompanyData::collect(Company::paginate(), PaginatedDataCollection::class);
}
Now, thanks to paginated data collections inference, you can skip that second argument entirely:
public function index(Request $request)
{
return CompanyData::collect(Company::paginate());
}
What’s Changed
- Use self out type instead of self templates definition extensions
What’s Changed
- Fixed redefining types on query builder filters