-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support all IANA mime types #82
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,9 @@ | |||
# build-mime-types | |||
|
|||
Builds a class file for ContentType enum from the IANA mime types list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the approach with code-generation based on the standards, but since there is no automation to get the latest version of those csv files - it makes the module useful just for one-time execution. I think there is no need to include it into the repository since the process of extending will be identical (update csv of the actual python enum file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where would the code live if it doesn't live in this repo?
since the process of extending will be identical (update csv of the actual python enum file)
Process:
- Download CSV files
- Run build_mime_types.py
If you delete build_mime_types.py
you'll have to add thousands of enum lines by hand or do a manual diff. Maybe I'm missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this approach, but for now it's semi-automated. I meant that if we go with code generation, then we can exclude CSV files from the git and make them downloadable directly in the script to have all the latest versions w/o manual actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case your suggestion with enum map for existing values would work fine as well, so it is up to you: update it now or leave PR as is and wait till the major version update w/o BC (but I have no time estimate on that for now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the maps. There are some open api specific content-types not listed in IANA that I added / generated and some that this library names specifically so I added logic for those to keep everything backwards compatible.
build_mime_types: Add tool to create ContentType enum from all IANA mime type CSVS pyproject.toml: Run build_mime_types.py during `poetry build` src/tests: Add more tests around mime types and adjust to mime_types.ContentType from enumeration.ContentType
9677b45
to
592423c
Compare
"multipart": "MULTIPART_ANY", | ||
"text/*": "TEXT_ANY", | ||
"video/*": "VIDEO_ANY", | ||
'text/json': "JSON_TEXT", # This isn't an OpenAPI specific mime type but it is needed as it already is in use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW: This content type is deprecated. We may want to mark as such so it can be removed later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me 👍
Overview
We have some content types in our schemas that were not supported. Instead of just adding the few we needed, I decided to grab all the IANA types as CSVs and build a tool to output the ContentType enum. I moved it out to mime_types.py as that's a generated file so, it should be kept separate.
NOTE: this should be merged after the switch to poetry PR as it is branched off that branch
Changes
build_mime_types: Add tool to create ContentType enum from all IANA mime type CSVS
pyproject.toml: Run build_mime_types.py during
poetry build
src/tests: Add more tests around mime types and adjust to mime_types.ContentType from enumeration.ContentType