julianwachholz / django-sqids

Non-intrusive sqids library for Django
https://pypi.org/project/django-sqids/
MIT License
60 stars 5 forks source link

drf-spectacular is confused about the field type #3

Closed w00kie closed 2 months ago

w00kie commented 3 months ago

When running with drf-spectacular to generate OpenAPI schemas, the field type cannot be auto-inferred and the following error pops up in the logs when accessing Redoc or Swagger schema:

Error [IssueViewSet]: could not resolve model field "epics.Issue.sqid". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string"

It still works because it defaults to a string but I think that all that's required to get clean logs is add this method to the SquidsField class:

def get_internal_type(self):
    return "CharField"

Will test and submit a PR momentarily.

julianwachholz commented 2 months ago

Closed via #4

w00kie commented 1 month ago

Can we have a new release with this fix included?

I've been pulling from my fork in the meantime but it would be nice to get this from the canonical package.

Cheers!

julianwachholz commented 1 month ago

@w00kie done!