Skip to content

Fix nullable array body parameters in OpenAPI 3.0 - #1091

Open
tikhomirov wants to merge 1 commit into
knuckleswtf:v5from
tikhomirov:fix/nullable-array-openapi
Open

tikhomirov wants to merge 1 commit into
knuckleswtf:v5from
tikhomirov:fix/nullable-array-openapi

Conversation

@tikhomirov

Copy link
Copy Markdown

Summary

  • Preserve nullable: true on parent array fields when Laravel field.* sub-rules are normalised onto the same parameter name (e.g. tags + tags.*).
  • Emit nullable on the array schema in OpenAPI 3.0, not on items, so tools render array of T | null instead of array of T | null | null.

Motivation

FormRequest rules like ['nullable', 'array'] + field.* are common. Scribe already parses nullable on the parent, but convertArraySubfields() overwrote the parent with the child parameter (without nullable). BaseGenerator also applied nullable to items only.

Test plan

  • ValidationRuleParsingTest::test_preserves_nullable_on_parent_array_field_when_subfield_overwrites_name
  • OpenAPISpecWriterTest::test_uses_nullable_on_array_not_items_in_openapi30
  • Full ValidationRuleParsingTest + OpenAPISpecWriterTest suites pass locally

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant