django-rest-framework
django-rest-framework copied to clipboard
OpenAPI schema for FileField/ImageField is always string/binary
Checklist
- [x] Raised initially as discussion https://github.com/encode/django-rest-framework/issues/6863
- [x] This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
- [x] I have reduced the issue to the simplest possible case.
Request and response schemas have the same format for FileField and ImageField:
"some_field": {
"type": "string",
"format": "binary"
}
However, it's not correct. If you look at implementation of FileField, you will see that to_representation
always returns string:
Response format should be url
or no format at all if UPLOADED_FILES_USE_URL
is false.
This was initially mentioned in https://github.com/encode/django-rest-framework/issues/6863