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

Performance degrades on swagger after migrante from restplus #558

Open
engFelipeMonteiro opened this issue Aug 11, 2023 · 5 comments
Open
Labels
bug Something isn't working

Comments

@engFelipeMonteiro
Copy link

engFelipeMonteiro commented Aug 11, 2023

We have a backend service that is developed with restplus, it's works without a problem.
After migrated for restx we observed that some endpoints, that have big responses (>3MB) makes the tab of browser crash, and the browser suggests to interrupt
We are using restx version 1.1.0.

The response using curl work perfectly

@engFelipeMonteiro engFelipeMonteiro added the bug Something isn't working label Aug 11, 2023
@engFelipeMonteiro engFelipeMonteiro changed the title Performance degraded after migrante from restplus Performance degrades on swagger after migrante from restplus Aug 11, 2023
@peter-doggart
Copy link
Contributor

The browser part of flask-restx is provided externally by npm swagger-ui-dist and not by anything inside flask-restx which purely generates the swagger.json file for the API.

I suspect that given restplus is old, it is using a much earlier version of swagger-ui-dist hence the difference. We had to move to a newer version of that package to deal with some security vulnerabilities.

If you are rendering extremely long responses, you might want to render a custom template with syntax highlighting disabled (see swagger-api/swagger-ui#3832 and #430 (comment)) or consider paginating your output.

@engFelipeMonteiro
Copy link
Author

engFelipeMonteiro commented Aug 21, 2023

How I determine the swagger-ui-dist version on a application?

@peter-doggart
Copy link
Contributor

See https://swagger.io/docs/open-source-tools/swagger-ui/usage/version-detection/

If you are using firefox, press Ctrl+Shift+K whilst viewing your swagger docs, then enter JSON.stringify(versions) on the console. It should echo something like:

{"swaggerUi":{"version":"3.52.0","gitRevision":"gee40b00","gitDirty":true,"buildTimestamp":"Mon, 09 Aug 2021 15:13:17 GMT","machine":"ip-172-31-21-173"}}

@engFelipeMonteiro
Copy link
Author

How I could upgrade or downgrade the swagger-ui-dist version?

@peter-doggart
Copy link
Contributor

The swagger-ui-dist files are bundled inside the flask-restx version that is published on PyPi. The target version of swagger-ui-dist is detailed in the top level packages.json and installed during build by an invoke task using npm to flask_restx/static. If you download the source distribution from PyPi, you will see the extra files.

Because swagger-ui-dist is designed to be standalone, you just need to replace the files in flask_restx/static with the version you want. I would suggest you follow the instructions in CONTRIBUTING.rst to clone the project, update the packages.json file and then run inv assets which will fetch the files required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants