It seems SerializerMethodField assumes the data type of the field is a string, even if it is an int. For instance, I have this field:
num_sections = serializers.SerializerMethodField(help_text="The number of sections for this course")
def get_num_sections(self, obj) -> int:
return obj.sections.count()
However, in the auto-generated OpenAPI schema, this field shows up as a string field. Is there any way to set the proper data type for a SerializerMethodField?