Hi @axnsan12, cool project! I tried it out in https://github.com/yunity/karrot-backend and stumbled upon this error:
TypeError: Object of type 'CurrentUserDefault' is not JSON serializable
(full stacktrace)
One of our serializers uses DRFs CurrentUserDefault like this:
class FeedbackSerializer(serializers.ModelSerializer):
class Meta:
model = FeedbackModel
fields = ['given_by']
extra_kwargs = {'given_by': {'default': serializers.CurrentUserDefault()}}
When enabling validation, flex throws this error:
flex.exceptions.ValidationError: 'definitions':
- 'Feedback':
- 'properties':
- 'properties':
- 'given_by':
- 'default':
- "The value of `default` must be of one of the declared types for the schema. `CurrentUserDefault()` is not one of `['string']`"
- 'User':
- 'default':
- "The value of `default` must be of one of the declared types for the schema. `CurrentUserDefault()` is not one of `['object']`"
Is it feasible to add support for CurrentUserDefault into drf-yasg?
Oh, just noticed #24, so I'll close this issue again.
If it does throw an error then this issue does indeed need to be handled. As said in #24, it cannot be handled by making it work, but one would at least expect it to not crash and just not populate the default value.
I'll look into it.
Fixed and pushed 1.0.6.
Can you check if that works for your case?
It works great ✨ Thank you!