Skip to content

fix: prevent nullable from triggering oneOf wrapping in JMSModelDescriber#2693

Open
lacatoire wants to merge 2 commits intonelmio:5.xfrom
lacatoire:fix/jms-nullable-custom-fields
Open

fix: prevent nullable from triggering oneOf wrapping in JMSModelDescriber#2693
lacatoire wants to merge 2 commits intonelmio:5.xfrom
lacatoire:fix/jms-nullable-custom-fields

Conversation

@lacatoire
Copy link
Contributor

@lacatoire lacatoire commented Feb 20, 2026

Summary

  • When a JMS property has a #[Assert\NotNull] constraint, SymfonyConstraintAnnotationReader sets nullable=false on the OA property. This caused jsonSerialize() to return a non-empty $customFields array, which triggered unnecessary oneOf wrapping instead of a simple $ref
  • Exclude nullable from the custom fields check (like property is already excluded), restoring the correct $ref output
  • Added a test with a #[Assert\NotNull] property on JMSUser to prevent regression

Fixes #2565

…iber

When a JMS property has a #[Assert\NotNull] constraint, the
SymfonyConstraintAnnotationReader sets nullable=false on the OA property.
This caused jsonSerialize() to return a non-empty customFields array,
which triggered unnecessary oneOf wrapping instead of a simple $ref.

Exclude nullable from the custom fields check, same as property is
already excluded. This restores the correct $ref output for JMS
properties with NotNull constraints.

Fixes nelmio#2565
The notNullFriend property with #[Assert\NotNull] correctly marks the
field as required in the generated schema. Update the JSON fixture and
test assertion to match.
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.59%. Comparing base (e651ed9) to head (56f72a2).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##              5.x    #2693   +/-   ##
=======================================
  Coverage   95.59%   95.59%           
=======================================
  Files          94       94           
  Lines        3064     3066    +2     
=======================================
+ Hits         2929     2931    +2     
  Misses        135      135           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lacatoire lacatoire changed the title fix: prevent nullable from triggering oneOf wrapping in JMSModelDescriber fix: JMS nullable oneOf wrapping, model name clash & docs for Flex UI route Feb 20, 2026
@lacatoire lacatoire force-pushed the fix/jms-nullable-custom-fields branch from 7adad9e to 56f72a2 Compare February 20, 2026 15:48
@lacatoire lacatoire changed the title fix: JMS nullable oneOf wrapping, model name clash & docs for Flex UI route fix: prevent nullable from triggering oneOf wrapping in JMSModelDescriber Feb 20, 2026
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.

[Bug]: JMSModelDescriber works badly with customFields

1 participant