Skip to content

Commit

Permalink
fix: BinaryField's schema type should be string #505 (#506)
Browse files Browse the repository at this point in the history
* fix: BinaryField's schema type should be string #505

* fix: BinaryField's schema type should be byte #505

* fix: BinaryField's schema type should be binary #505

* revert: OpenApiTypes.BYTE #505

* fix: BinaryField's schema type should be byte #505
  • Loading branch information
jtamm-red authored Sep 8, 2021
1 parent 508f4e5 commit 22a82a1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drf_spectacular/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ def _map_model_field(self, model_field, direction):
elif hasattr(models, 'JSONField') and isinstance(model_field, models.JSONField):
# fix for DRF==3.11 with django>=3.1 as it is not yet represented in the field_mapping
return build_basic_type(OpenApiTypes.OBJECT)
elif isinstance(model_field, models.BinaryField):
return build_basic_type(OpenApiTypes.BYTE)
elif hasattr(models, model_field.get_internal_type()):
# be graceful when the model field is not explicitly mapped to a serializer
internal_type = getattr(models, model_field.get_internal_type())
Expand Down

0 comments on commit 22a82a1

Please sign in to comment.