ModelSerializers -> OpenAPI components/schemas/<Model> section?

36 views
Skip to first unread message

ad...@bit.io

unread,
Oct 11, 2020, 10:52:16 PM10/11/20
to Django REST framework
Hi All,

I use a number of ModelSerializers and would like my generated OpenAPI schema to have a components/schema/<Model> section that is referenced by the responseBody section of my methods. Is this possible? This will make my openapi-generater generated code much cleaner - instead of a lot of InlineType17 and so on I'd get 'MyUserModel'.


I imagine with DRF we'd see each serializer turned into a section in components/schemas/<SerializerName>. Does this feature exist?

Thanks!

-Adam


Matemática A3K

unread,
Oct 12, 2020, 1:19:31 AM10/12/20
to django-res...@googlegroups.com
Hey Adam,

That seems to be the default behavior in the current stable version, have you tried it?
 

Thanks!

-Adam


--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/27567e07-974a-4ffe-b0e8-d8dc235f3bf5n%40googlegroups.com.

Adam Fletcher

unread,
Oct 12, 2020, 1:25:43 AM10/12/20
to django-res...@googlegroups.com

Matemática A3K

unread,
Oct 12, 2020, 1:51:30 AM10/12/20
to django-res...@googlegroups.com
On Mon, Oct 12, 2020 at 12:25 AM Adam Fletcher <ad...@bit.io> wrote:


Should be the same, I'm using djangorestframework-3.12.1 and I see an output as your described desired output, so not sure why you are not seeing it (perhaps the problem is in your openapi-generater, I'm using "plain vanilla drf" (just get_schema_view), perhaps if you disable your openapi-generater and try the output from the current bundled generator, it may be easier to rebuild from there if you need more customizations)
 

Adam Fletcher

unread,
Oct 12, 2020, 12:41:56 PM10/12/20
to django-res...@googlegroups.com
Okay, this was because I was on 3.11.x - when I upgraded to 3.12.1, everything does what I expect - thanks!

-Adam




Reply all
Reply to author
Forward
0 new messages