Drf-yasg: Hide model definition

Created on 20 Dec 2018  路  3Comments  路  Source: axnsan12/drf-yasg

How to hide model definition from swagger and only show APIs.

question

Most helpful comment

To disable globally, replace ReferencingSerializerInspector with InlineSerializerInspector. To disable for just one model, set ref_name =None on the serializer Meta.

All 3 comments

To disable globally, replace ReferencingSerializerInspector with InlineSerializerInspector. To disable for just one model, set ref_name =None on the serializer Meta.

Could you please example more in details.
I have no idea how to where ReferencingSerializerInspector is to replace it with InlineSerializerInspector

Could you please example more in details.
I have no idea how to where ReferencingSerializerInspector is to replace it with InlineSerializerInspector

I added this to the settings module and it works!

SWAGGER_SETTINGS = {
    ...
    'DEFAULT_FIELD_INSPECTORS': [
        'drf_yasg.inspectors.CamelCaseJSONFilter',
        'drf_yasg.inspectors.InlineSerializerInspector',
        'drf_yasg.inspectors.RelatedFieldInspector',
        'drf_yasg.inspectors.ChoiceFieldInspector',
        'drf_yasg.inspectors.FileFieldInspector',
        'drf_yasg.inspectors.DictFieldInspector',
        'drf_yasg.inspectors.SimpleFieldInspector',
        'drf_yasg.inspectors.StringDefaultFieldInspector',
    ],
    ...
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaumard picture jaumard  路  5Comments

nicholasgcoles picture nicholasgcoles  路  4Comments

Safrone picture Safrone  路  3Comments

csdenboer picture csdenboer  路  3Comments

beaugunderson picture beaugunderson  路  5Comments