Repository navigation
Translatable problem details, CursorPage typing, 415 for multipart - #1
Merged
Merged
Conversation
Every detail the package raises itself now comes from
resources/lang/en/problems.php through Support\Messages, which reads it
in the application's locale. Applications publish the file with
--tag=api-toolbox-lang and add lang/vendor/api-toolbox/{locale}; a
missing line falls back to English. Outside an application the English
file is read directly.
Type and title stay the same in every language, so clients can keep
branching on the type. A test checks every key the source asks for has
an English line.
CursorPage::of() took CursorPaginator<array-key, mixed>. Laravel's TKey is invariant, so the CursorPaginator<int, Model> that cursorPaginate() returns never matched, and every application calling it at a strict PHPStan level needed an ignore. CursorPage and PaginationLinks::for() are now generic over the paginator's key and value types. A fixture controller makes PHPStan check a real Eloquent call.
consumes: only looked at the raw body. PHP parses multipart/form-data into fields and files and leaves php://input empty, so a multipart upload to a JSON route had no content as far as the middleware could tell, and went through. Form fields and uploaded files now count as content. Laravel's post() test helper sends fields the same way, which is how this surfaced.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes found while moving JustSteveKing/kit onto the package. Each is its own commit.
Translatable problem details
Every
detailthe package writes itself (idempotency, negotiation, conditional requests, merge patch, digests, signatures, pagination, async) now comes fromresources/lang/en/problems.php, read in the application's locale throughSupport\Messages.php artisan vendor:publish --tag=api-toolbox-langand addlang/vendor/api-toolbox/{locale}/problems.php.Messagesreads the English file directly.typeandtitledon't change with the language, so clients keep branching ontype.detailstill pass.CursorPage typing
CursorPage::of()tookCursorPaginator<array-key, mixed>, which Eloquent'scursorPaginate()result (CursorPaginator<int, Model>) never matches, so every app at a strict PHPStan level needed an ignore.CursorPageandPaginationLinks::for()are now generic over the paginator's key and value types. A fixture controller makes PHPStan check a real Eloquent call.415 for multipart uploads
consumes:only looked at the raw body. PHP parsesmultipart/form-datainto fields and files and leavesphp://inputempty, so a multipart upload to a JSON route went through. Form fields and uploaded files now count as content.Release
No breaking changes. The behaviour change is that multipart requests to
consumes:routes are now refused when they don't match, which is what the middleware already promised. Suggest releasing asv0.3.0.2950 tests pass; PHPStan and Pint are clean.