-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Docs - Disable online swagger validator #2064
Comments
It seems there is no way to customize Swagger settings, since you enforce configuration |
I have the same issue, it would be nice if we could override the online validator setting from the main config file. |
What is the exact change being proposed? How would you modify the configuration? |
@jeremystretch well according to https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md you can pass the following to Swagger-UI:
Not sure on how to implement that into Netbox. Perhaps if we can set that from configuration.py as an exported variable or something? |
So this was an issue for me too, but you can set the validatorUrl via SWAGGER_SETTINGS = {
'DEFAULT_FIELD_INSPECTORS': [
'utilities.custom_inspectors.NullableBooleanFieldInspector',
'utilities.custom_inspectors.CustomChoiceFieldInspector',
'drf_yasg.inspectors.CamelCaseJSONFilter',
'drf_yasg.inspectors.ReferencingSerializerInspector',
'drf_yasg.inspectors.RelatedFieldInspector',
'drf_yasg.inspectors.ChoiceFieldInspector',
'drf_yasg.inspectors.FileFieldInspector',
'drf_yasg.inspectors.DictFieldInspector',
'drf_yasg.inspectors.SimpleFieldInspector',
'drf_yasg.inspectors.StringDefaultFieldInspector',
],
'DEFAULT_FILTER_INSPECTORS': [
'utilities.custom_inspectors.IdInFilterInspector',
'drf_yasg.inspectors.CoreAPICompatInspector',
],
'DEFAULT_PAGINATOR_INSPECTORS': [
'utilities.custom_inspectors.NullablePaginatorInspector',
'drf_yasg.inspectors.DjangoRestResponsePagination',
'drf_yasg.inspectors.CoreAPICompatInspector',
],
'VALIDATOR_URL': None
} which sets the UI's <script id="swagger-settings" type="application/json">{"docExpansion": "list", "deepLinking": false, "showExtensions": true, "defaultModelRendering": "model", "defaultModelExpandDepth": 3, "defaultModelsExpandDepth": 3, "showCommonExtensions": true, "supportedSubmitMethods": ["get", "put", "post", "delete", "options", "head", "patch", "trace"], "validatorUrl": null}</script> Edit: I went digging through the drf-yasg docs to find this setting, it may be useful to refer to them in the Netbox docs or at least put the link in a comment in https://drf-yasg.readthedocs.io/en/stable/settings.html#validator-url |
Fixed in ef61c70 |
Issue type
[X] Feature request
[ ] Bug report
[ ] Documentation
Environment
Description
Hello,
Our instance of netbox is restricted to our internal network only, the problem is that when someone go to the API doc view (/api/docs/), the online swagger validator is triggered, and it delays the whole display of API endpoints to finally display a nice "error badge".
I don't get the point of this online validator on production environnement ...
Thank you
The text was updated successfully, but these errors were encountered: