Fix Rule::enum on array items replacing array type in OpenAPI spec#1123
Open
dbrekelmans wants to merge 1 commit into
Open
Fix Rule::enum on array items replacing array type in OpenAPI spec#1123dbrekelmans wants to merge 1 commit into
Rule::enum on array items replacing array type in OpenAPI spec#1123dbrekelmans wants to merge 1 commit into
Conversation
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.
Follow-up to #1119 (comment), applies the same fix to
Rule::enum.When
Rule::enumis used on array items (e.g.['array', Rule::enum(StatusEnum::class)]), the EnumRule transformer ignores the previous type and returns the enum type directly, discarding the array entirely.Before (incorrect):
{ "$ref": "#/components/schemas/StatusEnum" }After (correct):
{ "type": "array", "items": { "$ref": "#/components/schemas/StatusEnum" } }Note on test skips
The
only()andexcept()array tests use->skip(! method_exists(Enum::class, 'only'))/->skip(! method_exists(Enum::class, 'except')), because these methods were only added in Laravel 11. This matches the existing skip conditions on the non-array only/except tests.