dandi / dandi-schema

Schemata for DANDI archive project
Apache License 2.0
7 stars 10 forks source link

Customize JSON schema generation for `Literal` fields of Pydantic models #227

Closed candleindark closed 9 months ago

candleindark commented 9 months ago

This PR adds customization to the generation of JSON schema for the fields of Pydantic models that are of Literal type. Basically, this customization ensures that the JSON schema for a Literal field of a Pydantic model has a type key.

This customization revert change 3v entailed by Pydantic V2 listed in the top post of #203. Hopefully, it will also satisfy @satra's request at https://github.com/dandi/dandi-archive/commit/b3db2310632782ccac935b3a680818fe765ae8e7#commitcomment-138484018.

codecov[bot] commented 9 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (08d92c8) 97.66% compared to head (8e24b33) 91.57%.

Files Patch % Lines
dandischema/utils.py 47.05% 9 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #227 +/- ## ========================================== - Coverage 97.66% 91.57% -6.10% ========================================== Files 18 18 Lines 1799 1816 +17 ========================================== - Hits 1757 1663 -94 - Misses 42 153 +111 ``` | [Flag](https://app.codecov.io/gh/dandi/dandi-schema/pull/227/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dandi) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/dandi/dandi-schema/pull/227/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dandi) | `91.57% <50.00%> (-6.10%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dandi#carryforward-flags-in-the-pull-request-comment) to find out more.

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

candleindark commented 9 months ago

As stated in https://github.com/dandi/dandi-archive/commit/b3db2310632782ccac935b3a680818fe765ae8e7#commitcomment-138536168, this PR is really not needed at all if the UI is able to construed the type of the value from the expression of the value in JSON.

candleindark commented 9 months ago

This PR is not needed per https://github.com/dandi/dandi-archive/commit/b3db2310632782ccac935b3a680818fe765ae8e7#commitcomment-138536466.