-
Notifications
You must be signed in to change notification settings - Fork 73
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
Enable setting swagger defaultModelsExpandDepth value #67
Enable setting swagger defaultModelsExpandDepth value #67
Conversation
Thanks. This looks pretty good! A few comments:
Going further, rather than adding parameters one at a time each time a user needs one, maybe we could add the whole mapping from https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md and write a more generic code. What do you think? Care should be taken about retro-compatibility. I don't use swagger-ui and I don't know what happens when feeding an old version with a more recent parameter. |
fe76dbd
to
ecc14b8
Compare
Thanks for the feedback. I have updated the code to have consistent variable names. I agree it would be nice to have a more flexible method to maintain swagger parameters, but I'm not sure of an easy way to do that in a backward compatible method. I'll think about it and submit a new patch with ideas on that, but I thin it is beyond the scope of this specific issue. I'll take a look at the doc updates as well shortly |
Agreed. Regarding the generic method, we could maintain the mapping in here and just come up with a generic code to 1/ get parameters from config 2/ inject them in template. Ideally, we'd only inject parameters only if specified in config so that the default value is handled in swagger-ui rather than here. This would be backward compatible. |
I checked and this option seems to work with swagger-ui 3.0.20. with anything older than that flask_rest_api doesn't seem to work for me (regardless of whether this option is set) |
This PR is almost good to go. Could you please add yourself to AUTHORS.rst? Also, you could squash the 3 first commits of this PR for a nicer history but it's alright if you don't. I created a separate issue for a generic solution to expose all parameters: #69. If you want to take a stab at it, go for it.
Can you please be more explicit? I believe I checked with 2.x versions when I added the feature. If 2.x doesn't work, it should be fixed or documented. |
3741825
to
36de1ef
Compare
Sorry for the long delay. I have made the requested changes, and have clarified that this function is available in OpenAPI 3.7.0 and newer. In older versions it is a no-op |
Closing as this can now be achieved using |
OpenAPI 3.0 by default displays the 'Models' section. This is configurable via the 'defaultModelsExpandDepth' settings.
This patch provides the ability to set this value via the OPENAPI_SWAGGER_UI_DEFAULT_MODELS_EXPAND_DEPTH config
setting OPENAPI_SWAGGER_UI_DEFAULT_MODELS_EXPAND_DEPTH = -1 will disable the 'Models' section entirely
setting OPENAPI_SWAGGER_UI_DEFAULT_MODELS_EXPAND_DEPTH = 0 will collapse the 'Models' section but still display it
setting OPENAPI_SWAGGER_UI_DEFAULT_MODELS_EXPAND_DEPTH = 1 is the default and will display the models section uncollapsed