Skip to content

fix: applying scalar converters to nullable anyOf fields - #856

Open
maximeroucher wants to merge 1 commit into
epam-cross-platform-lab:masterfrom
maximeroucher:upstream/fix/scalars-converters
Open

maximeroucher wants to merge 1 commit into
epam-cross-platform-lab:masterfrom
maximeroucher:upstream/fix/scalars-converters

Conversation

@maximeroucher

Copy link
Copy Markdown
Contributor

Two fixes so custom scalars (e.g. date-time -> DateTime) work end to end, including with separate_models and nullable fields.

  • Emits import package:json_annotation/json_annotation.dart as json; in the separate-models header when scalars are configured, so the generated _$XxxJsonConverter classes (which implement json.JsonConverter) compile in the models file.
  • Applies the scalar converter annotation to nullable (anyOf) date-time properties (OpenAPI 3.1 anyOf: [date-time, null]), so they serialize through the custom scalar instead of the default DateTime handling.
  • Adds a test covering the nullable anyOf date-time property.

Fixes #804. Relates to #840.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.69%. Comparing base (a08d9a4) to head (2eecf0e).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #856      +/-   ##
==========================================
+ Coverage   63.65%   63.69%   +0.04%     
==========================================
  Files           9        9              
  Lines        1183     1179       -4     
==========================================
- Hits          753      751       -2     
+ Misses        430      428       -2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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] failed to use scalar option with separate_models

1 participant