Repository navigation
Fix nullable array body parameters in OpenAPI 3.0 - #1091
Open
tikhomirov wants to merge 1 commit into
Open
tikhomirov wants to merge 1 commit into
tikhomirov wants to merge 1 commit into
Conversation
When a FormRequest uses nullable|array with item rules, parent nullable was lost during array subfield normalization and OpenAPI put nullable on items instead of the array schema, which broke UIs such as Scalar.
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.
Summary
nullable: trueon parent array fields when Laravelfield.*sub-rules are normalised onto the same parameter name (e.g.tags+tags.*).nullableon the array schema in OpenAPI 3.0, not onitems, so tools renderarray of T | nullinstead ofarray of T | null | null.Motivation
FormRequest rules like
['nullable', 'array']+field.*are common. Scribe already parsesnullableon the parent, butconvertArraySubfields()overwrote the parent with the child parameter (withoutnullable).BaseGeneratoralso appliednullabletoitemsonly.Test plan
ValidationRuleParsingTest::test_preserves_nullable_on_parent_array_field_when_subfield_overwrites_nameOpenAPISpecWriterTest::test_uses_nullable_on_array_not_items_in_openapi30ValidationRuleParsingTest+OpenAPISpecWriterTestsuites pass locally