datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

feat: msgspec discriminated unions

Open indrat opened this issue 1 year ago • 2 comments

adds support for:

  • adding base class kwargs to the msgpsec template in order to support adding tag and tag_field kwargs for Struct.
  • the discriminator property, uses the propertyName as the tag_field and the literal value as the tag.

this may not be the ideal method for doing this so happy for any feedback to improve it.

aiming to address #1610

indrat avatar Sep 01 '24 11:09 indrat

CodSpeed Performance Report

Merging #2081 will not alter performance

Comparing indrat:discriminated-unions-msgspec-support (c56c569) with main (6c3e114)

Summary

✅ 30 untouched benchmarks

codspeed-hq[bot] avatar Sep 01 '24 11:09 codspeed-hq[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (6c3e114) to head (c56c569). Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2081   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           38        38           
  Lines         4263      4273   +10     
  Branches       984       986    +2     
=========================================
+ Hits          4263      4273   +10     
Flag Coverage Δ
unittests 99.67% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 01 '24 11:09 codecov[bot]