Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pydantic model translation #582

Merged

Conversation

kevinjacobs-delfi
Copy link
Contributor

@kevinjacobs-delfi kevinjacobs-delfi commented Mar 25, 2024

Improve pydantic model translation

  • translating pydantic field descriptions to record field docs
  • renames AvroModel.config -> AvroModel.dacite_config in order to avoid collisions with model fields
  • render record title as schema doc
  • Accept kwargs on AvroModel.avro_schema and pass to json.dumps

@kevinjacobs-delfi kevinjacobs-delfi changed the title Add support for translating pydantic descriptions to record docs Improve pydantic model translation Mar 25, 2024
Copy link
Owner

@marcosschroh marcosschroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to check the fields and schema documentation?

dataclasses_avroschema/pydantic/parser.py Outdated Show resolved Hide resolved
dataclasses_avroschema/pydantic/parser.py Outdated Show resolved Hide resolved
marcosschroh and others added 3 commits March 26, 2024 16:30
  - added test case
  - reverted changes to PydanticParser
  - added PydanticParser.get_field_metadata staticmethod called from parse_fields() to obtain description as field doc
  - added PydanticParser.generate_documentation to obtain title as record doc
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 95.23810% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 99.50%. Comparing base (1d6ef42) to head (bf7564c).
Report is 49 commits behind head on master.

Files Patch % Lines
dataclasses_avroschema/pydantic/parser.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #582      +/-   ##
==========================================
+ Coverage   99.18%   99.50%   +0.32%     
==========================================
  Files          30       33       +3     
  Lines        1712     1812     +100     
  Branches      307        0     -307     
==========================================
+ Hits         1698     1803     +105     
- Misses          6        9       +3     
+ Partials        8        0       -8     

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

@marcosschroh marcosschroh merged commit 82f53e1 into marcosschroh:master Mar 26, 2024
5 of 8 checks passed
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.

2 participants