-
Notifications
You must be signed in to change notification settings - Fork 338
Issue 177 #542
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
Open
TraivsBrookes96
wants to merge
4
commits into
python-restx:master
Choose a base branch
from
TraivsBrookes96:issue-177
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Issue 177 #542
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… accounts for multiple arguments as part of the form and sets the correct "consumes" values so that "multipart/form-data" gets submitted, as with a single file, when a list of files is present.
Mentioning fix of bug python-restx#177
Ensuring formatting matches that of previous updates to this document
spartan124
approved these changes
Jul 3, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can personally attest that this works, I was having issues uploading multi-part files and stumbled across this. had to add the line of code before the issues with swagger stopped. I think this PR should be approved to save time.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 10, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 14, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 14, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 14, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted. Checking for the post-patch hash is necessary when running pytest, as the unit tests run in the same process, meaning the imports remain in memory, but many of the fixtures are re-run for each test. This includes the fixture that sets up the main Flask application, so the monkey patch function was being re-executed more than once, and the hash check was failing. The fix now checks if the code matches the patched hash first, and if it does assumes the patch has already been applied and exits the monkey patching function early. Add logging messages documenting the success or failure of applying the patch.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 14, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted. Checking for the post-patch hash is necessary when running pytest, as the unit tests run in the same process, meaning the imports remain in memory, but many of the fixtures are re-run for each test. This includes the fixture that sets up the main Flask application, so the monkey patch function was being re-executed more than once, and the hash check was failing. The fix now checks if the code matches the patched hash first, and if it does assumes the patch has already been applied and exits the monkey patching function early. Add logging messages documenting the success or failure of applying the patch.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 14, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted. Checking for the post-patch hash is necessary when running pytest, as the unit tests run in the same process, meaning the imports remain in memory, but many of the fixtures are re-run for each test. This includes the fixture that sets up the main Flask application, so the monkey patch function was being re-executed more than once, and the hash check was failing. The fix now checks if the code matches the patched hash first, and if it does assumes the patch has already been applied and exits the monkey patching function early. Add logging messages documenting the success or failure of applying the patch.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 14, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted. Checking for the post-patch hash is necessary when running pytest, as the unit tests run in the same process, meaning the imports remain in memory, but many of the fixtures are re-run for each test. This includes the fixture that sets up the main Flask application, so the monkey patch function was being re-executed more than once, and the hash check was failing. The fix now checks if the code matches the patched hash first, and if it does assumes the patch has already been applied and exits the monkey patching function early. Add logging messages documenting the success or failure of applying the patch.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 14, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted. Checking for the post-patch hash is necessary when running pytest, as the unit tests run in the same process, meaning the imports remain in memory, but many of the fixtures are re-run for each test. This includes the fixture that sets up the main Flask application, so the monkey patch function was being re-executed more than once, and the hash check was failing. The fix now checks if the code matches the patched hash first, and if it does assumes the patch has already been applied and exits the monkey patching function early. Add logging messages documenting the success or failure of applying the patch.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 15, 2025
This is a terrible, horrible, no good, very bad patch that I wish I didn't have to do. However, its the only way to get the Swagger behavior we need. It applies the patch in this PR python-restx/flask-restx#542 on the flask-restx repo, however it seems unlikely it will ever be accepted. Checking for the post-patch hash is necessary when running pytest, as the unit tests run in the same process, meaning the imports remain in memory, but many of the fixtures are re-run for each test. This includes the fixture that sets up the main Flask application, so the monkey patch function was being re-executed more than once, and the hash check was failing. The fix now checks if the code matches the patched hash first, and if it does assumes the patch has already been applied and exits the monkey patching function early. Add logging messages documenting the success or failure of applying the patch.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 15, 2025
This change introduces a monkey-patch for the flask-restx `Swagger.serialize_operation` method to force Swagger to use "multipart/form-data" content type for multi-file uploads instead of "application/x-www-form-urlencoded", as required by our application. The patch applies the proposed changes from PR #542 in the flask-restx repository (python-restx/flask-restx#542), which is unlikely to be accepted into the main branch. The monkey-patch includes the following safety measures: - A hash verification system that checks the source code of `flask_restx.Swagger.serialize_operation` before applying the patch. This prevents potential issues if the underlying library code changes. - Early exit logic that detects if the patch has already been applied, preventing double-patching scenarios that were causing issues during pytest execution (where imports remain in memory but fixtures are re-run). - Logging to document whether the patch is successfully applied or skipped because it was already present. The patch is applied during application initialization through a new `monkey_patch_flask_restx()` function, which is called in the `create_app()` setup process. While this is not an ideal solution, the safeguards should sufficiently minimize risk in the absence of upstream support for this behavior.
jkglasbrenner
added a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 16, 2025
This change introduces a monkey-patch for the flask-restx `Swagger.serialize_operation` method to force Swagger to use "multipart/form-data" content type for multi-file uploads instead of "application/x-www-form-urlencoded", as required by our application. The patch applies the proposed changes from PR #542 in the flask-restx repository (python-restx/flask-restx#542), which is unlikely to be accepted into the main branch. The monkey-patch includes the following safety measures: - A hash verification system that checks the source code of `flask_restx.Swagger.serialize_operation` before applying the patch. This prevents potential issues if the underlying library code changes. - Early exit logic that detects if the patch has already been applied, preventing double-patching scenarios that were causing issues during pytest execution (where imports remain in memory but fixtures are re-run). - Logging to document whether the patch is successfully applied or skipped because it was already present. The patch is applied during application initialization through a new `monkey_patch_flask_restx()` function, which is called in the `create_app()` setup process. While this is not an ideal solution, the safeguards should sufficiently minimize risk in the absence of upstream support for this behavior.
JustKuzya
pushed a commit
to usnistgov/dioptra
that referenced
this pull request
Jan 29, 2025
This change introduces a monkey-patch for the flask-restx `Swagger.serialize_operation` method to force Swagger to use "multipart/form-data" content type for multi-file uploads instead of "application/x-www-form-urlencoded", as required by our application. The patch applies the proposed changes from PR #542 in the flask-restx repository (python-restx/flask-restx#542), which is unlikely to be accepted into the main branch. The monkey-patch includes the following safety measures: - A hash verification system that checks the source code of `flask_restx.Swagger.serialize_operation` before applying the patch. This prevents potential issues if the underlying library code changes. - Early exit logic that detects if the patch has already been applied, preventing double-patching scenarios that were causing issues during pytest execution (where imports remain in memory but fixtures are re-run). - Logging to document whether the patch is successfully applied or skipped because it was already present. The patch is applied during application initialization through a new `monkey_patch_flask_restx()` function, which is called in the `create_app()` setup process. While this is not an ideal solution, the safeguards should sufficiently minimize risk in the absence of upstream support for this behavior.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates to allow files lists, using the action="append" argument in the parser. Adds unit tests to confirm that this works, not only whilst the file list is present, but when other arguments are alongside the file list in a single form.