Skip to content
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

Make it possible to include "unused" models in the generated swagger documentation #90

Closed
volfpeter opened this issue Mar 17, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@volfpeter
Copy link

Hi,

We use flask-accepts (marshmallow+flask-restx) to document and marshal our API. We would like to use the same tools to validate our custom JSON headers, but currently these extra models can't appear in the generated documentation because they are not a payload on any of our API endpoints.

Possible solution:

Add this bit of code to Swagger.as_dict() in flask_restx/swagger.py:

# should_add_unused_models could come from a RESTX_INCLUDE_ALL_MODELS env var, default is False
if should_add_unused_models:
    for m in self.api.models:
        self.register_model(m)

If you feel this request is reasonable, I would be happy to contribute a PR.

Thanks!

@volfpeter volfpeter added the enhancement New feature or request label Mar 17, 2020
@volfpeter
Copy link
Author

I've submitted the pull request that implements this feature. Could you please have a look at the issue and PR? Thanks!

ziirish added a commit that referenced this issue Apr 12, 2020
Make it possible to include "unused" models in the generated swagger documentation, refs #90
@volfpeter
Copy link
Author

Status: the feature is ready, I'll add the documentation for this feature once the rest of the RESTX_ options are documented.

@ziirish
Copy link
Contributor

ziirish commented Apr 12, 2020

Addressed in #104

@ziirish ziirish closed this as completed Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants