-
-
Notifications
You must be signed in to change notification settings - Fork 888
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
Schema: Remove hardcoded enum values from customizable fields #9318
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #9318 +/- ##
=======================================
Coverage 86.09% 86.10%
=======================================
Files 1205 1205
Lines 52743 52757 +14
Branches 2258 2258
=======================================
+ Hits 45410 45427 +17
+ Misses 6751 6748 -3
Partials 582 582
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Looking at the schema diff, we are losing a lot of information about formatting (currencies are always three letters capitalised, for example), sample values, etc. |
There are still enum status fields alongside the status_custom_key fields that I stripped the enums off of, but I agree it's less clear what the currency field accepts when it's just a string. It looks like the |
@matmair Annotating examples onto the API everywhere currency is used hits a bunch of places (39 objects, so at least that many operations would need to be annotated), and annotated examples don't update with code changes so it would be a nightmare to maintain. Since I can't change the This results in the following schema changes as a sample (diff from master to the branch linked above): currency:
- allOf:
- - $ref: '#/components/schemas/SalePriceCurrencyEnum'
+ type: string
description: |-
Default currency used for this supplier
* `AUD` - Australian Dollar
* `CNY` - Chinese Yuan
* `EUR` - Euro
* `USD` - US Dollar |
Have you checked if this can be achieved by changing the annotation of those fields? Maybe together with the schema generator we can find a more integrated approach. |
In testing against the demo dataset I ran across a handful of enum types in the schema that accept custom values, which of course breaks schema validation because the custom values weren't enumerated at schema compile time.
I did not change the serializer behavior, I simply added
extend_schema
annotations to tell the schema builder to not treat them as enumerable choices.Further work on #9045