# Restx-Monkey
[![codecov](https://codecov.io/gh/Ryu-CZ/restx-monkey/graph/badge.svg?token=3WT6TSHPPQ)](https://codecov.io/gh/Ryu-CZ/restx-monkey)
Monkey patches for unmaintained [flask-restx](https://github.com/python-restx/flask-restx) python package to keep
your installation of flask-restx compatible with the latest [flask](https://github.com/pallets/flask)
and [werkzeug](https://github.com/pallets/werkzeug).
**Good NEWS everyone!** Package [flask-restx](https://github.com/python-restx/flask-restx) is maintained now! I strongly suggest to submit issues on official project [issues page](https://github.com/python-restx/flask-restx/issues).
## Installation
To install restx_monkey, use [pip](https://pip.pypa.io/en/stable/):
```shell
python -m pip install -U restx-monkey
```
## Usage
Before importing `flask-restx` apply all patches in your main module:
```python
# app main file
import restx_monkey as monkey
monkey.patch_restx()
# after patch import other modules
import flask_restx
# your other code
```
or select which patches you do not want to apply
```python
# app main file
import restx_monkey as monkey
monkey.patch_restx(fix_restx_api=False)
# after patch import other modules
import flask_restx
# your other code
```
### What is patched?
Here is list of patches applied to [flask-restx](https://github.com/python-restx/flask-restx) package by this monkey:
- _replace_parse_rule_ - injects `parse_rule` method into werkzeug because `flask-restx` is using this internal method
- _fix_restx_api_ - fix deprecated `flask-restx.api.Api` init of `doc` endpoints after blueprint is bound
- _fix_restx_parser_ - replace failing `flask_restx.reqparse.Argument` class with child whom can correctly handle `json`
location of argument in `flask.Request` even in HTTP `GET` callback
- _update_swagger_ui_ - replace content of `flask_restx.static` directory with the later swagger UI then restx < 1.0
- _fix_endpoint_from_view_ - fix `flask.scaffold` missing `_endpoint_from_view_func`
- _inject_versions_ - puts back `__version__` to `flask` and `werkzeug` for `3.0+` where the version was removed
## Goal of project
Keep [flask-restx](https://github.com/python-restx/flask-restx) compatible with the
latest [flask](https://github.com/pallets/flask) and [werkzeug](https://github.com/pallets/werkzeug) as long as it is
reasonable simple to monkey patch it.
### What this project is not
This project does not solve incompatibilities of other python packages
using [flask-restx](https://github.com/python-restx/flask-restx).
## Tests
You can run tests with coverage tracing:
```shell
python -m coverage run -m unittest tests/test_* -v
```
To generate coverage report:
```shell
python -m coverage html
```
## Build
Clone repo and set up your pypi repo account credentials on build for build environment.
- Move to package repo:
```shell
cd ~/git/restx_monkey
```
- Install requirements:
```shell
python -m pip install -Ur requirements.txt
```
- Clean old build fragments:
```shell
rm -rf ./dist ./build ./src/restx_monkey.egg-info
```
- Build new package:
```shell
python -m build
```
- Upload new package:
```shell
python -m twine upload dist/*
```
Raw data
{
"_id": null,
"home_page": "",
"name": "restx-monkey",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "restx,flask-restx,api,rest,flask,restplus,json,openapi,python",
"author": "",
"author_email": "Tom Trval <thandeus@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8e/ae/8a39448500d36f70be2fd9e870dc02b857b0706d054ed2d7bee0e681c79b/restx-monkey-0.6.0.tar.gz",
"platform": null,
"description": "# Restx-Monkey\n\n[![codecov](https://codecov.io/gh/Ryu-CZ/restx-monkey/graph/badge.svg?token=3WT6TSHPPQ)](https://codecov.io/gh/Ryu-CZ/restx-monkey)\n\nMonkey patches for unmaintained [flask-restx](https://github.com/python-restx/flask-restx) python package to keep\nyour installation of flask-restx compatible with the latest [flask](https://github.com/pallets/flask)\nand [werkzeug](https://github.com/pallets/werkzeug).\n\n**Good NEWS everyone!** Package [flask-restx](https://github.com/python-restx/flask-restx) is maintained now! I strongly suggest to submit issues on official project [issues page](https://github.com/python-restx/flask-restx/issues).\n\n## Installation\n\nTo install restx_monkey, use [pip](https://pip.pypa.io/en/stable/):\n\n```shell\npython -m pip install -U restx-monkey\n```\n\n## Usage\n\nBefore importing `flask-restx` apply all patches in your main module:\n\n```python\n# app main file\nimport restx_monkey as monkey\n\nmonkey.patch_restx()\n\n# after patch import other modules \nimport flask_restx\n# your other code\n```\n\nor select which patches you do not want to apply\n\n```python\n# app main file\nimport restx_monkey as monkey\n\nmonkey.patch_restx(fix_restx_api=False)\n\n# after patch import other modules \nimport flask_restx\n# your other code\n```\n\n### What is patched?\n\nHere is list of patches applied to [flask-restx](https://github.com/python-restx/flask-restx) package by this monkey:\n\n- _replace_parse_rule_ - injects `parse_rule` method into werkzeug because `flask-restx` is using this internal method\n- _fix_restx_api_ - fix deprecated `flask-restx.api.Api` init of `doc` endpoints after blueprint is bound\n- _fix_restx_parser_ - replace failing `flask_restx.reqparse.Argument` class with child whom can correctly handle `json`\n location of argument in `flask.Request` even in HTTP `GET` callback\n- _update_swagger_ui_ - replace content of `flask_restx.static` directory with the later swagger UI then restx < 1.0\n- _fix_endpoint_from_view_ - fix `flask.scaffold` missing `_endpoint_from_view_func`\n- _inject_versions_ - puts back `__version__` to `flask` and `werkzeug` for `3.0+` where the version was removed \n\n## Goal of project\n\nKeep [flask-restx](https://github.com/python-restx/flask-restx) compatible with the\nlatest [flask](https://github.com/pallets/flask) and [werkzeug](https://github.com/pallets/werkzeug) as long as it is\nreasonable simple to monkey patch it.\n\n### What this project is not\n\nThis project does not solve incompatibilities of other python packages\nusing [flask-restx](https://github.com/python-restx/flask-restx).\n\n\n## Tests\n\nYou can run tests with coverage tracing:\n\n```shell\npython -m coverage run -m unittest tests/test_* -v \n```\n\nTo generate coverage report:\n\n```shell\npython -m coverage html \n```\n\n## Build\n\nClone repo and set up your pypi repo account credentials on build for build environment.\n\n- Move to package repo:\n\n ```shell\n cd ~/git/restx_monkey\n ```\n\n- Install requirements:\n\n ```shell\n python -m pip install -Ur requirements.txt\n ```\n\n- Clean old build fragments:\n\n ```shell\n rm -rf ./dist ./build ./src/restx_monkey.egg-info\n ```\n\n- Build new package:\n\n ```shell\n python -m build\n ``` \n\n- Upload new package:\n\n ```shell\n python -m twine upload dist/* \n ```\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Monkey patches to keep flask-restx working with latest flask and werkzeug.",
"version": "0.6.0",
"project_urls": {
"Bug Tracker": "https://github.com/Ryu-CZ/restx-monkey/issues",
"Homepage": "https://github.com/Ryu-CZ/restx-monkey"
},
"split_keywords": [
"restx",
"flask-restx",
"api",
"rest",
"flask",
"restplus",
"json",
"openapi",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "982a8feeb53148c89e5dd0c82cdbba30e0c8016755cc1adbb6d2f9f3efcb3fc8",
"md5": "fd54f7b2052ac88ae8faa5ee9240bf71",
"sha256": "0af426cabbb2ced3e40de704e6b6634c31abfcaecc9b618e884d4adc3922907a"
},
"downloads": -1,
"filename": "restx_monkey-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fd54f7b2052ac88ae8faa5ee9240bf71",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 2638731,
"upload_time": "2023-10-13T08:41:42",
"upload_time_iso_8601": "2023-10-13T08:41:42.227071Z",
"url": "https://files.pythonhosted.org/packages/98/2a/8feeb53148c89e5dd0c82cdbba30e0c8016755cc1adbb6d2f9f3efcb3fc8/restx_monkey-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8eae8a39448500d36f70be2fd9e870dc02b857b0706d054ed2d7bee0e681c79b",
"md5": "d14d9f4c358cc8630d4af24df75f1347",
"sha256": "f94fd52e831297f5dbd8a34502221c0941f6f35caabec71c8f7854af60e46a7b"
},
"downloads": -1,
"filename": "restx-monkey-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "d14d9f4c358cc8630d4af24df75f1347",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 2619386,
"upload_time": "2023-10-13T08:41:44",
"upload_time_iso_8601": "2023-10-13T08:41:44.400009Z",
"url": "https://files.pythonhosted.org/packages/8e/ae/8a39448500d36f70be2fd9e870dc02b857b0706d054ed2d7bee0e681c79b/restx-monkey-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-13 08:41:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Ryu-CZ",
"github_project": "restx-monkey",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "restx-monkey"
}