How to remove auto generate Enum field schema in drf-spectacular
here my SPECTACULAR_SETTINGS
:
SPECTACULAR_SETTINGS = {
'TITLE': 'Python Base Code',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
'SCHEMA_PATH_PREFIX_TRIM': True,
'SERVERS': [{'url': env('SWAGGER_SERVER')},],
'PREPROCESSING_HOOKS': ["custom.url_remover.preprocessing_filter_spec"],
'COMPONENT_SPLIT_PATCH': False,
}
If you're trying to hide/remove schemas of enums (which are auto-generated) in Swagger-UI, then try this SPECTACULAR_SETTINGS
instand of yours.
SPECTACULAR_SETTINGS = {
'TITLE': 'Python Base Code',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
'SCHEMA_PATH_PREFIX_TRIM': True,
'SERVERS': [{'url': env('SWAGGER_SERVER')},],
'PREPROCESSING_HOOKS': ["custom.url_remover.preprocessing_filter_spec"],
'COMPONENT_SPLIT_PATCH': False,
'POSTPROCESSING_HOOKS': []
}
i just overwrite the default POSTPROCESSING_HOOKS
from this
'POSTPROCESSING_HOOKS': [ 'drf_spectacular.hooks.postprocess_schema_enums' ]
to this
'POSTPROCESSING_HOOKS': []
This should work