How to hide model definition from swagger and only show APIs.
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',
],
...
}
Most helpful comment
To disable globally, replace
ReferencingSerializerInspectorwithInlineSerializerInspector. To disable for just one model, setref_name =Noneon the serializer Meta.