With the default PrimaryKeyRelatedFieldConverter (https://github.com/maykinmedia/drf-jsonschema-serializer/blob/main/drf_jsonschema_serializer/converters.py#L267), using PrimaryKeyRelatedField with a foreign key field which does not use Integer primary keys creates an incorrect schema with {"type": "integer"}.
A potential fix could look something like this, however I haven't found a good method to test for all string-based fields:
@converter
class PrimaryKeyRelatedFieldConverter:
"""Custom primary key field converter which is aware of non-integer based PKs
This is not an exhaustive fix for other non-int PKs, however in authentik we either
use UUIDs or ints"""
field_class = PrimaryKeyRelatedField
def convert(self, field: PrimaryKeyRelatedField):
model: Model = field.queryset.model
pk_field = model._meta.pk
if isinstance(pk_field, fields.UUIDField):
return {"type": "string", "format": "uuid"}
return {"type": "integer"}
With the default
PrimaryKeyRelatedFieldConverter(https://github.com/maykinmedia/drf-jsonschema-serializer/blob/main/drf_jsonschema_serializer/converters.py#L267), usingPrimaryKeyRelatedFieldwith a foreign key field which does not use Integer primary keys creates an incorrect schema with{"type": "integer"}.A potential fix could look something like this, however I haven't found a good method to test for all string-based fields: