-
Notifications
You must be signed in to change notification settings - Fork 270
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
Fix file fields #69
Fix file fields #69
Conversation
They are binary on upload, and usually type uri in responses.
Codecov Report
@@ Coverage Diff @@
## master #69 +/- ##
==========================================
- Coverage 96.81% 96.66% -0.15%
==========================================
Files 38 38
Lines 2542 2549 +7
==========================================
+ Hits 2461 2464 +3
- Misses 81 85 +4
Continue to review full report at Codecov.
|
good point! it is the right idea, but it's not quite right yet. this is cannot be represented with one component though, as one field would have to take 2 different types depending in req/resp. luckily, there is a mode for that in spectacular, where request and repsponse are split into 2 components (if applicable):
we can wrap it in there. That mode also has some other benefits regarding |
Hmm, it sounds like you are saying the current changes in this PR are correct, but only cater for either a read-only or a write-only endpoint. wrt to File/Image, that is quite common, e.g. for sites where image uploading and page creation occurs in Django admin rather than via the API, and/or where uploads occur using separate 'direct upload to S3' apps and not through the standard model serializers. So some other additional voodoo is needed elsewhere for a read+write file field, but that voodoo depends on a non-default mode
|
yes almost. let me clarify: this does not cater exclusively to readOnly writeOnly. What it does is simply building the component twice (request/response). while building the component again, any field can differ. its a rather simple idea actually. this feature will likely stay off by default. component demultiplexing is mainly targeted to help client generation. I consider it a "hack" to take complexity out of the schema by making it more explicit. it is a global feature. imho, graceful would be to ignore the request binary part if split is turned off. that is the best we can do. the only issue that it is a problem here to make "multipart" the first option. |
have a look at this. i added a question to the FAQ for file fields to explain how to use this. on split: request: BINARY and response: URI/STR |
I found that enabling |
It would be possible to merge identical components together again, but that would be the same behavior you criticized in "disappearing enums", i.e. change one field and the "Request" component appears or disappears from the schema because they are are identical. you can't have a minimal set of components and a stable set at the same time. i suppose you can't have you cake and eat it. |
They are binary on upload, and usually type uri in responses.