clarkduvall / serpy

ridiculously fast object serialization
http://serpy.readthedocs.org/en/latest/
MIT License
960 stars 62 forks source link

Expose fields such that swagger can autogenerate models/code? #53

Open shannazf opened 7 years ago

shannazf commented 7 years ago

Hi, I'm trying to use Serpy in my project. I have a very simple userprofile model that I'm testing with Serpy, which I have pasted below. I've also included two images that show the django serializer versus serpy, and how that renders in Swagger. Any idea how to make it play nicely with each other?

screen shot 2017-11-02 at 11 15 04 am screen shot 2017-11-02 at 11 16 06 am
class UserProfileSerializer(serpy.Serializer):
    class Meta:
        model = UserProfile
        fields = (
            'id',
            'user',
            'notes',
            'created_at',
            'updated_at'
        )
        read_only_fields = ('created_at', 'updated_at')

    id = serpy.Field()
    user = serpy.StrField()
    notes = serpy.StrField()
    created_at = serpy.Field()
    updated_at = serpy.Field()
ahankinson commented 6 years ago

I suspect it's related to #1

sergenp commented 2 years ago

If you're using Django Rest Framework, I have forked the repo and added swagger auto-gen for drf endpoints using drf-yasg.

You can install it via https://pypi.org/project/drf-serpy/