diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index bd343344..535e5dca 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -1,6 +1,6 @@ --- name: Bug Report -about: Tell us how Flask-RESTPlus is broken +about: Tell us how Flask-RESTX is broken title: '' labels: bug assignees: '' @@ -11,7 +11,7 @@ assignees: '' - Is this something you can **debug and fix**? Send a pull request! Bug fixes and documentation fixes are welcome. - Please check if a similar issue already exists or has been closed before. Seriously, nobody here is getting paid. Help us out and take five minutes to make sure you aren't submitting a duplicate. -- Please review the [guidelines for contributing](https://github.com/noirbizarre/flask-restplus/blob/master/CONTRIBUTING.rst) +- Please review the [guidelines for contributing](https://github.com/python-restx/flask-restx/blob/master/CONTRIBUTING.rst) ### **Code** @@ -36,7 +36,7 @@ If applicable, add the stack trace produced by the error ### **Environment** - Python version - Flask version -- Flask-RESTPlus version +- Flask-RESTX version - Other installed Flask extensions ### **Additional Context** diff --git a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md index 54e75570..88e1677f 100644 --- a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md @@ -15,7 +15,7 @@ _Put an `x` in the boxes that apply_ _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._ -- [ ] I have read the [guidelines for contributing](https://github.com/noirbizarre/flask-restplus/blob/master/CONTRIBUTING.rst) +- [ ] I have read the [guidelines for contributing](https://github.com/python-restx/flask-restx/blob/master/CONTRIBUTING.rst) - [ ] All unit tests pass on my local version with my changes - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added necessary documentation (if appropriate) diff --git a/.gitignore b/.gitignore index 04ee8bf7..ebb3a6ce 100644 --- a/.gitignore +++ b/.gitignore @@ -60,5 +60,5 @@ histograms/ doc/_build/ # Specifics -flask_restplus/static +flask_restx/static node_modules diff --git a/AUTHORS.rst b/AUTHORS.rst deleted file mode 100644 index 8c7a9f6a..00000000 --- a/AUTHORS.rst +++ /dev/null @@ -1,129 +0,0 @@ -Authors -======= - -Thanks to all of Flask-RESTPlus contributors (including those of initial flask-restful): - - -- Alex Gaynor -- Alex M -- Alex Morken -- Andrew Dunham -- Andrew Widdersheim -- Andrés Martano -- Andriy Yurchuk -- Anil Kulkarni -- Antonio Dourado -- Antonio Herraiz -- Artur Rodrigues -- Axel Haustant -- Belousow Makc -- Bennett, Bryan -- Bohan Zhang -- Bryan Bennett -- Bulat Bochkariov -- Cameron Brandon White -- Catherine Devlin -- Constantin Roshchupkin -- Dan Quirk -- Daniel Kats -- Daniele Esposti -- Dario Bertini -- David Arnold -- David Baumgold -- David Boucha -- David Crawford -- Dimitris Theodorou -- Doug Black -- Evan Dale Aromin -- Frank Stratton -- Frank Stratton ☺ -- Garret Raziel -- Gary Belvin -- Gilles Dartiguelongue -- Giorgio Salluzzo -- Guillaume BINET -- Heston Liebowitz -- Jacob Magnusson -- James Booth -- James Ogura -- James Turk -- Jan Vlčinský -- Jeff Widman -- Jeremy Logan -- Joakim Ekberg -- Johannes -- Jordan Yelloz -- Josh Friend -- Joshua C. Randall -- Joshua Randall -- José Fernández Ramos -- Juan Rossi -- JuneHyeon Bae -- Kamil Gałuszka -- Kevin Burke -- Kevin Deldycke -- Kevin Funk -- Kyle Conroy -- Lance Ingle -- Lars Holm Nielsen -- Leiser Fernández Gallo -- Luiz Armesto -- Malthe Borch -- Marek Hlobil -- Matt Dainty -- Matt Wright -- Max Peterson -- Maxim -- Madhav Desetty -- Michael Hwang -- Michael Newman -- Miguel Grinberg -- Mihai Tomescu -- Nicolas Harraudeau -- Pavel Tyslyatsky -- Petrus J.v.Rensburg -- Philippe Ndiaye -- Piotr Husiatyński -- Prasanna Swaminathan -- Robert Warner -- Rod Cloutier -- Ryan Horn -- Sam Kimbrel -- Samarth Shah -- Sander Sink -- Sasha Baranov -- Saul Diez-Guerra -- Sergey Romanov -- Steve Barrau -- Sven-Hendrik Haase -- Trevor Goodyear -- Usman Ehtesham Gul -- Victor Neo -- Vlad Frolov -- Vladimir Pal -- Will Daly -- WooParadog -- Yaniv Aknin -- bret barker -- hachichaud -- jbouzekri -- justanr -- k-funk -- kelvinhammond -- kenjones -- kumy -- lyschoening -- mailto1587 -- mniebla -- mozillazg -- muchosalsa -- nachinius -- nixdata -- papaeye -- pingz -- saml -- siavashg -- silasray -- soasme -- ueg1990 -- y-p diff --git a/CHANGELOG.rst b/CHANGELOG.rst deleted file mode 100644 index dd976de8..00000000 --- a/CHANGELOG.rst +++ /dev/null @@ -1,357 +0,0 @@ -Changelog -========= - -.. currentmodule:: flask_restplus - -Current -------- - -- Ensure that exceptions raised in error handler, including programming errors, are logged (:issue:`705`, :pr:`706`) -- Import the ABCs from 'collections.abc' instead of 'collections' by default as it is deprecated since Python3.7, and in 3.8 it will stop working. Python2.7 is still supported though. -- Fix illegal characters in JSON references to model names (:issue:`651`) -- Support ``envelope`` parameter in Swagger documentation (:pr:`390`) - -0.13.0 (2019-08-12) -------------------- - -- Add new `Wildcard` fields (:pr:`255`) -- Fix ABC deprecation warnings (:pr:`580`) -- Fix `@api.expect(..., validate=False)` decorators for an :class:`Api` where `validate=True` is set on the constructor (:issue:`609`, :pr:`610`) -- Ensure `basePath` is always a path -- Hide Namespaces with all hidden Resources from Swagger documentation -- Per route Swagger documentation for multiple routes on a ``Resource`` -- Fix Swagger `duplicate mapping key` problem from conflicts between response codes given as string or integer (:issue`661`) - -0.12.1 (2018-09-28) -------------------- - -- Fix missing changelog inprevious release -- Ensure definitions with both `$ref` and description (or other property) output is valid (using `allOf`) -- Added initial specifications schemas and validation support -- Ensure empty enums are not serialized (to have a valid specification) - -0.12.0 (2018-09-27) -------------------- - -- Fix Namespace decorators (:issue:`475`) -- Do not serialize empty tags descriptions -- Ensure `consumes` is properly set when using form parameters on classes -- Ensure parameters are not duplicated (:issue:`164`, :issue:`196`, :issue:`234`) -- Publish sources distribution (:issue:`500`, :issue:`515`) -- Fix late resources registeration (:issue:`483`) -- Don't include namespaces without resources to the SWAGGER documentation (:issue:`470`) -- Add support for checkbox validation input + consistent behavior between inputs and fields. (:issue:`461`) -- Fix missing `enum34` dependency (:issue:`444`) - -0.11.0 (2018-05-16) -------------------- - -- Add authorizations parsing to namespace (:issue:`403`) -- Add vendor extensions support (:issue:`97`) -- :class:`~reqparse.RequestParser` arguments now support the ``split`` action -- Ensure default boolean value as `False` works with :class:`~reqparse.RequestParser` (:issue:`199`) -- Schema errors are not longuer hidden by `AttributeError: Api does not have __schema__ attribute` (:issue:`194`) -- Add a new :class:`~inputs.URL` validator, more flexible and precise. -- Fix error bundling (:issue:`175`, :issue:`144`) -- Help message is now added to source error message instead of string interpolation (:issue:`147`) -- Use pytest instead of nosetests -- Upgrade to Swagger-UI 3.4.0 -- Fix typo in comments -- Add an optional key argument, ``skip_none``, in :func:`marshal_with` and :func:`marshal` -- Fix masks not working correctly with Python 2.7 (:issue:`217`) -- Fixed typos in doc/scaling -- Add docs for `allow_null` and :class:`~fields.Nested` -- Add Namespace.payload -- **Breaking**: everything is unordered by default because ordering has a serious impact on performances: - - :class:`Api` and :class:`Namespace` now accept an optionnal ``ordered`` parameter - - :func:`marshal_with` and :func:`marshal` now accept an optionnal ``ordered`` parameter - -Breaking changes -~~~~~~~~~~~~~~~~ - -- Drop python 2.6 support -- Improve header handling (:issue:`119`): - - `@api.header` only document response headers on all responses - - `@api.response` accept an optionnal `headers` argument to document response specific headers - - request header are handled by the `@api.expect` decorator - -0.10.1 (2017-03-04) -------------------- - -- Fix a typo in ``__init__`` breaking ``from flask_restplus import *`` (:issue:`242`) -- Basic support for custom URL converters (:issue:`243`) -- Support custom response classes inheriting from :class:`~werkzeug.wrappers.BaseResponse` (:issue:`245`) -- Allow models to preserve order (:issue:`135`) - -0.10.0 (2017-02-12) -------------------- - -- Allows to specify a custom mount path on namespace registration -- Allow to express models as raw schemas -- Upgraded to Swagger-UI 2.2.6 -- Support Swagger-UI translations -- Fix prefix trailing slash stripping in Postman doc generation (:issue:`232`) -- Add validation for lists in the expect decorator (:issue:`231`) - -0.9.2 (2016-04-22) ------------------- - -- Same version but a PyPI bug force reupload. - -0.9.1 (2016-04-22) ------------------- - -- Added some Swagger-UI Oauth configurations: - - `SWAGGER_UI_OAUTH_CLIENT_ID` - - `SWAGGER_UI_OAUTH_REALM` - - `SWAGGER_UI_OAUTH_APP_NAME` -- Expose ``type: object`` in Swagger schemas (:issue:`157`) -- Fix an issue with error handlers (:issue:`141`) -- Fix an issue with Postman export when using OAuth (:issue:`151`) -- Miscellenaous code and documentation fixes -- Remove last flask-restful references (unless needed) and add missing attributions - -0.9.0 (2016-02-22) ------------------- - -- Make :class:`Namespace` behave like :class:`~flask.Blueprint` for :class:`~flask.Flask` -- Deprecated ``parser`` and ``body`` parameters for ``expect`` in :meth:`~Namespace.doc` decorator -- Deprecated :meth:`Model.extend` in favor of :meth:`Model.clone` -- Added the :meth:`~Namespace.param` decorator -- Honour method restrictions in Swagger documentation (:issue:`93`) -- Improved documentation - -0.8.6 (2015-12-26) ------------------- - -- Handle callable on API infos -- Handle documentation on error handlers -- Drop/merge flask_restful ``flask_restful.RequestParser`` -- Handle :class:`~reqparse.RequestParser` into :meth:`~Api.expect` decorator -- Handle schema for :mod:`~inputs` parsers -- Added some inputs: - - :class:`~inputs.email` - - :func:`~inputs.ip` - - :func:`~inputs.ipv4` - - :func:`~inputs.ipv6` - - -0.8.5 (2015-12-12) ------------------- - -- Handle mask on :class:`~fields.Polymorph` field -- Handle mask on inherited models -- Replace `flask_restful.abort` by :func:`flask_restplus.errors.abort` -- Replace `flask_restful.unpack` by :func:`flask_restplus.utils.unpack` -- **Breaking changes**: - - Renamed ``ApiModel`` into :class:`Model` - - Renamed ``ApiNamespace`` into :class:`Namespace` - - -0.8.4 (2015-12-07) ------------------- - -- Drop/merge `flask_restful.Resource` resolving a recursion problem -- Allow any `callable` as field `default`, `min`, `max`... -- Added :class:`~fields.Date` field -- Improve error handling for inconsistent masks -- Handle model level default mask -- support colons and dashes in mask field names -- **Breaking changes**: - - Renamed `exceptions` module into `errors` - - Renamed `RestException` into :class:`~errors.RestError` - - Renamed `MarshallingException` into :class:`~fields.MarshallingError` - - :class:`~fields.DateTime` field always output datetime - -0.8.3 (2015-12-05) ------------------- - -- Drop/merge flask-restful fields -- Drop/merge flask-restplus inputs -- Update Swagger-UI to version 2.1.3 -- Use minified version of Swagger-UI if ``DEBUG=False`` -- Blueprint subdomain support (static only) -- Added support for default fields mask - -0.8.2 (2015-12-01) ------------------- - -- Skip unknown fields in mask when applied on a model -- Added `*` token to fields mask (all remaining fields) -- Ensure generated endpoints does not collide -- Drop/merge flask-restful `Api.handler_error()` - -0.8.1 (2015-11-27) ------------------- - -- Refactor Swagger UI handling: - - allow to register a custom view with ``@api.documentation`` - - allow to register a custom URL with the ``doc`` parameter - - allow to disable documentation with ``doc=False`` -- Added fields mask support through header (see: :doc:`Fields Masks Documentation `) -- Expose ``flask_restful.inputs`` module on ``flask_restplus.inputs`` -- Added support for some missing fields and attributes: - - ``host`` root field (filed only if ``SERVER_NAME`` config is set) - - custom ``tags`` root field - - ``exclusiveMinimum`` and ``exclusiveMaximum`` number field attributes - - ``multipleOf`` number field attribute - - ``minLength`` and ``maxLength`` string field attributes - - ``pattern`` string field attribute - - ``minItems`` and ``maxItems`` list field attributes - - ``uniqueItems`` list field attribute -- Allow to override the default error handler -- Fixes - - -0.8.0 ------ - -- Added payload validation (initial implementation based on jsonschema) -- Added ``@api.deprecated`` to mark resources or methods as deprecated -- Added ``@api.header`` decorator shortcut to document headers -- Added Postman export -- Fix compatibility with flask-restful 0.3.4 -- Allow to specify an exemple a custom fields with ``__schema_example__`` -- Added support for ``PATCH`` method in Swagger UI -- Upgraded to Swagger UI 2.1.2 -- Handle enum as callable -- Allow to configure ``docExpansion`` with the ``SWAGGER_UI_DOC_EXPANSION`` parameter - - -0.7.2 ------ - -- Compatibility with flask-restful 0.3.3 -- Fix action=append handling in RequestParser -- Upgraded to SwaggerUI 2.1.8-M1 -- Miscellaneous fixes - - -0.7.1 ------ - -- Fix ``@api.marshal_with_list()`` keyword arguments handling. - - -0.7.0 ------ - -- Expose models and fields schema through the ``__schema__`` attribute -- Drop support for model as class -- Added ``@api.errorhandler()`` to register custom error handlers -- Added ``@api.response()`` shortcut decorator -- Fix list nested models missing in definitions - - -0.6.0 ------ - -- Python 2.6 support -- Experimental polymorphism support (single inheritance only) - - Added ``Polymorph`` field - - Added ``discriminator`` attribute support on ``String`` fields - - Added ``api.inherit()`` method -- Added ``ClassName`` field - -0.5.1 ------ - -- Fix for parameter with schema (do not set type=string) - - -0.5.0 ------ - -- Allow shorter syntax to set operation id: ``@api.doc('my-operation')`` -- Added a shortcut to specify the expected input model: ``@api.expect(my_fields)`` -- Added ``title`` attribute to fields -- Added ``@api.extend()`` to extend models -- Ensure coherence between ``required`` and ``allow_null`` for ``NestedField`` -- Support list of primitive types and list of models as body -- Upgraded to latest version of Swagger UI -- Fixes - - -0.4.2 ------ - -- Rename apidoc blueprint into restplus_doc to avoid collisions - - -0.4.1 ------ - -- Added ``SWAGGER_VALIDATOR_URL`` config parameter -- Added ``readonly`` field parameter -- Upgraded to latest version of Swagger UI - - -0.4.0 ------ - -- Port to Flask-Restful 0.3+ -- Use the default Blueprint/App mecanism -- Allow to hide some ressources or methods using ``@api.doc(False)`` or ``@api.hide`` -- Allow to globally customize the default operationId with the ``default_id`` callable parameter - -0.3.0 ------ - -- Switch to Swagger 2.0 (Major breakage) - - ``notes`` documentation is now ``description`` - - ``nickname`` documentation is now ``id`` - - new responses declaration format -- Added missing ``body`` parameter to document ``body`` input -- Last release before Flask-Restful 0.3+ compatibility switch - - -0.2.4 ------ - -- Handle ``description`` and ``required`` attributes on ``fields.List`` - -0.2.3 ------ - -- Fix custom fields registeration - -0.2.2 ------ - -- Fix model list in declaration - -0.2.1 ------ - -- Allow to type custom fields with ``Api.model`` -- Handle custom fields into ``fieds.List`` - -0.2 ---- - -- Upgraded to SwaggerUI 0.2.22 -- Support additional field documentation attributes: ``required``, ``description``, ``enum``, ``min``, ``max`` and ``default`` -- Initial support for model in RequestParser - -0.1.3 ------ - -- Fix ``Api.marshal()`` shortcut - -0.1.2 ------ - -- Added ``Api.marshal_with()`` and ``Api.marshal_list_with()`` decorators -- Added ``Api.marshal()`` shortcut - - -0.1.1 ------ - -- Use ``zip_safe=False`` for proper packaging. - - -0.1 ---- - -- Initial release diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 3e205160..92274708 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,7 +1,7 @@ Contributing ============ -flask-restplus is open-source and very open to contributions. +flask-restx is open-source and very open to contributions. If you're part of a corporation with an NDA, and you may require updating the license. See Updating Copyright below @@ -14,7 +14,7 @@ to submit reports on the `official bugtracker`_. Provide as much informations as possible to specify the issues: -- the flask-restplus version used +- the flask-restx version used - a stacktrace - installed applications list - a code sample to reproduce the issue @@ -26,7 +26,7 @@ Submitting patches (bugfix, features, ...) If you want to contribute some code: -1. fork the `official flask-restplus repository`_ +1. fork the `official flask-restx repository`_ 2. Ensure an issue is opened for your feature or bug 3. create a branch with an explicit name (like ``my-new-feature`` or ``issue-XX``) 4. do your work in it @@ -44,7 +44,7 @@ There are some rules to follow: - your code should be mostly PEP8 compatible with a 120 characters line length - your contribution should support both Python 2 and 3 (use ``tox`` to test) -You need to install some dependencies to develop on flask-restplus: +You need to install some dependencies to develop on flask-restx: .. code-block:: console @@ -76,13 +76,13 @@ and ensure the documentation is generating. $ tox -You also need to ensure your code is compliant with the flask-restplus coding standards: +You also need to ensure your code is compliant with the flask-restx coding standards: .. code-block:: console $ inv qa -To ensure everything is fine before commiting, you can launch the all in one command: +To ensure everything is fine before committing, you can launch the all in one command: .. code-block:: console @@ -91,8 +91,8 @@ To ensure everything is fine before commiting, you can launch the all in one com It will ensure the code meet the coding conventions, runs on every version on python and the documentation is properly generating. -.. _official flask-restplus repository: https://github.com/noirbizarre/flask-restplus -.. _official bugtracker: https://github.com/noirbizarre/flask-restplus/issues +.. _official flask-restx repository: https://github.com/python-restx/flask-restx +.. _official bugtracker: https://github.com/python-restx/flask-restx/issues Running a local Swagger Server ------------------------------ @@ -110,10 +110,11 @@ If you're new to NPM, also check out `nvm `_. + -Flask-RESTPlus is an extension for `Flask`_ that adds support for quickly building REST APIs. -Flask-RESTPlus encourages best practices with minimal setup. -If you are familiar with Flask, Flask-RESTPlus should be easy to pick up. +Flask-RESTX is an extension for `Flask`_ that adds support for quickly building REST APIs. +Flask-RESTX encourages best practices with minimal setup. +If you are familiar with Flask, Flask-RESTX should be easy to pick up. It provides a coherent collection of decorators and tools to describe your API and expose its documentation properly using `Swagger`_. @@ -31,34 +35,34 @@ and expose its documentation properly using `Swagger`_. Compatibility ============= -Flask-RestPlus requires Python 2.7 or 3.4+. +Flask-RESTX requires Python 2.7 or 3.4+. Installation ============ -You can install Flask-Restplus with pip: +You can install Flask-RESTX with pip: .. code-block:: console - $ pip install flask-restplus + $ pip install flask-restx or with easy_install: .. code-block:: console - $ easy_install flask-restplus + $ easy_install flask-restx Quick start =========== -With Flask-Restplus, you only import the api instance to route and document your endpoints. +With Flask-RESTX, you only import the api instance to route and document your endpoints. .. code-block:: python from flask import Flask - from flask_restplus import Api, Resource, fields + from flask_restx import Api, Resource, fields app = Flask(__name__) api = Api(app, version='1.0', title='TodoMVC API', @@ -155,8 +159,8 @@ With Flask-Restplus, you only import the api instance to route and document your Contributors ============ -Flask-RESTPlus is brought to you by @noirbizarre. Since early 2019 @SteadBytes, -@a-luna, @j5awry, @ziirish volunteered to help @noirbizarre keep the project up +Flask-RESTX is brought to you by @python-restx. Since early 2019 @SteadBytes, +@a-luna, @j5awry, @ziirish volunteered to help @python-restx keep the project up and running. Of course everyone is welcome to contribute and we will be happy to review your PR's or answer to your issues. @@ -165,7 +169,7 @@ PR's or answer to your issues. Documentation ============= -The documentation is hosted `on Read the Docs `_ +The documentation is hosted `on Read the Docs `_ .. _Flask: http://flask.pocoo.org/ @@ -174,4 +178,4 @@ The documentation is hosted `on Read the Docs `_ \ No newline at end of file +Want to contribute! That's awesome! Check out `CONTRIBUTING.rst! `_ diff --git a/bumpr.rc b/bumpr.rc index 617cc5ec..d4a672e9 100644 --- a/bumpr.rc +++ b/bumpr.rc @@ -1,5 +1,5 @@ [bumpr] -file = flask_restplus/__about__.py +file = flask_restx/__about__.py vcs = git commit = true tag = true @@ -26,7 +26,7 @@ bump = {version} ({date:%Y-%m-%d}) prepare = Current [readthedoc] -id = flask-restplus +id = flask-restx [replace] dev = ?branch=master diff --git a/coverage.rc b/coverage.rc index f989accd..062e428e 100644 --- a/coverage.rc +++ b/coverage.rc @@ -1,5 +1,5 @@ [run] -source = flask_restplus +source = flask_restx branch = True omit = /tests/* diff --git a/doc/Makefile b/doc/Makefile index 564ec88d..f4daebdf 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -85,17 +85,17 @@ qthelp: @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Flask-RESTPlus.qhcp" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Flask-RESTX.qhcp" @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Flask-RESTPlus.qhc" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Flask-RESTX.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/Flask-RESTPlus" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Flask-RESTPlus" + @echo "# mkdir -p $$HOME/.local/share/devhelp/Flask-RESTX" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Flask-RESTX" @echo "# devhelp" epub: diff --git a/doc/_static/apple-180.png b/doc/_static/apple-180.png index 70d6aeb2..1078c983 100644 Binary files a/doc/_static/apple-180.png and b/doc/_static/apple-180.png differ diff --git a/doc/_static/favicon-128.png b/doc/_static/favicon-128.png index 9224be8a..8e7cc7eb 100644 Binary files a/doc/_static/favicon-128.png and b/doc/_static/favicon-128.png differ diff --git a/doc/_static/favicon-196.png b/doc/_static/favicon-196.png index 68360f15..5727d4b6 100644 Binary files a/doc/_static/favicon-196.png and b/doc/_static/favicon-196.png differ diff --git a/doc/_static/favicon-512.png b/doc/_static/favicon-512.png new file mode 100644 index 00000000..cf5ad2ea Binary files /dev/null and b/doc/_static/favicon-512.png differ diff --git a/doc/_static/favicon-64.png b/doc/_static/favicon-64.png index 64ed856d..da2c2b50 100644 Binary files a/doc/_static/favicon-64.png and b/doc/_static/favicon-64.png differ diff --git a/doc/_static/favicon.ico b/doc/_static/favicon.ico index ef2e6cb2..b8522e3b 100644 Binary files a/doc/_static/favicon.ico and b/doc/_static/favicon.ico differ diff --git a/doc/_static/logo-512-nobg.png b/doc/_static/logo-512-nobg.png new file mode 100644 index 00000000..3ee8a3a2 Binary files /dev/null and b/doc/_static/logo-512-nobg.png differ diff --git a/doc/_static/logo-512.png b/doc/_static/logo-512.png index 65b5d47c..aaa34e91 100644 Binary files a/doc/_static/logo-512.png and b/doc/_static/logo-512.png differ diff --git a/doc/_themes/restplus/badges.html b/doc/_themes/restx/badges.html similarity index 100% rename from doc/_themes/restplus/badges.html rename to doc/_themes/restx/badges.html diff --git a/doc/_themes/restplus/layout.html b/doc/_themes/restx/layout.html similarity index 100% rename from doc/_themes/restplus/layout.html rename to doc/_themes/restx/layout.html diff --git a/doc/_themes/restplus/static/restplus.css b/doc/_themes/restx/static/restx.css similarity index 100% rename from doc/_themes/restplus/static/restplus.css rename to doc/_themes/restx/static/restx.css diff --git a/doc/_themes/restplus/theme.conf b/doc/_themes/restx/theme.conf similarity index 68% rename from doc/_themes/restplus/theme.conf rename to doc/_themes/restx/theme.conf index 09b593ee..82356eaa 100644 --- a/doc/_themes/restplus/theme.conf +++ b/doc/_themes/restx/theme.conf @@ -1,6 +1,6 @@ [theme] inherit = alabaster -stylesheet = restplus.css +stylesheet = restx.css [options] favicons= diff --git a/doc/api.rst b/doc/api.rst index c146b23d..ac50a346 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -3,7 +3,7 @@ API === -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx Core ---- @@ -24,18 +24,18 @@ Core Models ------ -.. autoclass:: flask_restplus.Model +.. autoclass:: flask_restx.Model :members: All fields accept a ``required`` boolean and a ``description`` string in ``kwargs``. -.. automodule:: flask_restplus.fields +.. automodule:: flask_restx.fields :members: Serialization ------------- -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx .. autofunction:: marshal @@ -43,42 +43,42 @@ Serialization .. autofunction:: marshal_with_field -.. autoclass:: flask_restplus.mask.Mask +.. autoclass:: flask_restx.mask.Mask :members: -.. autofunction:: flask_restplus.mask.apply +.. autofunction:: flask_restx.mask.apply Request parsing --------------- -.. automodule:: flask_restplus.reqparse +.. automodule:: flask_restx.reqparse :members: Inputs ~~~~~~ -.. automodule:: flask_restplus.inputs +.. automodule:: flask_restx.inputs :members: Errors ------ -.. automodule:: flask_restplus.errors +.. automodule:: flask_restx.errors :members: -.. autoexception:: flask_restplus.fields.MarshallingError +.. autoexception:: flask_restx.fields.MarshallingError -.. autoexception:: flask_restplus.mask.MaskError +.. autoexception:: flask_restx.mask.MaskError -.. autoexception:: flask_restplus.mask.ParseError +.. autoexception:: flask_restx.mask.ParseError Schemas ------- -.. automodule:: flask_restplus.schemas +.. automodule:: flask_restx.schemas :members: @@ -88,11 +88,11 @@ Internals These are internal classes or helpers. Most of the time you shouldn't have to deal directly with them. -.. autoclass:: flask_restplus.api.SwaggerView +.. autoclass:: flask_restx.api.SwaggerView -.. autoclass:: flask_restplus.swagger.Swagger +.. autoclass:: flask_restx.swagger.Swagger -.. autoclass:: flask_restplus.postman.PostmanCollectionV1 +.. autoclass:: flask_restx.postman.PostmanCollectionV1 -.. automodule:: flask_restplus.utils +.. automodule:: flask_restx.utils :members: diff --git a/doc/changelog.rst b/doc/changelog.rst deleted file mode 100644 index 565b0521..00000000 --- a/doc/changelog.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../CHANGELOG.rst diff --git a/doc/conf.py b/doc/conf.py index eca98e38..2e8c49d5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Flask-RESTPlus documentation build configuration file, created by +# Flask-RESTX documentation build configuration file, created by # sphinx-quickstart on Wed Aug 13 17:07:14 2014. # # This file is execfile()d with the current directory set to its @@ -51,7 +51,7 @@ master_doc = 'index' # General information about the project. -project = u'Flask-RESTPlus' +project = u'Flask-RESTX' copyright = u'2014, Axel Haustant' # The version info for the project you're documenting, acts as replacement for @@ -59,12 +59,12 @@ # built documents. # # The full version, including alpha/beta/rc tags. -release = __import__('flask_restplus').__version__ +release = __import__('flask_restx').__version__ # The short X.Y version. version = '.'.join(release.split('.')[:1]) # Github repo -issues_github_path = 'noirbizarre/flask-restplus' +issues_github_path = 'python-restx/flask-restx' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -109,7 +109,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'restplus' +html_theme = 'restx' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -118,8 +118,8 @@ 'logo': 'logo-512.png', 'logo_name': True, 'touch_icon': 'apple-180.png', - 'github_user': 'noirbizarre', - 'github_repo': 'flask-restplus', + 'github_user': 'python-restx', + 'github_repo': 'flask-restx', 'github_banner': True, 'show_related': True, 'page_width': '1000px', @@ -132,27 +132,27 @@ 'badges': [( # Gitter.im 'https://badges.gitter.im/Join%20Chat.svg', - 'https://gitter.im/noirbizarre/flask-restplus', - 'Join the chat at https://gitter.im/noirbizarre/flask-restplus' + 'https://gitter.im/python-restx', + 'Join the chat at https://gitter.im/python-restx' ), ( # Github Fork - 'https://img.shields.io/github/forks/noirbizarre/flask-restplus.svg?style=social&label=Fork', - 'https://github.com/noirbizarre/flask-restplus', + 'https://img.shields.io/github/forks/python-restx/flask-restx.svg?style=social&label=Fork', + 'https://github.com/python-restx/flask-restx', 'Github repository', ), ( # Github issues - 'https://img.shields.io/github/issues-raw/noirbizarre/flask-restplus.svg', - 'https://github.com/noirbizarre/flask-restplus/issues', + 'https://img.shields.io/github/issues-raw/python-restx/flask-restx.svg', + 'https://github.com/python-restx/flask-restx/issues', 'Github repository', ), ( # License - 'https://img.shields.io/github/license/noirbizarre/flask-restplus.svg', - 'https://github.com/noirbizarre/flask-restplus', + 'https://img.shields.io/github/license/python-restx/flask-restx.svg', + 'https://github.com/python-restx/flask-restx', 'License', ), ( # PyPI - 'https://img.shields.io/pypi/v/flask-restplus.svg', - 'https://pypi.python.org/pypi/flask-restplus', + 'https://img.shields.io/pypi/v/flask-restx.svg', + 'https://pypi.python.org/pypi/flask-restx', 'Latest version on PyPI' )] } @@ -239,7 +239,7 @@ #html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'Flask-RESTPlusdoc' +htmlhelp_basename = 'Flask-RESTXdoc' # -- Options for LaTeX output --------------------------------------------- @@ -259,7 +259,7 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'Flask-RESTPlus.tex', u'Flask-RESTPlus Documentation', + ('index', 'Flask-RESTX.tex', u'Flask-RESTX Documentation', u'Axel Haustant', 'manual'), ] @@ -289,7 +289,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'flask-restplus', u'Flask-RESTPlus Documentation', + ('index', 'flask-restx', u'Flask-RESTX Documentation', [u'Axel Haustant'], 1) ] @@ -303,8 +303,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Flask-RESTPlus', u'Flask-RESTPlus Documentation', - u'Axel Haustant', 'Flask-RESTPlus', 'One line description of project.', + ('index', 'Flask-RESTX', u'Flask-RESTX Documentation', + u'Axel Haustant', 'Flask-RESTX', 'One line description of project.', 'Miscellaneous'), ] diff --git a/doc/errors.rst b/doc/errors.rst index eaf0c281..bf30c659 100644 --- a/doc/errors.rst +++ b/doc/errors.rst @@ -1,7 +1,7 @@ Error handling ============== -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx HTTPException handling ---------------------- @@ -91,7 +91,7 @@ will output } -The Flask-RESTPlus abort helper +The Flask-RESTX abort helper ------------------------------- The :func:`errors.abort` and the :meth:`Namespace.abort` helpers @@ -100,7 +100,7 @@ but it will also add the keyword arguments to the response. .. code-block:: python - from flask_restplus import abort + from flask_restx import abort abort(400, custom='value') will return a 400 HTTP code and output @@ -209,7 +209,7 @@ It also allows for overriding the default error handler when used without parame .. note :: - Flask-RESTPlus will return a message in the error response by default. + Flask-RESTX will return a message in the error response by default. If a custom response is required as an error and the message field is not needed, it can be disabled by setting ``ERROR_INCLUDE_MESSAGE`` to ``False`` in your application config. diff --git a/doc/example.rst b/doc/example.rst index 04a0e76e..3d96ad15 100644 --- a/doc/example.rst +++ b/doc/example.rst @@ -6,7 +6,7 @@ Here is a full example of a `TodoMVC `_ API. .. code-block:: python from flask import Flask - from flask_restplus import Api, Resource, fields + from flask_restx import Api, Resource, fields from werkzeug.contrib.fixers import ProxyFix app = Flask(__name__) @@ -105,4 +105,4 @@ Here is a full example of a `TodoMVC `_ API. You can find other examples in the `github repository examples folder`_. -.. _github repository examples folder: https://github.com/noirbizarre/flask-restplus/tree/master/examples +.. _github repository examples folder: https://github.com/python-restx/flask-restx/tree/master/examples diff --git a/doc/index.rst b/doc/index.rst index d6a03e35..f1704e87 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,14 +1,14 @@ -.. Flask-RESTPlus documentation master file, created by +.. Flask-RESTX documentation master file, created by sphinx-quickstart on Wed Aug 13 17:07:14 2014. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to Flask-RESTPlus's documentation! +Welcome to Flask-RESTX's documentation! ========================================== -Flask-RESTPlus is an extension for Flask that adds support for quickly building REST APIs. -Flask-RESTPlus encourages best practices with minimal setup. -If you are familiar with Flask, Flask-RESTPlus should be easy to pick up. +Flask-RESTX is an extension for Flask that adds support for quickly building REST APIs. +Flask-RESTX encourages best practices with minimal setup. +If you are familiar with Flask, Flask-RESTX should be easy to pick up. It provides a coherent collection of decorators and tools to describe your API and expose its documentation properly (using Swagger). @@ -16,30 +16,30 @@ and expose its documentation properly (using Swagger). Compatibility ============= -flask-restplus requires Python 2.7+. +flask-restx requires Python 2.7+. Installation ============ -You can install flask-restplus with pip: +You can install flask-restx with pip: .. code-block:: console - $ pip install flask-restplus + $ pip install flask-restx or with easy_install: .. code-block:: console - $ easy_install flask-restplus + $ easy_install flask-restx Documentation ============= This part of the documentation will show you how to get started in using -Flask-RESTPlus with Flask. +Flask-RESTX with Flask. .. toctree:: :maxdepth: 2 @@ -75,7 +75,6 @@ Additional Notes :maxdepth: 2 contributing - changelog Indices and tables diff --git a/doc/installation.rst b/doc/installation.rst index 7de6fe5f..7872254f 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -3,22 +3,22 @@ Installation ============ -Install Flask-RESTPlus with ``pip``: +Install Flask-RESTX with ``pip``: .. code-block:: console - pip install flask-restplus + pip install flask-restx The development version can be downloaded from -`GitHub `_. +`GitHub `_. .. code-block:: console - git clone https://github.com/noirbizarre/flask-restplus.git - cd flask-restplus + git clone https://github.com/python-restx/flask-restx.git + cd flask-restx pip install -e .[dev,test] -Flask-RESTPlus requires Python version 2.7, 3.3, 3.4 or 3.5. +Flask-RESTX requires Python version 2.7, 3.3, 3.4 or 3.5. It's also working with PyPy and PyPy3. diff --git a/doc/logging.rst b/doc/logging.rst index 73d4f7f0..32fdb70d 100644 --- a/doc/logging.rst +++ b/doc/logging.rst @@ -1,7 +1,7 @@ Logging =============== -Flask-RESTPlus extends `Flask's logging `_ +Flask-RESTX extends `Flask's logging `_ by providing each ``API`` and ``Namespace`` it's own standard Python :class:`logging.Logger` instance. This allows separation of logging on a per namespace basis to allow more fine-grained detail and configuration. @@ -13,7 +13,7 @@ By default, these loggers inherit configuration from the Flask application objec import flask - from flask_restplus import Api, Resource + from flask_restx import Api, Resource # configure root logger logging.basicConfig(level=logging.INFO) diff --git a/doc/make.bat b/doc/make.bat index dfa194c6..25ad79f7 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -115,9 +115,9 @@ if "%1" == "qthelp" ( echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Flask-RESTPlus.qhcp + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Flask-RESTX.qhcp echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Flask-RESTPlus.ghc + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Flask-RESTX.ghc goto end ) diff --git a/doc/marshalling.rst b/doc/marshalling.rst index 63b12973..abf894c6 100644 --- a/doc/marshalling.rst +++ b/doc/marshalling.rst @@ -3,10 +3,10 @@ Response marshalling ==================== -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx -Flask-RESTPlus provides an easy way to control what data you actually render in +Flask-RESTX provides an easy way to control what data you actually render in your response or expect as in input payload. With the :mod:`~.fields` module, you can use whatever objects (ORM models/custom classes/etc.) you want in your resource. @@ -27,7 +27,7 @@ formatted as an ISO 8601 datetime string (RFC 822 is supported as well): .. code-block:: python - from flask_restplus import Resource, fields + from flask_restx import Resource, fields model = api.model('Model', { 'name': fields.String, @@ -142,7 +142,7 @@ but for a human readable output it's nice to convert them to separate string fie Url & Other Concrete Fields --------------------------- -Flask-RESTPlus includes a special field, :class:`fields.Url`, +Flask-RESTX includes a special field, :class:`fields.Url`, that synthesizes a uri for the resource that's being requested. This is also a good example of how to add data to your response that's not actually present on your data object. @@ -180,7 +180,7 @@ You can have a flat structure that :func:`marshal` will transform to a nested st .. code-block:: python - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> import json >>> >>> resource_fields = {'name': fields.String} @@ -206,7 +206,7 @@ List Field You can also unmarshal fields as lists :: - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> import json >>> >>> resource_fields = {'name': fields.String, 'first_names': fields.List(fields.String)} @@ -222,7 +222,7 @@ Wildcard Field If you don't know the name(s) of the field(s) you want to unmarshall, you can use :class:`~fields.Wildcard` :: - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> import json >>> >>> wild = fields.Wildcard(fields.String) @@ -234,7 +234,7 @@ use :class:`~fields.Wildcard` :: The name you give to your :class:`~fields.Wildcard` acts as a real glob as shown bellow :: - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> import json >>> >>> wild = fields.Wildcard(fields.String) @@ -256,7 +256,7 @@ In order to avoid unexpected behavior, when mixing :class:`~fields.Wildcard` with other fields, you may want to use an ``OrderedDict`` and use the :class:`~fields.Wildcard` as the last field :: - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> import json >>> >>> wild = fields.Wildcard(fields.Integer) @@ -276,7 +276,7 @@ While nesting fields using dicts can turn a flat data object into a nested response, you can use :class:`~fields.Nested` to unmarshal nested data structures and render them appropriately. :: - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> import json >>> >>> address_fields = {} @@ -472,7 +472,7 @@ Let consider the following example with an optional ``skip_none`` keyword argume .. code-block:: python - >>> from flask_restplus import Model, fields, marshal_with + >>> from flask_restx import Model, fields, marshal_with >>> import json >>> model = Model('Model', { ... 'name': fields.String, @@ -497,7 +497,7 @@ If your module use :class:`fields.Nested`, you need to pass ``skip_none=True`` k .. code-block:: python - >>> from flask_restplus import Model, fields, marshal_with + >>> from flask_restx import Model, fields, marshal_with >>> import json >>> model = Model('Model', { ... 'name': fields.String, diff --git a/doc/mask.rst b/doc/mask.rst index 50fbb6f6..6169dbc6 100644 --- a/doc/mask.rst +++ b/doc/mask.rst @@ -1,7 +1,7 @@ Fields masks ============ -Flask-Restplus support partial object fetching (aka. fields mask) +Flask-RESTX support partial object fetching (aka. fields mask) by supplying a custom header in the request. By default the header is ``X-Fields`` diff --git a/doc/parsing.rst b/doc/parsing.rst index 926a9f87..cbcfdcf8 100644 --- a/doc/parsing.rst +++ b/doc/parsing.rst @@ -5,7 +5,7 @@ Request Parsing .. warning :: - The whole request parser part of Flask-RESTPlus is slated for removal and + The whole request parser part of Flask-RESTX is slated for removal and will be replaced by documentation on how to integrate with other packages that do the input/output stuff better (such as `marshmallow `_). @@ -13,9 +13,9 @@ Request Parsing Don't worry, if you have code using that now and wish to continue doing so, it's not going to go away any time too soon. -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx -Flask-RESTPlus's request parsing interface, :mod:`reqparse`, +Flask-RESTX's request parsing interface, :mod:`reqparse`, is modeled after the :mod:`python:argparse` interface. It's designed to provide simple and uniform access to any variable on the :class:`flask.request` object in Flask. @@ -28,7 +28,7 @@ It looks for two arguments in the :attr:`flask.Request.values` dict: an integer .. code-block:: python - from flask_restplus import reqparse + from flask_restx import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate cannot be converted') @@ -169,7 +169,7 @@ Advanced types handling ----------------------- Sometimes, you need more than a primitive type to handle input validation. -The :mod:`~flask_restplus.inputs` module provides some common type handling like: +The :mod:`~flask_restx.inputs` module provides some common type handling like: - :func:`~inputs.boolean` for wider boolean handling - :func:`~inputs.ipv4` and :func:`~inputs.ipv6` for IP adresses @@ -181,7 +181,7 @@ You just have to use them as `type` argument: parser.add_argument('flag', type=inputs.boolean) -See the :mod:`~flask_restplus.inputs` documentation for full list of available inputs. +See the :mod:`~flask_restx.inputs` documentation for full list of available inputs. You can also write your own: @@ -208,7 +208,7 @@ also overwrite any argument in the parent with :meth:`~reqparse.RequestParser.replace_argument`, or remove it completely with :meth:`~reqparse.RequestParser.remove_argument`. For example: :: - from flask_restplus import reqparse + from flask_restx import reqparse parser = reqparse.RequestParser() parser.add_argument('foo', type=int) @@ -263,7 +263,7 @@ specified either at the Flask application level or on the specific RequestParser instance. To invoke a RequestParser with the bundling errors option, pass in the argument ``bundle_errors``. For example :: - from flask_restplus import reqparse + from flask_restx import reqparse parser = reqparse.RequestParser(bundle_errors=True) parser.add_argument('foo', type=int, required=True) @@ -320,7 +320,7 @@ then the error message will be the value of ``help``. replaced with the string representation of the type error. This allows the message to be customized while preserving the original error:: - from flask_restplus import reqparse + from flask_restx import reqparse parser = reqparse.RequestParser() diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 50401827..af3871f8 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -3,10 +3,10 @@ Quick start =========== -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx This guide assumes you have a working understanding of `Flask `_, -and that you have already installed both Flask and Flask-RESTPlus. +and that you have already installed both Flask and Flask-RESTX. If not, then follow the steps in the :ref:`installation` section. @@ -18,7 +18,7 @@ As every other extension, you can initialize it with an application object: .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) api = Api(app) @@ -28,7 +28,7 @@ or lazily with the factory pattern: .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api api = Api() @@ -39,12 +39,12 @@ or lazily with the factory pattern: A Minimal API ------------- -A minimal Flask-RESTPlus API looks like this: +A minimal Flask-RESTX API looks like this: .. code-block:: python from flask import Flask - from flask_restplus import Resource, Api + from flask_restx import Resource, Api app = Flask(__name__) api = Api(app) @@ -88,7 +88,7 @@ See :ref:`swaggerui` for a complete documentation on the automatic documentation Resourceful Routing ------------------- -The main building block provided by Flask-RESTPlus are resources. +The main building block provided by Flask-RESTX are resources. Resources are built on top of :ref:`Flask pluggable views `, giving you easy access to multiple HTTP methods just by defining methods on your resource. A basic CRUD resource for a todo application (of course) looks like this: @@ -96,7 +96,7 @@ A basic CRUD resource for a todo application (of course) looks like this: .. code-block:: python from flask import Flask, request - from flask_restplus import Resource, Api + from flask_restx import Resource, Api app = Flask(__name__) api = Api(app) @@ -143,10 +143,10 @@ Or from python if you have the `Requests `_ li >>> get('http://localhost:5000/todo2').json() {u'todo2': u'Change my brakepads'} -Flask-RESTPlus understands multiple kinds of return values from view methods. +Flask-RESTX understands multiple kinds of return values from view methods. Similar to Flask, you can return any iterable and it will be converted into a response, including raw Flask response objects. -Flask-RESTPlus also support setting the response code and response headers using multiple return values, +Flask-RESTX also support setting the response code and response headers using multiple return values, as shown below: .. code-block:: python @@ -200,7 +200,7 @@ You can also match parts of the path as variables to your resource methods. .. note :: If a request does not match any of your application's endpoints, - Flask-RESTPlus will return a 404 error message with suggestions of other + Flask-RESTX will return a 404 error message with suggestions of other endpoints that closely match the requested endpoint. This can be disabled by setting ``ERROR_404_HELP`` to ``False`` in your application config. @@ -210,12 +210,12 @@ Argument Parsing While Flask provides easy access to request data (i.e. querystring or POST form encoded data), it's still a pain to validate form data. -Flask-RESTPlus has built-in support for request data validation +Flask-RESTX has built-in support for request data validation using a library similar to :mod:`python:argparse`. .. code-block:: python - from flask_restplus import reqparse + from flask_restx import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') @@ -228,7 +228,7 @@ using a library similar to :mod:`python:argparse`. Using the :class:`~reqparse.RequestParser` class also gives you sane error messages for free. If an argument fails to pass validation, -Flask-RESTPlus will respond with a 400 Bad Request and a response highlighting the error. +Flask-RESTX will respond with a 400 Bad Request and a response highlighting the error. .. code-block:: console @@ -253,7 +253,7 @@ Data Formatting By default, all fields in your return iterable will be rendered as-is. While this works great when you're just dealing with Python data structures, it can become very frustrating when working with objects. -To solve this problem, Flask-RESTPlus provides the :mod:`fields` module and the +To solve this problem, Flask-RESTX provides the :mod:`fields` module and the :meth:`marshal_with` decorator. Similar to the Django ORM and WTForm, you use the ``fields`` module to describe the structure of your response. @@ -261,7 +261,7 @@ you use the ``fields`` module to describe the structure of your response. .. code-block:: python from flask import Flask - from flask_restplus import fields, Api, Resource + from flask_restx import fields, Api, Resource app = Flask(__name__) api = Api(app) diff --git a/doc/scaling.rst b/doc/scaling.rst index beb02e65..0830d074 100644 --- a/doc/scaling.rst +++ b/doc/scaling.rst @@ -3,22 +3,22 @@ Scaling your project ==================== -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx -This page covers building a slightly more complex Flask-RESTPlus app that will -cover out some best practices when setting up a real-world Flask-RESTPlus-based API. -The :ref:`quickstart` section is great for getting started with your first Flask-RESTplus app, -so if you're new to Flask-RESTPlus you'd be better off checking that out first. +This page covers building a slightly more complex Flask-RESTX app that will +cover out some best practices when setting up a real-world Flask-RESTX-based API. +The :ref:`quickstart` section is great for getting started with your first Flask-RESTX app, +so if you're new to Flask-RESTX you'd be better off checking that out first. Multiple namespaces ------------------- -There are many different ways to organize your Flask-RESTPlus app, +There are many different ways to organize your Flask-RESTX app, but here we'll describe one that scales pretty well with larger apps and maintains a nice level organization. -Flask-RESTPlus provides a way to use almost the same pattern as Flask's `blueprint`. +Flask-RESTX provides a way to use almost the same pattern as Flask's `blueprint`. The main idea is to split your app into reusable namespaces. Here's an example directory structure:: @@ -51,7 +51,7 @@ For example: .. code-block:: Python - from flask_restplus import Namespace, Resource, fields + from flask_restx import Namespace, Resource, fields api = Namespace('cats', description='Cats related operations') @@ -90,7 +90,7 @@ The `apis.__init__` module should aggregate them: .. code-block:: Python - from flask_restplus import Api + from flask_restx import Api from .namespace1 import api as ns1 from .namespace2 import api as ns2 @@ -115,7 +115,7 @@ You don't have to bind url-prefix while declaration of Namespace object. .. code-block:: Python - from flask_restplus import Api + from flask_restx import Api from .namespace1 import api as ns1 from .namespace2 import api as ns2 @@ -157,7 +157,7 @@ Here's an example of how to link an :class:`Api` up to a :class:`~flask.Blueprin .. code-block:: python from flask import Blueprint - from flask_restplus import Api + from flask_restx import Api blueprint = Blueprint('api', __name__) api = Api(blueprint) @@ -219,7 +219,7 @@ Each `apivX` module will have the following pattern: .. code-block:: python from flask import Blueprint - from flask_restplus import Api + from flask_restx import Api api = Api(blueprint) @@ -258,4 +258,4 @@ And the app will simply mount them: These are only proposals and you can do whatever suits your needs. Look at the `github repository examples folder`_ for more complete examples. -.. _github repository examples folder: https://github.com/noirbizarre/flask-restplus/tree/master/examples +.. _github repository examples folder: https://github.com/python-restx/flask-restx/tree/master/examples diff --git a/doc/swagger.rst b/doc/swagger.rst index 8f677eaf..c332ccc9 100644 --- a/doc/swagger.rst +++ b/doc/swagger.rst @@ -4,7 +4,7 @@ Swagger documentation ===================== -.. currentmodule:: flask_restplus +.. currentmodule:: flask_restx Swagger API documentation is automatically generated and available from your API's root URL. You can configure the documentation using the :meth:`@api.doc() ` decorator. @@ -174,7 +174,7 @@ You can specify lists as the expected input: pass -You can use :exc:`~flask_restplus.reqparse.RequestParser` to define the expected input: +You can use :exc:`~flask_restx.reqparse.RequestParser` to define the expected input: .. code-block:: python @@ -184,7 +184,7 @@ You can use :exc:`~flask_restplus.reqparse.RequestParser` to define the expected @api.route('/with-parser/', endpoint='with-parser') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.expect(parser) def get(self): return {} @@ -416,7 +416,7 @@ Routes with a ``doc`` parameter are given a `unique` Swagger ``operationId``. Ro Documenting the fields ---------------------- -Every Flask-Restplus field accepts optional arguments used to document the field: +Every Flask-RESTX field accepts optional arguments used to document the field: - ``required``: a boolean indicating if the field is always set (*default*: ``False``) - ``description``: some details about the field (*default*: ``None``) @@ -561,9 +561,9 @@ For ``POST`` and ``PUT`` methods, use the ``body`` keyword argument to specify t return {} -If both ``body`` and ``formData`` parameters are used, a :exc:`~flask_restplus.errors.SpecsError` will be raised. +If both ``body`` and ``formData`` parameters are used, a :exc:`~flask_restx.errors.SpecsError` will be raised. -Models can also be specified with a :class:`~flask_restplus.reqparse.RequestParser`. +Models can also be specified with a :class:`~flask_restx.reqparse.RequestParser`. .. code-block:: python @@ -572,7 +572,7 @@ Models can also be specified with a :class:`~flask_restplus.reqparse.RequestPars parser.add_argument('in_files', type=FileStorage, location='files') @api.route('/with-parser/', endpoint='with-parser') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.expect(parser) def get(self): return {} @@ -590,7 +590,7 @@ Models can also be specified with a :class:`~flask_restplus.reqparse.RequestPars .. note:: - Using :class:`~flask_restplus.reqparse.RequestParser` is preferred over the ``api.param()`` decorator + Using :class:`~flask_restx.reqparse.RequestParser` is preferred over the ``api.param()`` decorator to document form fields as it also perform validation. Headers @@ -602,7 +602,7 @@ You can document response headers with the ``@api.header()`` decorator shortcut. @api.route('/with-headers/') @api.header('X-Header', 'Some class header') - class WithHeaderResource(restplus.Resource): + class WithHeaderResource(restx.Resource): @api.header('X-Collection', type=[str], collectionType='csv') def get(self): pass @@ -613,7 +613,7 @@ just use the `@api.response` `headers` parameter. .. code-block:: python @api.route('/response-headers/') - class WithHeaderResource(restplus.Resource): + class WithHeaderResource(restx.Resource): @api.response(200, 'Success', headers={'X-Header': 'Some header'}) def get(self): pass @@ -628,7 +628,7 @@ Documenting expected/request headers is done through the `@api.expect` decorator @api.route('/expect-headers/') @api.expect(parser) - class ExpectHeaderResource(restplus.Resource): + class ExpectHeaderResource(restx.Resource): def get(self): pass @@ -851,7 +851,7 @@ Expose vendor Extensions ------------------------ Swaggers allows you to expose custom `vendor extensions`_ and you can use them -in Flask-RESTPlus with the `@api.vendor` decorator. +in Flask-RESTX with the `@api.vendor` decorator. It supports both extensions as `dict` or `kwargs` and perform automatique `x-` prefix: @@ -887,13 +887,13 @@ You can export the Swagger specifications for your API: Swagger UI ---------- -By default ``flask-restplus`` provides Swagger UI documentation, served from the root URL of the API. +By default ``flask-restx`` provides Swagger UI documentation, served from the root URL of the API. .. code-block:: python from flask import Flask - from flask_restplus import Api, Resource, fields + from flask_restx import Api, Resource, fields app = Flask(__name__) api = Api(app, version='1.0', title='Sample API', @@ -929,7 +929,7 @@ You can control the Swagger UI path with the ``doc`` parameter (defaults to the .. code-block:: python from flask import Flask, Blueprint - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) blueprint = Blueprint('api', __name__, url_prefix='/api') @@ -945,7 +945,7 @@ You can specify a custom validator URL by setting ``config.SWAGGER_VALIDATOR_URL .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) app.config.SWAGGER_VALIDATOR_URL = 'http://domain.com/validator' @@ -964,7 +964,7 @@ These values are all public knowledge. No *client secret* is specified here. .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) @@ -996,7 +996,7 @@ setting (``'none'``, ``'list'`` or ``'full'``): .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) app.config.SWAGGER_UI_DOC_EXPANSION = 'list' @@ -1008,7 +1008,7 @@ By default, operation ID is hidden as well as request duration, you can enable t .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) app.config.SWAGGER_UI_OPERATION_ID = True @@ -1023,7 +1023,7 @@ you can register a custom view function with the :meth:`~Api.documentation` deco .. code-block:: python from flask import Flask - from flask_restplus import Api, apidoc + from flask_restx import Api, apidoc app = Flask(__name__) api = Api(app) @@ -1042,7 +1042,7 @@ supporting the same values as the ``supportedSubmitMethods`` `Swagger UI paramet .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) @@ -1062,7 +1062,7 @@ To disable Swagger UI entirely, set ``doc=False``: .. code-block:: python from flask import Flask - from flask_restplus import Api + from flask_restx import Api app = Flask(__name__) api = Api(app, doc=False) diff --git a/examples/todo.py b/examples/todo.py index e70c94f7..f85f0ddf 100644 --- a/examples/todo.py +++ b/examples/todo.py @@ -1,5 +1,5 @@ from flask import Flask -from flask_restplus import Api, Resource, fields +from flask_restx import Api, Resource, fields from werkzeug.contrib.fixers import ProxyFix app = Flask(__name__) diff --git a/examples/todo_blueprint.py b/examples/todo_blueprint.py index d01a650a..1096346f 100644 --- a/examples/todo_blueprint.py +++ b/examples/todo_blueprint.py @@ -1,5 +1,5 @@ from flask import Flask, Blueprint -from flask_restplus import Api, Resource, fields +from flask_restx import Api, Resource, fields api_v1 = Blueprint('api', __name__, url_prefix='/api/1') diff --git a/examples/todo_simple.py b/examples/todo_simple.py index 2b4e975d..9bb217ee 100644 --- a/examples/todo_simple.py +++ b/examples/todo_simple.py @@ -1,5 +1,5 @@ from flask import Flask, request -from flask_restplus import Resource, Api +from flask_restx import Resource, Api app = Flask(__name__) api = Api(app) diff --git a/examples/todomvc.py b/examples/todomvc.py index 595929d5..077a6f55 100644 --- a/examples/todomvc.py +++ b/examples/todomvc.py @@ -1,5 +1,5 @@ from flask import Flask -from flask_restplus import Api, Resource, fields +from flask_restx import Api, Resource, fields from werkzeug.contrib.fixers import ProxyFix app = Flask(__name__) diff --git a/examples/xml_representation.py b/examples/xml_representation.py index e3e751d8..25b27ac9 100644 --- a/examples/xml_representation.py +++ b/examples/xml_representation.py @@ -1,7 +1,7 @@ # needs: pip install python-simplexml from simplexml import dumps from flask import make_response, Flask -from flask_restplus import Api, Resource, fields +from flask_restx import Api, Resource, fields def output_xml(data, code, headers=None): diff --git a/examples/zoo/__init__.py b/examples/zoo/__init__.py index 24196f27..d066087a 100644 --- a/examples/zoo/__init__.py +++ b/examples/zoo/__init__.py @@ -1,4 +1,4 @@ -from flask_restplus import Api +from flask_restx import Api from .cat import api as cat_api from .dog import api as dog_api diff --git a/examples/zoo/cat.py b/examples/zoo/cat.py index 58c14f06..a6e39c5a 100644 --- a/examples/zoo/cat.py +++ b/examples/zoo/cat.py @@ -1,4 +1,4 @@ -from flask_restplus import Namespace, Resource, fields +from flask_restx import Namespace, Resource, fields api = Namespace('cats', description='Cats related operations') diff --git a/examples/zoo/dog.py b/examples/zoo/dog.py index ecaee1b3..d4c6bb4c 100644 --- a/examples/zoo/dog.py +++ b/examples/zoo/dog.py @@ -1,4 +1,4 @@ -from flask_restplus import Namespace, Resource, fields +from flask_restx import Namespace, Resource, fields api = Namespace('dogs', description='Dogs related operations') diff --git a/flask_restplus/__about__.py b/flask_restx/__about__.py similarity index 100% rename from flask_restplus/__about__.py rename to flask_restx/__about__.py diff --git a/flask_restplus/__init__.py b/flask_restx/__init__.py similarity index 100% rename from flask_restplus/__init__.py rename to flask_restx/__init__.py diff --git a/flask_restplus/_http.py b/flask_restx/_http.py similarity index 100% rename from flask_restplus/_http.py rename to flask_restx/_http.py diff --git a/flask_restplus/api.py b/flask_restx/api.py similarity index 98% rename from flask_restplus/api.py rename to flask_restx/api.py index b5433ce3..a04eccbd 100644 --- a/flask_restplus/api.py +++ b/flask_restx/api.py @@ -42,7 +42,7 @@ RE_RULES = re.compile('(<.*>)') -# List headers that should never be handled by Flask-RESTPlus +# List headers that should never be handled by Flask-RESTX HEADERS_BLACKLIST = ('Content-Length',) DEFAULT_REPRESENTATIONS = [('application/json', output_json)] @@ -238,7 +238,7 @@ def _complete_url(self, url_part, registration_prefix): return ''.join(part for part in parts if part) def _register_apidoc(self, app): - conf = app.extensions.setdefault('restplus', {}) + conf = app.extensions.setdefault('restx', {}) if not conf.get('apidoc_registered', False): app.register_blueprint(apidoc.apidoc) conf['apidoc_registered'] = True @@ -581,11 +581,11 @@ def _has_fr_route(self): def error_router(self, original_handler, e): ''' - This function decides whether the error occurred in a flask-restplus - endpoint or not. If it happened in a flask-restplus endpoint, our + This function decides whether the error occurred in a flask-restx + endpoint or not. If it happened in a flask-restx endpoint, our handler will be dispatched. If it happened in an unrelated view, the app's original error handler will be dispatched. - In the event that the error occurred in a flask-restplus endpoint but + In the event that the error occurred in a flask-restx endpoint but the local handler can't resolve the situation, the router will fall back onto the original_handler as last resort. @@ -753,7 +753,7 @@ def _deferred_blueprint_init(self, setup_state): ''' Synchronize prefix between blueprint/api and registration options, then perform initialization with setup_state.app :class:`flask.Flask` object. - When a :class:`flask_restplus.Api` object is initialized with a blueprint, + When a :class:`flask_restx.Api` object is initialized with a blueprint, this method is recorded on the blueprint to be run when the blueprint is later registered to a :class:`flask.Flask` object. This method also monkeypatches BlueprintSetupState.add_url_rule with _blueprint_setup_add_url_rule_patch. @@ -770,7 +770,7 @@ def _deferred_blueprint_init(self, setup_state): setup_state.add_url_rule = MethodType(Api._blueprint_setup_add_url_rule_patch, setup_state) if not setup_state.first_registration: - raise ValueError('flask-restplus blueprints can only be registered once.') + raise ValueError('flask-restx blueprints can only be registered once.') self._init_app(setup_state.app) def mediatypes_method(self): @@ -813,7 +813,7 @@ def unauthorized(self, response): '''Given a response, change it to ask for credentials''' if self.serve_challenge_on_401: - realm = current_app.config.get("HTTP_BASIC_AUTH_REALM", "flask-restplus") + realm = current_app.config.get("HTTP_BASIC_AUTH_REALM", "flask-restx") challenge = u"{0} realm=\"{1}\"".format("Basic", realm) response.headers['WWW-Authenticate'] = challenge diff --git a/flask_restplus/apidoc.py b/flask_restx/apidoc.py similarity index 89% rename from flask_restplus/apidoc.py rename to flask_restx/apidoc.py index a6f7a342..8b31585d 100644 --- a/flask_restplus/apidoc.py +++ b/flask_restx/apidoc.py @@ -18,7 +18,7 @@ def register(self, *args, **kwargs): self.registered = True -apidoc = Apidoc('restplus_doc', __name__, +apidoc = Apidoc('restx_doc', __name__, template_folder='templates', static_folder='static', static_url_path='/swaggerui', @@ -27,7 +27,7 @@ def register(self, *args, **kwargs): @apidoc.add_app_template_global def swagger_static(filename): - return url_for('restplus_doc.static', filename=filename) + return url_for('restx_doc.static', filename=filename) def ui_for(api): diff --git a/flask_restplus/cors.py b/flask_restx/cors.py similarity index 100% rename from flask_restplus/cors.py rename to flask_restx/cors.py diff --git a/flask_restplus/errors.py b/flask_restx/errors.py similarity index 95% rename from flask_restplus/errors.py rename to flask_restx/errors.py index 24de3d51..c544b7e1 100644 --- a/flask_restplus/errors.py +++ b/flask_restx/errors.py @@ -38,7 +38,7 @@ def abort(code=HTTPStatus.INTERNAL_SERVER_ERROR, message=None, **kwargs): class RestError(Exception): - '''Base class for all Flask-Restplus Errors''' + '''Base class for all Flask-RESTX Errors''' def __init__(self, msg): self.msg = msg diff --git a/flask_restplus/fields.py b/flask_restx/fields.py similarity index 100% rename from flask_restplus/fields.py rename to flask_restx/fields.py diff --git a/flask_restplus/inputs.py b/flask_restx/inputs.py similarity index 100% rename from flask_restplus/inputs.py rename to flask_restx/inputs.py diff --git a/flask_restplus/marshalling.py b/flask_restx/marshalling.py similarity index 96% rename from flask_restplus/marshalling.py rename to flask_restx/marshalling.py index 84c8feb2..0222a720 100644 --- a/flask_restplus/marshalling.py +++ b/flask_restx/marshalling.py @@ -36,7 +36,7 @@ def marshal(data, fields, envelope=None, skip_none=False, mask=None, ordered=Fal :param bool ordered: Wether or not to preserve order - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> data = { 'a': 100, 'b': 'foo', 'c': None } >>> mfields = { 'a': fields.Raw, 'c': fields.Raw, 'd': fields.Raw } @@ -131,7 +131,7 @@ def _marshal(data, fields, envelope=None, skip_none=False, mask=None, ordered=Fa :param bool ordered: Wether or not to preserve order - >>> from flask_restplus import fields, marshal + >>> from flask_restx import fields, marshal >>> data = { 'a': 100, 'b': 'foo', 'c': None } >>> mfields = { 'a': fields.Raw, 'c': fields.Raw, 'd': fields.Raw } @@ -199,7 +199,7 @@ def __format_field(key, val): class marshal_with(object): """A decorator that apply marshalling to the return values of your methods. - >>> from flask_restplus import fields, marshal_with + >>> from flask_restx import fields, marshal_with >>> mfields = { 'a': fields.Raw } >>> @marshal_with(mfields) ... def get(): @@ -226,7 +226,7 @@ class marshal_with(object): >>> get() OrderedDict([('a', 100)]) - see :meth:`flask_restplus.marshal` + see :meth:`flask_restx.marshal` """ def __init__(self, fields, envelope=None, skip_none=False, mask=None, ordered=False): """ @@ -265,7 +265,7 @@ class marshal_with_field(object): """ A decorator that formats the return values of your methods with a single field. - >>> from flask_restplus import marshal_with_field, fields + >>> from flask_restx import marshal_with_field, fields >>> @marshal_with_field(fields.List(fields.Integer)) ... def get(): ... return ['1', 2, 3.0] @@ -273,7 +273,7 @@ class marshal_with_field(object): >>> get() [1, 2, 3] - see :meth:`flask_restplus.marshal_with` + see :meth:`flask_restx.marshal_with` """ def __init__(self, field): """ diff --git a/flask_restplus/mask.py b/flask_restx/mask.py similarity index 100% rename from flask_restplus/mask.py rename to flask_restx/mask.py diff --git a/flask_restplus/model.py b/flask_restx/model.py similarity index 100% rename from flask_restplus/model.py rename to flask_restx/model.py diff --git a/flask_restplus/namespace.py b/flask_restx/namespace.py similarity index 99% rename from flask_restplus/namespace.py rename to flask_restx/namespace.py index 9c1b7b57..57b1528e 100644 --- a/flask_restplus/namespace.py +++ b/flask_restx/namespace.py @@ -138,7 +138,7 @@ def abort(self, *args, **kwargs): ''' Properly abort the current request - See: :func:`~flask_restplus.errors.abort` + See: :func:`~flask_restx.errors.abort` ''' abort(*args, **kwargs) diff --git a/flask_restplus/postman.py b/flask_restx/postman.py similarity index 100% rename from flask_restplus/postman.py rename to flask_restx/postman.py diff --git a/flask_restplus/representations.py b/flask_restx/representations.py similarity index 100% rename from flask_restplus/representations.py rename to flask_restx/representations.py diff --git a/flask_restplus/reqparse.py b/flask_restx/reqparse.py similarity index 99% rename from flask_restplus/reqparse.py rename to flask_restx/reqparse.py index d24b4d38..c840aab3 100644 --- a/flask_restplus/reqparse.py +++ b/flask_restx/reqparse.py @@ -44,7 +44,7 @@ def __setattr__(self, name, value): 'files': 'an uploaded file', } -#: Maps Flask-RESTPlus RequestParser locations to Swagger ones +#: Maps Flask-RESTX RequestParser locations to Swagger ones LOCATIONS = { 'args': 'query', 'form': 'formData', @@ -296,7 +296,7 @@ class RequestParser(object): Enables adding and parsing of multiple arguments in the context of a single request. Ex:: - from flask_restplus import RequestParser + from flask_restx import RequestParser parser = RequestParser() parser.add_argument('foo') diff --git a/flask_restplus/resource.py b/flask_restx/resource.py similarity index 98% rename from flask_restplus/resource.py rename to flask_restx/resource.py index 9bdd2b11..21c4bf64 100644 --- a/flask_restplus/resource.py +++ b/flask_restx/resource.py @@ -20,7 +20,7 @@ class Resource(MethodView): the API will return a response with status 405 Method Not Allowed. Otherwise the appropriate method is called and passed all arguments from the url rule used when adding the resource to an Api instance. - See :meth:`~flask_restplus.Api.add_resource` for details. + See :meth:`~flask_restx.Api.add_resource` for details. ''' representations = None diff --git a/flask_restplus/schemas/__init__.py b/flask_restx/schemas/__init__.py similarity index 96% rename from flask_restplus/schemas/__init__.py rename to flask_restx/schemas/__init__.py index 90e5fc97..93e92506 100644 --- a/flask_restplus/schemas/__init__.py +++ b/flask_restx/schemas/__init__.py @@ -18,7 +18,7 @@ from collections import Mapping from jsonschema import Draft4Validator -from flask_restplus import errors +from flask_restx import errors class SchemaValidationError(errors.ValidationError): @@ -101,7 +101,7 @@ def validate(data): :param data dict: The specification to validate :returns boolean: True if the specification is valid :raises SchemaValidationError: when the specification is invalid - :raises flask_restplus.errors.SpecsError: when it's not possible to determinate + :raises flask_restx.errors.SpecsError: when it's not possible to determinate the schema to validate against .. versionadded:: 0.12.1 diff --git a/flask_restplus/schemas/oas-2.0.json b/flask_restx/schemas/oas-2.0.json similarity index 100% rename from flask_restplus/schemas/oas-2.0.json rename to flask_restx/schemas/oas-2.0.json diff --git a/flask_restplus/swagger.py b/flask_restx/swagger.py similarity index 100% rename from flask_restplus/swagger.py rename to flask_restx/swagger.py diff --git a/flask_restplus/templates/swagger-ui-css.html b/flask_restx/templates/swagger-ui-css.html similarity index 100% rename from flask_restplus/templates/swagger-ui-css.html rename to flask_restx/templates/swagger-ui-css.html diff --git a/flask_restplus/templates/swagger-ui-libs.html b/flask_restx/templates/swagger-ui-libs.html similarity index 100% rename from flask_restplus/templates/swagger-ui-libs.html rename to flask_restx/templates/swagger-ui-libs.html diff --git a/flask_restplus/templates/swagger-ui.html b/flask_restx/templates/swagger-ui.html similarity index 97% rename from flask_restplus/templates/swagger-ui.html rename to flask_restx/templates/swagger-ui.html index f1255fe8..b233e018 100644 --- a/flask_restplus/templates/swagger-ui.html +++ b/flask_restx/templates/swagger-ui.html @@ -52,7 +52,7 @@ const ui = window.ui = new SwaggerUIBundle({ url: "{{ specs_url }}", {% if config.SWAGGER_UI_OAUTH_CLIENT_ID -%} - oauth2RedirectUrl: "{{ url_for('restplus_doc.static', filename='oauth2-redirect.html', _external=True) }}", + oauth2RedirectUrl: "{{ url_for('restx_doc.static', filename='oauth2-redirect.html', _external=True) }}", {%- endif %} validatorUrl: "{{ config.SWAGGER_VALIDATOR_URL }}" || null, dom_id: "#swagger-ui", diff --git a/flask_restplus/utils.py b/flask_restx/utils.py similarity index 100% rename from flask_restplus/utils.py rename to flask_restx/utils.py diff --git a/package.json b/package.json index cef85a35..1049a13a 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "flask-restplus", + "name": "flask-restx", "version": "0.10.1", "description": "Fully featured framework for fast, easy and documented API development with Flask", - "repository": "noirbizarre/flask-restplus", + "repository": "python-restx/flask-restx", "keywords": [ "swagger", "flask" diff --git a/requirements/develop.pip b/requirements/develop.pip index ba2eada9..d9a65bab 100644 --- a/requirements/develop.pip +++ b/requirements/develop.pip @@ -2,3 +2,4 @@ invoke==1.3.0 flake8==3.7.8 readme-renderer==24.0 tox==3.13.2 +twine==1.15.0 diff --git a/setup.py b/setup.py index 010a3d65..92d41864 100644 --- a/setup.py +++ b/setup.py @@ -16,13 +16,13 @@ (r':(?:class|func|meth|mod|attr|obj|exc|data|const):`~(?:\w+\.)*(\w+)`', r'``\1``'), (r':(?:class|func|meth|mod|attr|obj|exc|data|const):`([^`]+)`', r'``\1``'), # replace doc references - (r':doc:`(.+) <(.*)>`', r'`\1 `_'), + (r':doc:`(.+) <(.*)>`', r'`\1 `_'), # replace issues references - (r':issue:`(.+?)`', r'`#\1 `_'), + (r':issue:`(.+?)`', r'`#\1 `_'), # replace pr references - (r':pr:`(.+?)`', r'`#\1 `_'), + (r':pr:`(.+?)`', r'`#\1 `_'), # replace commit references - (r':commit:`(.+?)`', r'`#\1 `_'), + (r':commit:`(.+?)`', r'`#\1 `_'), # Drop unrecognized currentmodule (r'\.\. currentmodule:: .*', ''), ) @@ -55,12 +55,11 @@ def pip(filename): long_description = '\n'.join(( rst('README.rst'), - rst('CHANGELOG.rst'), '' )) -exec(compile(open('flask_restplus/__about__.py').read(), 'flask_restplus/__about__.py', 'exec')) +exec(compile(open('flask_restx/__about__.py').read(), 'flask_restx/__about__.py', 'exec')) install_requires = pip('install') doc_require = pip('doc') @@ -68,13 +67,12 @@ def pip(filename): dev_require = tests_require + pip('develop') setup( - name='flask-restplus', + name='flask-restx', version=__version__, description=__description__, long_description=long_description, - url='https://github.com/noirbizarre/flask-restplus', - author='Axel Haustant', - author_email='axel@data.gouv.fr', + url='https://github.com/python-restx/flask-restx', + author='python-restx Authors', packages=find_packages(exclude=['tests', 'tests.*']), include_package_data=True, install_requires=install_requires, @@ -87,7 +85,7 @@ def pip(filename): }, license='BSD-3-Clause', zip_safe=False, - keywords='flask restplus rest api swagger openapi', + keywords='flask restx rest api swagger openapi', classifiers=[ 'Development Status :: 3 - Alpha', 'Programming Language :: Python', diff --git a/tasks.py b/tasks.py index 7c96955c..2bd8a794 100644 --- a/tasks.py +++ b/tasks.py @@ -135,7 +135,7 @@ def cover(ctx, html=False): header(cover.__doc__) extra = '--cov-report html' if html else '' with ctx.cd(ROOT): - ctx.run('pytest --benchmark-skip --cov flask_restplus --cov-report term {0}'.format(extra), pty=True) + ctx.run('pytest --benchmark-skip --cov flask_restx --cov-report term {0}'.format(extra), pty=True) @task @@ -151,13 +151,18 @@ def qa(ctx): header(qa.__doc__) with ctx.cd(ROOT): info('Python Static Analysis') - flake8_results = ctx.run('flake8 flask_restplus tests', pty=True, warn=True) + flake8_results = ctx.run('flake8 flask_restx tests', pty=True, warn=True) if flake8_results.failed: error('There is some lints to fix') else: success('No linter errors') info('Ensure PyPI can render README and CHANGELOG') - readme_results = ctx.run('python setup.py check -r -s', pty=True, warn=True, hide=True) + info('Building dist package') + dist = ctx.run('python setup.py sdist', pty=True, warn=False, hide=True) + if dist.failed: + error('Unable to build sdist package') + exit('Quality check failed', dist.return_code) + readme_results = ctx.run('twine check dist/*', pty=True, warn=True, hide=True) if readme_results.failed: print(readme_results.stdout) error('README and/or CHANGELOG is not renderable by PyPI') @@ -182,11 +187,11 @@ def assets(ctx): header(assets.__doc__) with ctx.cd(ROOT): ctx.run('npm install') - ctx.run('mkdir -p flask_restplus/static') - ctx.run('cp node_modules/swagger-ui-dist/{swagger-ui*.{css,js}{,.map},favicon*.png,oauth2-redirect.html} flask_restplus/static') + ctx.run('mkdir -p flask_restx/static') + ctx.run('cp node_modules/swagger-ui-dist/{swagger-ui*.{css,js}{,.map},favicon*.png,oauth2-redirect.html} flask_restx/static') # Until next release we need to install droid sans separately - ctx.run('cp node_modules/typeface-droid-sans/index.css flask_restplus/static/droid-sans.css') - ctx.run('cp -R node_modules/typeface-droid-sans/files flask_restplus/static/') + ctx.run('cp node_modules/typeface-droid-sans/index.css flask_restx/static/droid-sans.css') + ctx.run('cp -R node_modules/typeface-droid-sans/files flask_restx/static/') @task diff --git a/tests/benchmarks/bench_marshalling.py b/tests/benchmarks/bench_marshalling.py index 3b8b3c54..9b505e04 100644 --- a/tests/benchmarks/bench_marshalling.py +++ b/tests/benchmarks/bench_marshalling.py @@ -2,7 +2,7 @@ from faker import Faker -from flask_restplus import marshal, fields +from flask_restx import marshal, fields fake = Faker() diff --git a/tests/benchmarks/bench_swagger.py b/tests/benchmarks/bench_swagger.py index 295ee7a8..9d3509e6 100644 --- a/tests/benchmarks/bench_swagger.py +++ b/tests/benchmarks/bench_swagger.py @@ -1,7 +1,7 @@ import pytest -from flask_restplus import fields, Api, Resource -from flask_restplus.swagger import Swagger +from flask_restx import fields, Api, Resource +from flask_restx.swagger import Swagger api = Api() diff --git a/tests/conftest.py b/tests/conftest.py index f8c23e71..cd204e0e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,7 @@ from flask import Flask, Blueprint from flask.testing import FlaskClient -import flask_restplus as restplus +import flask_restx as restx class TestClient(FlaskClient): @@ -60,7 +60,7 @@ def api(request, app): bpkwargs['subdomain'] = marker.kwargs.pop('subdomain') kwargs = marker.kwargs blueprint = Blueprint('api', __name__, **bpkwargs) - api = restplus.Api(blueprint, **kwargs) + api = restx.Api(blueprint, **kwargs) app.register_blueprint(blueprint) yield api @@ -70,7 +70,7 @@ def mock_app(mocker): app = mocker.Mock(Flask) # mock Flask app object doesn't have any real loggers -> mock logging # set up on Api object - mocker.patch.object(restplus.Api, '_configure_namespace_logger') + mocker.patch.object(restx.Api, '_configure_namespace_logger') app.view_functions = {} app.extensions = {} app.config = {} diff --git a/tests/legacy/test_api_legacy.py b/tests/legacy/test_api_legacy.py index 88d0b8a8..1b95b95c 100644 --- a/tests/legacy/test_api_legacy.py +++ b/tests/legacy/test_api_legacy.py @@ -10,11 +10,11 @@ from flask import Blueprint, redirect, views from werkzeug.exceptions import HTTPException, Unauthorized, BadRequest -import flask_restplus as restplus +import flask_restx as restx # Add a dummy Resource to verify that the app is properly set. -class HelloWorld(restplus.Resource): +class HelloWorld(restx.Resource): def get(self): return {} @@ -31,7 +31,7 @@ def test_unauthorized(self, api, mocker): response = mocker.Mock() response.headers = {} response = api.unauthorized(response) - assert response.headers['WWW-Authenticate'] == 'Basic realm="flask-restplus"' + assert response.headers['WWW-Authenticate'] == 'Basic realm="flask-restx"' @pytest.mark.options(HTTP_BASIC_AUTH_REALM='Foo') @pytest.mark.api(serve_challenge_on_401=True) @@ -54,7 +54,7 @@ def test_handle_error_401_sends_challege_default_realm(self, api): resp = api.handle_error(exception) assert resp.status_code == 401 - assert resp.headers['WWW-Authenticate'] == 'Basic realm="flask-restplus"' + assert resp.headers['WWW-Authenticate'] == 'Basic realm="flask-restx"' @pytest.mark.api(serve_challenge_on_401=True) @pytest.mark.options(HTTP_BASIC_AUTH_REALM='test-realm') @@ -78,19 +78,19 @@ def foo(): assert api.representations['foo'] == foo def test_api_base(self, app): - api = restplus.Api(app) + api = restx.Api(app) assert api.urls == {} assert api.prefix == '' assert api.default_mediatype == 'application/json' def test_api_delayed_initialization(self, app, client): - api = restplus.Api() + api = restx.Api() api.add_resource(HelloWorld, '/', endpoint="hello") api.init_app(app) assert client.get('/').status_code == 200 def test_api_prefix(self, app): - api = restplus.Api(app, prefix='/foo') + api = restx.Api(app, prefix='/foo') assert api.prefix == '/foo' @pytest.mark.api(serve_challenge_on_401=True) @@ -103,7 +103,7 @@ def test_handle_auth(self, api): assert 'WWW-Authenticate' in resp.headers def test_media_types(self, app): - api = restplus.Api(app) + api = restx.Api(app) with app.test_request_context("/foo", headers={ 'Accept': 'application/json' @@ -111,7 +111,7 @@ def test_media_types(self, app): assert api.mediatypes() == ['application/json'] def test_media_types_method(self, app, mocker): - api = restplus.Api(app) + api = restx.Api(app) with app.test_request_context("/foo", headers={ 'Accept': 'application/xml; q=.5' @@ -119,7 +119,7 @@ def test_media_types_method(self, app, mocker): assert api.mediatypes_method()(mocker.Mock()) == ['application/xml', 'application/json'] def test_media_types_q(self, app): - api = restplus.Api(app) + api = restx.Api(app) with app.test_request_context("/foo", headers={ 'Accept': 'application/json; q=1, application/xml; q=.5' @@ -131,7 +131,7 @@ def return_zero(func): return 0 view = mocker.Mock() - api = restplus.Api(mock_app) + api = restx.Api(mock_app) api.decorators.append(return_zero) api.output = mocker.Mock() api.add_resource(view, '/foo', endpoint='bar') @@ -141,19 +141,19 @@ def return_zero(func): def test_add_resource_endpoint(self, app, mocker): view = mocker.Mock(**{'as_view.return_value.__name__': str('test_view')}) - api = restplus.Api(app) + api = restx.Api(app) api.add_resource(view, '/foo', endpoint='bar') view.as_view.assert_called_with('bar', api) def test_add_two_conflicting_resources_on_same_endpoint(self, app): - api = restplus.Api(app) + api = restx.Api(app) - class Foo1(restplus.Resource): + class Foo1(restx.Resource): def get(self): return 'foo1' - class Foo2(restplus.Resource): + class Foo2(restx.Resource): def get(self): return 'foo2' @@ -162,9 +162,9 @@ def get(self): api.add_resource(Foo2, '/foo/toto', endpoint='bar') def test_add_the_same_resource_on_same_endpoint(self, app): - api = restplus.Api(app) + api = restx.Api(app) - class Foo1(restplus.Resource): + class Foo1(restx.Resource): def get(self): return 'foo1' @@ -178,7 +178,7 @@ def get(self): assert foo2.data == b'"foo1"\n' def test_add_resource(self, mocker, mock_app): - api = restplus.Api(mock_app) + api = restx.Api(mock_app) api.output = mocker.Mock() api.add_resource(views.MethodView, '/foo') @@ -186,7 +186,7 @@ def test_add_resource(self, mocker, mock_app): view_func=api.output()) def test_add_resource_kwargs(self, mocker, mock_app): - api = restplus.Api(mock_app) + api = restx.Api(mock_app) api.output = mocker.Mock() api.add_resource(views.MethodView, '/foo', defaults={"bar": "baz"}) @@ -195,9 +195,9 @@ def test_add_resource_kwargs(self, mocker, mock_app): defaults={"bar": "baz"}) def test_add_resource_forward_resource_class_parameters(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) - class Foo(restplus.Resource): + class Foo(restx.Resource): def __init__(self, api, *args, **kwargs): self.one = args[0] self.two = kwargs['secret_state'] @@ -218,7 +218,7 @@ def test_output_unpack(self, app): def make_empty_response(): return {'foo': 'bar'} - api = restplus.Api(app) + api = restx.Api(app) with app.test_request_context("/foo"): wrapper = api.output(make_empty_response) @@ -231,7 +231,7 @@ def test_output_func(self, app): def make_empty_resposne(): return flask.make_response('') - api = restplus.Api(app) + api = restx.Api(app) with app.test_request_context("/foo"): wrapper = api.output(make_empty_resposne) @@ -240,13 +240,13 @@ def make_empty_resposne(): assert resp.data.decode() == '' def test_resource(self, app, mocker): - resource = restplus.Resource() + resource = restx.Resource() resource.get = mocker.Mock() with app.test_request_context("/foo"): resource.dispatch_request() def test_resource_resp(self, app, mocker): - resource = restplus.Resource() + resource = restx.Resource() resource.get = mocker.Mock() with app.test_request_context("/foo"): resource.get.return_value = flask.make_response('') @@ -256,7 +256,7 @@ def test_resource_text_plain(self, app): def text(data, code, headers=None): return flask.make_response(six.text_type(data)) - class Foo(restplus.Resource): + class Foo(restx.Resource): representations = { 'text/plain': text, } @@ -271,18 +271,18 @@ def get(self): @pytest.mark.request_context('/foo') def test_resource_error(self, app): - resource = restplus.Resource() + resource = restx.Resource() with pytest.raises(AssertionError): resource.dispatch_request() @pytest.mark.request_context('/foo', method='HEAD') def test_resource_head(self, app): - resource = restplus.Resource() + resource = restx.Resource() with pytest.raises(AssertionError): resource.dispatch_request() def test_endpoints(self, app): - api = restplus.Api(app) + api = restx.Api(app) api.add_resource(HelloWorld, '/ids/', endpoint="hello") with app.test_request_context('/foo'): assert api._has_fr_route() is False @@ -291,7 +291,7 @@ def test_endpoints(self, app): assert api._has_fr_route() is True def test_url_for(self, app): - api = restplus.Api(app) + api = restx.Api(app) api.add_resource(HelloWorld, '/ids/') with app.test_request_context('/foo'): assert api.url_for(HelloWorld, id=123) == '/ids/123' @@ -301,7 +301,7 @@ def test_url_for_with_blueprint(self, app): Blueprint. """ api_bp = Blueprint('api', __name__) - api = restplus.Api(api_bp) + api = restx.Api(api_bp) api.add_resource(HelloWorld, '/foo/') app.register_blueprint(api_bp) with app.test_request_context('/foo'): @@ -323,9 +323,9 @@ class TestConfig(object): 'separators': (', ', ': ')} app.config.from_object(TestConfig) - api = restplus.Api(app) + api = restx.Api(app) - class Foo(restplus.Resource): + class Foo(restx.Resource): def get(self): return {'foo': 'bar', 'baz': 'qux'} @@ -346,9 +346,9 @@ class TestConfig(object): RESTPLUS_JSON = {'cls': CabageEncoder} app.config.from_object(TestConfig) - api = restplus.Api(app) + api = restx.Api(app) - class Cabbage(restplus.Resource): + class Cabbage(restx.Resource): def get(self): return {'frob': object()} @@ -360,7 +360,7 @@ def get(self): assert data == expected def test_json_with_no_settings(self, api, client): - class Foo(restplus.Resource): + class Foo(restx.Resource): def get(self): return {'foo': 'bar'} @@ -372,7 +372,7 @@ def get(self): assert data == expected def test_redirect(self, api, client): - class FooResource(restplus.Resource): + class FooResource(restx.Resource): def get(self): return redirect('/') @@ -383,7 +383,7 @@ def get(self): assert resp.headers['Location'] == 'http://localhost/' def test_calling_owns_endpoint_before_api_init(self): - api = restplus.Api() + api = restx.Api() api.owns_endpoint('endpoint') # with pytest.raises(AttributeError): # try: diff --git a/tests/legacy/test_api_with_blueprint.py b/tests/legacy/test_api_with_blueprint.py index bce08d77..7916a6be 100644 --- a/tests/legacy/test_api_with_blueprint.py +++ b/tests/legacy/test_api_with_blueprint.py @@ -5,16 +5,16 @@ from flask import Blueprint, request -import flask_restplus as restplus +import flask_restx as restx # Add a dummy Resource to verify that the app is properly set. -class HelloWorld(restplus.Resource): +class HelloWorld(restx.Resource): def get(self): return {} -class GoodbyeWorld(restplus.Resource): +class GoodbyeWorld(restx.Resource): def __init__(self, err): self.err = err @@ -25,7 +25,7 @@ def get(self): class APIWithBlueprintTest(object): def test_api_base(self, app): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint) + api = restx.Api(blueprint) app.register_blueprint(blueprint) assert api.urls == {} assert api.prefix == '' @@ -33,14 +33,14 @@ def test_api_base(self, app): def test_api_delayed_initialization(self, app): blueprint = Blueprint('test', __name__) - api = restplus.Api() + api = restx.Api() api.init_app(blueprint) app.register_blueprint(blueprint) api.add_resource(HelloWorld, '/', endpoint="hello") def test_add_resource_endpoint(self, app, mocker): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint) + api = restx.Api(blueprint) view = mocker.Mock(**{'as_view.return_value.__name__': str('test_view')}) api.add_resource(view, '/foo', endpoint='bar') app.register_blueprint(blueprint) @@ -48,7 +48,7 @@ def test_add_resource_endpoint(self, app, mocker): def test_add_resource_endpoint_after_registration(self, app, mocker): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint) + api = restx.Api(blueprint) app.register_blueprint(blueprint) view = mocker.Mock(**{'as_view.return_value.__name__': str('test_view')}) api.add_resource(view, '/foo', endpoint='bar') @@ -56,7 +56,7 @@ def test_add_resource_endpoint_after_registration(self, app, mocker): def test_url_with_api_prefix(self, app): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint, prefix='/api') + api = restx.Api(blueprint, prefix='/api') api.add_resource(HelloWorld, '/hi', endpoint='hello') app.register_blueprint(blueprint) with app.test_request_context('/api/hi'): @@ -64,7 +64,7 @@ def test_url_with_api_prefix(self, app): def test_url_with_blueprint_prefix(self, app): blueprint = Blueprint('test', __name__, url_prefix='/bp') - api = restplus.Api(blueprint) + api = restx.Api(blueprint) api.add_resource(HelloWorld, '/hi', endpoint='hello') app.register_blueprint(blueprint) with app.test_request_context('/bp/hi'): @@ -72,7 +72,7 @@ def test_url_with_blueprint_prefix(self, app): def test_url_with_registration_prefix(self, app): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint) + api = restx.Api(blueprint) api.add_resource(HelloWorld, '/hi', endpoint='hello') app.register_blueprint(blueprint, url_prefix='/reg') with app.test_request_context('/reg/hi'): @@ -80,7 +80,7 @@ def test_url_with_registration_prefix(self, app): def test_registration_prefix_overrides_blueprint_prefix(self, app): blueprint = Blueprint('test', __name__, url_prefix='/bp') - api = restplus.Api(blueprint) + api = restx.Api(blueprint) api.add_resource(HelloWorld, '/hi', endpoint='hello') app.register_blueprint(blueprint, url_prefix='/reg') with app.test_request_context('/reg/hi'): @@ -88,7 +88,7 @@ def test_registration_prefix_overrides_blueprint_prefix(self, app): def test_url_with_api_and_blueprint_prefix(self, app): blueprint = Blueprint('test', __name__, url_prefix='/bp') - api = restplus.Api(blueprint, prefix='/api') + api = restx.Api(blueprint, prefix='/api') api.add_resource(HelloWorld, '/hi', endpoint='hello') app.register_blueprint(blueprint) with app.test_request_context('/bp/api/hi'): @@ -96,7 +96,7 @@ def test_url_with_api_and_blueprint_prefix(self, app): def test_error_routing(self, app, mocker): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint) + api = restx.Api(blueprint) api.add_resource(HelloWorld, '/hi', endpoint="hello") api.add_resource(GoodbyeWorld(404), '/bye', endpoint="bye") app.register_blueprint(blueprint) @@ -109,11 +109,11 @@ def test_error_routing(self, app, mocker): def test_non_blueprint_rest_error_routing(self, app, mocker): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint) + api = restx.Api(blueprint) api.add_resource(HelloWorld, '/hi', endpoint="hello") api.add_resource(GoodbyeWorld(404), '/bye', endpoint="bye") app.register_blueprint(blueprint, url_prefix='/blueprint') - api2 = restplus.Api(app) + api2 = restx.Api(app) api2.add_resource(HelloWorld(api), '/hi', endpoint="hello") api2.add_resource(GoodbyeWorld(404), '/bye', endpoint="bye") with app.test_request_context('/hi', method='POST'): @@ -137,7 +137,7 @@ def test_non_blueprint_rest_error_routing(self, app, mocker): def test_non_blueprint_non_rest_error_routing(self, app, mocker): blueprint = Blueprint('test', __name__) - api = restplus.Api(blueprint) + api = restx.Api(blueprint) api.add_resource(HelloWorld, '/hi', endpoint="hello") api.add_resource(GoodbyeWorld(404), '/bye', endpoint="bye") app.register_blueprint(blueprint, url_prefix='/blueprint') diff --git a/tests/test_accept.py b/tests/test_accept.py index fb6f5ee5..784677db 100644 --- a/tests/test_accept.py +++ b/tests/test_accept.py @@ -1,17 +1,17 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import flask_restplus as restplus +import flask_restx as restx -class Foo(restplus.Resource): +class Foo(restx.Resource): def get(self): return "data" class ErrorsTest(object): def test_accept_default_application_json(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) api.add_resource(Foo, '/test/') res = client.get('/test/', headers={'Accept': None}) @@ -19,7 +19,7 @@ def test_accept_default_application_json(self, app, client): assert res.content_type == 'application/json' def test_accept_application_json_by_default(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) api.add_resource(Foo, '/test/') res = client.get('/test/', headers=[('Accept', 'application/json')]) @@ -27,7 +27,7 @@ def test_accept_application_json_by_default(self, app, client): assert res.content_type == 'application/json' def test_accept_no_default_match_acceptable(self, app, client): - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) api.add_resource(Foo, '/test/') res = client.get('/test/', headers=[('Accept', 'application/json')]) @@ -35,7 +35,7 @@ def test_accept_no_default_match_acceptable(self, app, client): assert res.content_type == 'application/json' def test_accept_default_override_accept(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) api.add_resource(Foo, '/test/') res = client.get('/test/', headers=[('Accept', 'text/plain')]) @@ -43,7 +43,7 @@ def test_accept_default_override_accept(self, app, client): assert res.content_type == 'application/json' def test_accept_default_any_pick_first(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.representation('text/plain') def text_rep(data, status_code, headers=None): @@ -57,7 +57,7 @@ def text_rep(data, status_code, headers=None): assert res.content_type == 'application/json' def test_accept_no_default_no_match_not_acceptable(self, app, client): - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) api.add_resource(Foo, '/test/') res = client.get('/test/', headers=[('Accept', 'text/plain')]) @@ -65,7 +65,7 @@ def test_accept_no_default_no_match_not_acceptable(self, app, client): assert res.content_type == 'application/json' def test_accept_no_default_custom_repr_match(self, app, client): - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) api.representations = {} @api.representation('text/plain') @@ -80,7 +80,7 @@ def text_rep(data, status_code, headers=None): assert res.content_type == 'text/plain' def test_accept_no_default_custom_repr_not_acceptable(self, app, client): - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) api.representations = {} @api.representation('text/plain') @@ -100,7 +100,7 @@ def test_accept_no_default_match_q0_not_acceptable(self, app, client): but this depends on werkzeug >= 1.0 which is not yet released so this test is expected to fail until we depend on werkzeug >= 1.0 """ - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) api.add_resource(Foo, '/test/') res = client.get('/test/', headers=[('Accept', 'application/json; q=0')]) @@ -108,7 +108,7 @@ def test_accept_no_default_match_q0_not_acceptable(self, app, client): assert res.content_type == 'application/json' def test_accept_no_default_accept_highest_quality_of_two(self, app, client): - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) @api.representation('text/plain') def text_rep(data, status_code, headers=None): @@ -122,7 +122,7 @@ def text_rep(data, status_code, headers=None): assert res.content_type == 'text/plain' def test_accept_no_default_accept_highest_quality_of_three(self, app, client): - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) @api.representation('text/html') @api.representation('text/plain') @@ -137,7 +137,7 @@ def text_rep(data, status_code, headers=None): assert res.content_type == 'text/plain' def test_accept_no_default_no_representations(self, app, client): - api = restplus.Api(app, default_mediatype=None) + api = restx.Api(app, default_mediatype=None) api.representations = {} api.add_resource(Foo, '/test/') @@ -147,7 +147,7 @@ def test_accept_no_default_no_representations(self, app, client): assert res.content_type == 'text/plain' def test_accept_invalid_default_no_representations(self, app, client): - api = restplus.Api(app, default_mediatype='nonexistant/mediatype') + api = restx.Api(app, default_mediatype='nonexistant/mediatype') api.representations = {} api.add_resource(Foo, '/test/') diff --git a/tests/test_api.py b/tests/test_api.py index 21d02471..30be4a54 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -5,12 +5,12 @@ from flask import url_for, Blueprint -import flask_restplus as restplus +import flask_restx as restx class APITest(object): def test_root_endpoint(self, app): - api = restplus.Api(app, version='1.0') + api = restx.Api(app, version='1.0') with app.test_request_context(): url = url_for('root') @@ -18,7 +18,7 @@ def test_root_endpoint(self, app): assert api.base_url == 'http://localhost/' def test_root_endpoint_lazy(self, app): - api = restplus.Api(version='1.0') + api = restx.Api(version='1.0') api.init_app(app) with app.test_request_context(): @@ -28,7 +28,7 @@ def test_root_endpoint_lazy(self, app): def test_root_endpoint_with_blueprint(self, app): blueprint = Blueprint('api', __name__, url_prefix='/api') - api = restplus.Api(blueprint, version='1.0') + api = restx.Api(blueprint, version='1.0') app.register_blueprint(blueprint) with app.test_request_context(): @@ -38,7 +38,7 @@ def test_root_endpoint_with_blueprint(self, app): def test_root_endpoint_with_blueprint_with_subdomain(self, app): blueprint = Blueprint('api', __name__, subdomain='api', url_prefix='/api') - api = restplus.Api(blueprint, version='1.0') + api = restx.Api(blueprint, version='1.0') app.register_blueprint(blueprint) with app.test_request_context(): @@ -47,27 +47,27 @@ def test_root_endpoint_with_blueprint_with_subdomain(self, app): assert api.base_url == 'http://api.localhost/api/' def test_parser(self): - api = restplus.Api() - assert isinstance(api.parser(), restplus.reqparse.RequestParser) + api = restx.Api() + assert isinstance(api.parser(), restx.reqparse.RequestParser) def test_doc_decorator(self, app): - api = restplus.Api(app, prefix='/api', version='1.0') + api = restx.Api(app, prefix='/api', version='1.0') params = {'q': {'description': 'some description'}} @api.doc(params=params) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass assert hasattr(TestResource, '__apidoc__') assert TestResource.__apidoc__ == {'params': params} def test_doc_with_inheritance(self, app): - api = restplus.Api(app, prefix='/api', version='1.0') + api = restx.Api(app, prefix='/api', version='1.0') base_params = {'q': {'description': 'some description', 'type': 'string', 'paramType': 'query'}} child_params = {'q': {'description': 'some new description'}, 'other': {'description': 'another param'}} @api.doc(params=base_params) - class BaseResource(restplus.Resource): + class BaseResource(restx.Resource): pass @api.doc(params=child_params) @@ -84,32 +84,32 @@ class TestResource(BaseResource): }} def test_specs_endpoint_not_added(self, app): - api = restplus.Api() + api = restx.Api() api.init_app(app, add_specs=False) assert 'specs' not in api.endpoints assert 'specs' not in app.view_functions def test_specs_endpoint_not_found_if_not_added(self, app, client): - api = restplus.Api() + api = restx.Api() api.init_app(app, add_specs=False) resp = client.get('/swagger.json') assert resp.status_code == 404 def test_default_endpoint(self, app): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass with app.test_request_context(): assert url_for('test_resource') == '/test/' def test_default_endpoint_lazy(self, app): - api = restplus.Api() + api = restx.Api() @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass api.init_app(app) @@ -119,11 +119,11 @@ class TestResource(restplus.Resource): def test_default_endpoint_with_blueprint(self, app): blueprint = Blueprint('api', __name__, url_prefix='/api') - api = restplus.Api(blueprint) + api = restx.Api(blueprint) app.register_blueprint(blueprint) @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass with app.test_request_context(): @@ -131,33 +131,33 @@ class TestResource(restplus.Resource): def test_default_endpoint_with_blueprint_with_subdomain(self, app): blueprint = Blueprint('api', __name__, subdomain='api', url_prefix='/api') - api = restplus.Api(blueprint) + api = restx.Api(blueprint) app.register_blueprint(blueprint) @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass with app.test_request_context(): assert url_for('api.test_resource') == 'http://api.localhost/api/test/' def test_default_endpoint_for_namespace(self, app): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('ns', 'Test namespace') @ns.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass with app.test_request_context(): assert url_for('ns_test_resource') == '/ns/test/' def test_default_endpoint_lazy_for_namespace(self, app): - api = restplus.Api() + api = restx.Api() ns = api.namespace('ns', 'Test namespace') @ns.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass api.init_app(app) @@ -167,11 +167,11 @@ class TestResource(restplus.Resource): def test_default_endpoint_for_namespace_with_blueprint(self, app): blueprint = Blueprint('api', __name__, url_prefix='/api') - api = restplus.Api(blueprint) + api = restx.Api(blueprint) ns = api.namespace('ns', 'Test namespace') @ns.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass app.register_blueprint(blueprint) @@ -180,11 +180,11 @@ class TestResource(restplus.Resource): assert url_for('api.ns_test_resource') == '/api/ns/test/' def test_multiple_default_endpoint(self, app): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test2/') @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass with app.test_request_context(): @@ -192,11 +192,11 @@ class TestResource(restplus.Resource): assert url_for('test_resource_2') == '/test2/' def test_multiple_default_endpoint_lazy(self, app): - api = restplus.Api() + api = restx.Api() @api.route('/test2/') @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass api.init_app(app) @@ -206,12 +206,12 @@ class TestResource(restplus.Resource): assert url_for('test_resource_2') == '/test2/' def test_multiple_default_endpoint_for_namespace(self, app): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('ns', 'Test namespace') @ns.route('/test2/') @ns.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass with app.test_request_context(): @@ -219,12 +219,12 @@ class TestResource(restplus.Resource): assert url_for('ns_test_resource_2') == '/ns/test2/' def test_multiple_default_endpoint_lazy_for_namespace(self, app): - api = restplus.Api() + api = restx.Api() ns = api.namespace('ns', 'Test namespace') @ns.route('/test2/') @ns.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass api.init_app(app) @@ -235,12 +235,12 @@ class TestResource(restplus.Resource): def test_multiple_default_endpoint_for_namespace_with_blueprint(self, app): blueprint = Blueprint('api', __name__, url_prefix='/api') - api = restplus.Api(blueprint) + api = restx.Api(blueprint) ns = api.namespace('ns', 'Test namespace') @ns.route('/test2/') @ns.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass app.register_blueprint(blueprint) @@ -250,11 +250,11 @@ class TestResource(restplus.Resource): assert url_for('api.ns_test_resource_2') == '/api/ns/test2/' def test_ns_path_prefixes(self, app): - api = restplus.Api() - ns = restplus.Namespace('test_ns', description='Test namespace') + api = restx.Api() + ns = restx.Namespace('test_ns', description='Test namespace') @ns.route('/test/', endpoint='test_resource') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass api.add_namespace(ns, '/api_test') @@ -264,7 +264,7 @@ class TestResource(restplus.Resource): assert url_for('test_resource') == '/api_test/test/' def test_multiple_ns_with_authorizations(self, app): - api = restplus.Api() + api = restx.Api() a1 = { 'apikey': { 'type': 'apiKey', @@ -283,17 +283,17 @@ def test_multiple_ns_with_authorizations(self, app): } } } - ns1 = restplus.Namespace('ns1', authorizations=a1) - ns2 = restplus.Namespace('ns2', authorizations=a2) + ns1 = restx.Namespace('ns1', authorizations=a1) + ns2 = restx.Namespace('ns2', authorizations=a2) @ns1.route('/') - class Ns1(restplus.Resource): + class Ns1(restx.Resource): @ns1.doc(security='apikey') def get(self): pass @ns2.route('/') - class Ns2(restplus.Resource): + class Ns2(restx.Resource): @ns1.doc(security='oauth2') def post(self): pass @@ -309,13 +309,13 @@ def post(self): assert api.__schema__["securityDefinitions"] == unified_auth def test_non_ordered_namespace(self, app): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('ns', 'Test namespace') assert not ns.ordered def test_ordered_namespace(self, app): - api = restplus.Api(app, ordered=True) + api = restx.Api(app, ordered=True) ns = api.namespace('ns', 'Test namespace') assert ns.ordered @@ -325,10 +325,10 @@ def test_decorators(self, app, mocker): decorator2 = mocker.Mock(return_value=lambda x: x) decorator3 = mocker.Mock(return_value=lambda x: x) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): method_decorators = [] - api = restplus.Api(decorators=[decorator1]) + api = restx.Api(decorators=[decorator1]) ns = api.namespace('test_ns', decorators=[decorator2, decorator3]) ns.add_resource(TestResource, '/test', endpoint='test') diff --git a/tests/test_apidoc.py b/tests/test_apidoc.py index 1f0a9bca..8fb995fb 100644 --- a/tests/test_apidoc.py +++ b/tests/test_apidoc.py @@ -6,12 +6,12 @@ from flask import url_for, Blueprint from werkzeug.routing import BuildError -import flask_restplus as restplus +import flask_restx as restx class APIDocTest(object): def test_default_apidoc_on_root(self, app, client): - restplus.Api(app, version='1.0') + restx.Api(app, version='1.0') assert url_for('doc') == url_for('root') @@ -20,7 +20,7 @@ def test_default_apidoc_on_root(self, app, client): assert response.content_type == 'text/html; charset=utf-8' def test_default_apidoc_on_root_lazy(self, app, client): - api = restplus.Api(version='1.0') + api = restx.Api(version='1.0') api.init_app(app) assert url_for('doc') == url_for('root') @@ -31,7 +31,7 @@ def test_default_apidoc_on_root_lazy(self, app, client): def test_default_apidoc_on_root_with_blueprint(self, app, client): blueprint = Blueprint('api', __name__, url_prefix='/api') - restplus.Api(blueprint, version='1.0') + restx.Api(blueprint, version='1.0') app.register_blueprint(blueprint) assert url_for('api.doc') == url_for('api.root') @@ -42,7 +42,7 @@ def test_default_apidoc_on_root_with_blueprint(self, app, client): def test_apidoc_with_custom_validator(self, app, client): app.config['SWAGGER_VALIDATOR_URL'] = 'http://somewhere.com/validator' - restplus.Api(app, version='1.0') + restx.Api(app, version='1.0') response = client.get(url_for('doc')) assert response.status_code == 200 @@ -50,7 +50,7 @@ def test_apidoc_with_custom_validator(self, app, client): assert 'validatorUrl: "http://somewhere.com/validator" || null,' in str(response.data) def test_apidoc_doc_expansion_parameter(self, app, client): - restplus.Api(app) + restx.Api(app) response = client.get(url_for('doc')) assert 'docExpansion: "none"' in str(response.data) @@ -64,7 +64,7 @@ def test_apidoc_doc_expansion_parameter(self, app, client): assert 'docExpansion: "full"' in str(response.data) def test_apidoc_doc_display_operation_id(self, app, client): - restplus.Api(app) + restx.Api(app) response = client.get(url_for('doc')) assert 'displayOperationId: false' in str(response.data) @@ -78,7 +78,7 @@ def test_apidoc_doc_display_operation_id(self, app, client): assert 'displayOperationId: true' in str(response.data) def test_apidoc_doc_display_request_duration(self, app, client): - restplus.Api(app) + restx.Api(app) response = client.get(url_for('doc')) assert 'displayRequestDuration: false' in str(response.data) @@ -92,7 +92,7 @@ def test_apidoc_doc_display_request_duration(self, app, client): assert 'displayRequestDuration: true' in str(response.data) def test_custom_apidoc_url(self, app, client): - restplus.Api(app, version='1.0', doc='/doc/') + restx.Api(app, version='1.0', doc='/doc/') doc_url = url_for('doc') root_url = url_for('root') @@ -109,12 +109,12 @@ def test_custom_apidoc_url(self, app, client): def test_custom_api_prefix(self, app, client): prefix = '/api' - api = restplus.Api(app, prefix=prefix) + api = restx.Api(app, prefix=prefix) api.namespace('resource') assert url_for('root') == prefix def test_custom_apidoc_page(self, app, client): - api = restplus.Api(app, version='1.0') + api = restx.Api(app, version='1.0') content = 'My Custom API Doc' @api.documentation @@ -127,7 +127,7 @@ def api_doc(): def test_custom_apidoc_page_lazy(self, app, client): blueprint = Blueprint('api', __name__, url_prefix='/api') - api = restplus.Api(blueprint, version='1.0') + api = restx.Api(blueprint, version='1.0') content = 'My Custom API Doc' @api.documentation @@ -141,7 +141,7 @@ def api_doc(): assert response.data.decode('utf8') == content def test_disabled_apidoc(self, app, client): - restplus.Api(app, version='1.0', doc=False) + restx.Api(app, version='1.0', doc=False) with pytest.raises(BuildError): url_for('doc') diff --git a/tests/test_cors.py b/tests/test_cors.py index fbf79093..3d5e49fe 100644 --- a/tests/test_cors.py +++ b/tests/test_cors.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from flask_restplus import Api, Resource, cors +from flask_restx import Api, Resource, cors class ErrorsTest(object): diff --git a/tests/test_errors.py b/tests/test_errors.py index b196efe3..421a4f5c 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -12,34 +12,34 @@ from werkzeug.exceptions import HTTPException, BadRequest, NotFound, Aborter from werkzeug.http import quote_etag, unquote_etag -import flask_restplus as restplus +import flask_restx as restx class ErrorsTest(object): def test_abort_type(self): with pytest.raises(HTTPException): - restplus.abort(404) + restx.abort(404) def test_abort_data(self): with pytest.raises(HTTPException) as cm: - restplus.abort(404, foo='bar') + restx.abort(404, foo='bar') assert cm.value.data == {'foo': 'bar'} def test_abort_no_data(self): with pytest.raises(HTTPException) as cm: - restplus.abort(404) + restx.abort(404) assert not hasattr(cm.value, 'data') def test_abort_custom_message(self): with pytest.raises(HTTPException) as cm: - restplus.abort(404, 'My message') + restx.abort(404, 'My message') assert cm.value.data['message'] == 'My message' def test_abort_code_only_with_defaults(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): api.abort(403) @@ -51,10 +51,10 @@ def get(self): assert 'message' in data def test_abort_with_message(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): api.abort(403, 'A message') @@ -66,10 +66,10 @@ def get(self): assert data['message'] == 'A message' def test_abort_with_lazy_init(self, app, client): - api = restplus.Api() + api = restx.Api() @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): api.abort(403) @@ -83,10 +83,10 @@ def get(self): assert 'message' in data def test_abort_on_exception(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise ValueError() @@ -98,10 +98,10 @@ def get(self): assert 'message' in data def test_abort_on_exception_with_lazy_init(self, app, client): - api = restplus.Api() + api = restx.Api() @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise ValueError() @@ -115,13 +115,13 @@ def get(self): assert 'message' in data def test_errorhandler_for_exception_inheritance(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) class CustomException(RuntimeError): pass @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise CustomException('error') @@ -140,13 +140,13 @@ def handle_custom_exception(error): } def test_errorhandler_for_custom_exception(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) class CustomException(RuntimeError): pass @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise CustomException('error') @@ -166,7 +166,7 @@ def handle_custom_exception(error): def test_blunder_in_errorhandler_is_not_suppressed_in_logs(self, app, client, caplog): - api = restplus.Api(app) + api = restx.Api(app) class CustomException(RuntimeError): pass @@ -175,7 +175,7 @@ class ProgrammingBlunder(Exception): pass @api.route('/test/', endpoint="test") - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise CustomException('error') @@ -190,13 +190,13 @@ def handle_custom_exception(error): assert response.status_code == 500 def test_errorhandler_for_custom_exception_with_headers(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) class CustomException(RuntimeError): pass @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise CustomException('error') @@ -213,10 +213,10 @@ def handle_custom_exception(error): assert response.headers['Retry-After'] == '120' def test_errorhandler_for_httpexception(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise BadRequest() @@ -235,15 +235,15 @@ def handle_badrequest_exception(error): } def test_errorhandler_with_namespace(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) - ns = restplus.Namespace("ExceptionHandler", path="/") + ns = restx.Namespace("ExceptionHandler", path="/") class CustomException(RuntimeError): pass @ns.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise CustomException('error') @@ -264,7 +264,7 @@ def handle_custom_exception(error): } def test_errorhandler_with_namespace_from_api(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace("ExceptionHandler", path="/") @@ -272,7 +272,7 @@ class CustomException(RuntimeError): pass @ns.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise CustomException('error') @@ -291,10 +291,10 @@ def handle_custom_exception(error): } def test_default_errorhandler(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise Exception('error') @@ -307,10 +307,10 @@ def get(self): def test_default_errorhandler_with_propagate_true(self, app, client): blueprint = Blueprint('api', __name__, url_prefix='/api') - api = restplus.Api(blueprint) + api = restx.Api(blueprint) @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise Exception('error') @@ -326,10 +326,10 @@ def get(self): client.get('/api/test/') def test_custom_default_errorhandler(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise Exception('error') @@ -348,10 +348,10 @@ def default_error_handler(error): } def test_custom_default_errorhandler_with_headers(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise Exception('error') @@ -368,13 +368,13 @@ def default_error_handler(error): assert response.headers['Retry-After'] == '120' def test_errorhandler_lazy(self, app, client): - api = restplus.Api() + api = restx.Api() class CustomException(RuntimeError): pass @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise CustomException('error') @@ -395,10 +395,10 @@ def handle_custom_exception(error): } def test_handle_api_error(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/api', endpoint='api') - class Test(restplus.Resource): + class Test(restx.Resource): def get(self): abort(404) @@ -409,20 +409,20 @@ def get(self): assert 'message' in data def test_handle_non_api_error(self, app, client): - restplus.Api(app) + restx.Api(app) response = client.get("/foo") assert response.status_code == 404 assert response.headers['Content-Type'] == 'text/html' def test_non_api_error_404_catchall(self, app, client): - api = restplus.Api(app, catch_all_404s=True) + api = restx.Api(app, catch_all_404s=True) response = client.get("/foo") assert response.headers['Content-Type'] == api.default_mediatype def test_handle_error_signal(self, app): - api = restplus.Api(app) + api = restx.Api(app) exception = BadRequest() @@ -441,7 +441,7 @@ def record(sender, exception): got_request_exception.disconnect(record, app) def test_handle_error(self, app): - api = restplus.Api(app) + api = restx.Api(app) response = api.handle_error(BadRequest()) assert response.status_code == 400 @@ -450,15 +450,15 @@ def test_handle_error(self, app): } def test_handle_error_does_not_duplicate_content_length(self, app): - api = restplus.Api(app) + api = restx.Api(app) # with self.app.test_request_context("/foo"): response = api.handle_error(BadRequest()) assert len(response.headers.getlist('Content-Length')) == 1 def test_handle_smart_errors(self, app): - api = restplus.Api(app) - view = restplus.Resource + api = restx.Api(app) + view = restx.Resource api.add_resource(view, '/foo', endpoint='bor') api.add_resource(view, '/fee', endpoint='bir') @@ -485,8 +485,8 @@ def test_handle_smart_errors(self, app): } def test_handle_include_error_message(self, app): - api = restplus.Api(app) - view = restplus.Resource + api = restx.Api(app) + view = restx.Resource api.add_resource(view, '/foo', endpoint='bor') @@ -497,8 +497,8 @@ def test_handle_include_error_message(self, app): def test_handle_not_include_error_message(self, app): app.config['ERROR_INCLUDE_MESSAGE'] = False - api = restplus.Api(app) - view = restplus.Resource + api = restx.Api(app) + view = restx.Resource api.add_resource(view, '/foo', endpoint='bor') @@ -515,7 +515,7 @@ class ProgrammingBlunder(Exception): def raise_blunder(arg): raise blunder - api = restplus.Api(app) + api = restx.Api(app) app.handle_exception = mocker.Mock() api.handle_error = mocker.Mock(side_effect=raise_blunder) api._has_fr_route = mocker.Mock(return_value=True) @@ -526,10 +526,10 @@ def raise_blunder(arg): app.handle_exception.assert_called_with(blunder) def test_fr_405(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/ids/', endpoint='hello') - class HelloWorld(restplus.Resource): + class HelloWorld(restx.Resource): def get(self): return {} @@ -544,7 +544,7 @@ def get(self): @pytest.mark.options(debug=True) def test_exception_header_forwarded(self, app, client): '''Ensure that HTTPException's headers are extended properly''' - api = restplus.Api(app) + api = restx.Api(app) class NotModified(HTTPException): code = 304 @@ -559,7 +559,7 @@ def get_headers(self, *args, **kwargs): custom_abort = Aborter(mapping={304: NotModified}) @api.route('/foo') - class Foo1(restplus.Resource): + class Foo1(restx.Resource): def get(self): custom_abort(304, etag='myETag') @@ -567,7 +567,7 @@ def get(self): assert foo.get_etag() == unquote_etag(quote_etag('myETag')) def test_handle_server_error(self, app): - api = restplus.Api(app) + api = restx.Api(app) resp = api.handle_error(Exception()) assert resp.status_code == 500 @@ -576,7 +576,7 @@ def test_handle_server_error(self, app): } def test_handle_error_with_code(self, app): - api = restplus.Api(app, serve_challenge_on_401=True) + api = restx.Api(app, serve_challenge_on_401=True) exception = Exception() exception.code = "Not an integer" @@ -587,17 +587,17 @@ def test_handle_error_with_code(self, app): assert json.loads(response.data.decode()) == {"foo": "bar"} def test_errorhandler_swagger_doc(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) class CustomException(RuntimeError): pass error = api.model('Error', { - 'message': restplus.fields.String() + 'message': restx.fields.String() }) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): ''' Do something @@ -642,10 +642,10 @@ def test_errorhandler_with_propagate_true(self, app, client): '''Exceptions with errorhandler should not be returned to client, even if PROPAGATE_EXCEPTIONS is set.''' app.config['PROPAGATE_EXCEPTIONS'] = True - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): raise RuntimeError('error') diff --git a/tests/test_fields.py b/tests/test_fields.py index 837e607d..cb145bc4 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -14,7 +14,7 @@ import pytest from flask import Blueprint -from flask_restplus import fields, Api +from flask_restx import fields, Api class FieldTestCase(object): @@ -1183,7 +1183,7 @@ class Child2(object): def test_polymorph_field_does_not_have_ambiguous_mappings(self, api): """ - Regression test for https://github.com/noirbizarre/flask-restplus/pull/691 + Regression test for https://github.com/noirbizarre/flask-restx/pull/691 """ parent = api.model('Parent', { 'name': fields.String, diff --git a/tests/test_fields_mask.py b/tests/test_fields_mask.py index 7ffeefc8..3e2bfe6d 100644 --- a/tests/test_fields_mask.py +++ b/tests/test_fields_mask.py @@ -10,7 +10,7 @@ # TODO Remove this to drop Python2 support from collections import OrderedDict -from flask_restplus import mask, Api, Resource, fields, marshal, Mask +from flask_restx import mask, Api, Resource, fields, marshal, Mask def assert_data(tested, expected): diff --git a/tests/test_inputs.py b/tests/test_inputs.py index 23a50041..ce3ccd3d 100644 --- a/tests/test_inputs.py +++ b/tests/test_inputs.py @@ -8,7 +8,7 @@ from datetime import date, datetime from six import text_type -from flask_restplus import inputs +from flask_restx import inputs class Iso8601DateTest(object): diff --git a/tests/test_logging.py b/tests/test_logging.py index e3ed832e..2db298af 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -1,6 +1,6 @@ import logging -import flask_restplus as restplus +import flask_restx as restx class LoggingTest(object): @@ -8,18 +8,18 @@ def test_namespace_loggers_log_to_flask_app_logger(self, app, client, caplog): # capture Flask app logs caplog.set_level(logging.INFO, logger=app.logger.name) - api = restplus.Api(app) + api = restx.Api(app) ns1 = api.namespace('ns1', path='/ns1') ns2 = api.namespace('ns2', path='/ns2') @ns1.route('/') - class Ns1(restplus.Resource): + class Ns1(restx.Resource): def get(self): ns1.logger.info("hello from ns1") pass @ns2.route('/') - class Ns2(restplus.Resource): + class Ns2(restx.Resource): def get(self): ns2.logger.info("hello from ns2") pass @@ -37,18 +37,18 @@ def get(self): def test_defaults_to_app_level(self, app, client, caplog): caplog.set_level(logging.INFO, logger=app.logger.name) - api = restplus.Api(app) + api = restx.Api(app) ns1 = api.namespace('ns1', path='/ns1') ns2 = api.namespace('ns2', path='/ns2') @ns1.route('/') - class Ns1(restplus.Resource): + class Ns1(restx.Resource): def get(self): ns1.logger.debug("hello from ns1") pass @ns2.route('/') - class Ns2(restplus.Resource): + class Ns2(restx.Resource): def get(self): ns2.logger.info("hello from ns2") pass @@ -66,19 +66,19 @@ def get(self): def test_override_app_level(self, app, client, caplog): caplog.set_level(logging.INFO, logger=app.logger.name) - api = restplus.Api(app) + api = restx.Api(app) ns1 = api.namespace('ns1', path='/ns1') ns1.logger.setLevel(logging.DEBUG) ns2 = api.namespace('ns2', path='/ns2') @ns1.route('/') - class Ns1(restplus.Resource): + class Ns1(restx.Resource): def get(self): ns1.logger.debug("hello from ns1") pass @ns2.route('/') - class Ns2(restplus.Resource): + class Ns2(restx.Resource): def get(self): ns2.logger.debug("hello from ns2") pass @@ -97,7 +97,7 @@ def test_namespace_additional_handler(self, app, client, caplog, tmp_path): caplog.set_level(logging.INFO, logger=app.logger.name) log_file = tmp_path / "v1.log" - api = restplus.Api(app) + api = restx.Api(app) ns1 = api.namespace('ns1', path='/ns1') # set up a file handler for ns1 only # FileHandler only supports Path object on Python >= 3.6 -> cast to str @@ -107,13 +107,13 @@ def test_namespace_additional_handler(self, app, client, caplog, tmp_path): ns2 = api.namespace('ns2', path='/ns2') @ns1.route('/') - class Ns1(restplus.Resource): + class Ns1(restx.Resource): def get(self): ns1.logger.info("hello from ns1") pass @ns2.route('/') - class Ns2(restplus.Resource): + class Ns2(restx.Resource): def get(self): ns2.logger.info("hello from ns2") pass diff --git a/tests/test_marshalling.py b/tests/test_marshalling.py index 0698c071..8c339471 100644 --- a/tests/test_marshalling.py +++ b/tests/test_marshalling.py @@ -3,7 +3,7 @@ import pytest -from flask_restplus import ( +from flask_restx import ( marshal, marshal_with, marshal_with_field, fields, Api, Resource ) diff --git a/tests/test_model.py b/tests/test_model.py index 677232e0..d683bf81 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -10,7 +10,7 @@ # TODO Remove this to drop Python2 support from collections import OrderedDict -from flask_restplus import fields, Model, OrderedModel, SchemaModel +from flask_restx import fields, Model, OrderedModel, SchemaModel class ModelTest(object): diff --git a/tests/test_namespace.py b/tests/test_namespace.py index fbb26778..f02cfb84 100644 --- a/tests/test_namespace.py +++ b/tests/test_namespace.py @@ -1,22 +1,22 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import flask_restplus as restplus +import flask_restx as restx -from flask_restplus import Namespace, Model, OrderedModel +from flask_restx import Namespace, Model, OrderedModel class NamespaceTest(object): def test_parser(self): api = Namespace('test') - assert isinstance(api.parser(), restplus.reqparse.RequestParser) + assert isinstance(api.parser(), restx.reqparse.RequestParser) def test_doc_decorator(self): api = Namespace('test') params = {'q': {'description': 'some description'}} @api.doc(params=params) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): pass assert hasattr(TestResource, '__apidoc__') @@ -28,7 +28,7 @@ def test_doc_with_inheritance(self): child_params = {'q': {'description': 'some new description'}, 'other': {'description': 'another param'}} @api.doc(params=base_params) - class BaseResource(restplus.Resource): + class BaseResource(restx.Resource): pass @api.doc(params=child_params) @@ -106,18 +106,18 @@ def test_inherit_from_multiple_parents(self): assert 'Child' in api.models def test_api_payload(self, app, client): - api = restplus.Api(app, validate=True) - ns = restplus.Namespace('apples') + api = restx.Api(app, validate=True) + ns = restx.Namespace('apples') api.add_namespace(ns) fields = ns.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @ns.route('/validation/') - class Payload(restplus.Resource): + class Payload(restx.Resource): payload = None @ns.expect(fields) diff --git a/tests/test_payload.py b/tests/test_payload.py index 21738e74..9cca9005 100644 --- a/tests/test_payload.py +++ b/tests/test_payload.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import flask_restplus as restplus +import flask_restx as restx class PayloadTest(object): @@ -13,16 +13,16 @@ def assert_errors(self, client, url, data, *errors): assert error in out['errors'] def test_validation_false_on_constructor(self, app, client): - api = restplus.Api(app, validate=False) + api = restx.Api(app, validate=False) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class ValidationOff(restplus.Resource): + class ValidationOff(restx.Resource): @api.expect(fields) def post(self): return {} @@ -31,16 +31,16 @@ def post(self): assert data == {} def test_validation_false_on_constructor_with_override(self, app, client): - api = restplus.Api(app, validate=False) + api = restx.Api(app, validate=False) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class ValidationOn(restplus.Resource): + class ValidationOn(restx.Resource): @api.expect(fields, validate=True) def post(self): return {} @@ -48,16 +48,16 @@ def post(self): self.assert_errors(client, '/validation/', {}, 'name') def test_validation_true_on_constructor(self, app, client): - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class ValidationOff(restplus.Resource): + class ValidationOff(restx.Resource): @api.expect(fields) def post(self): return {} @@ -65,16 +65,16 @@ def post(self): self.assert_errors(client, '/validation/', {}, 'name') def test_validation_true_on_constructor_with_override(self, app, client): - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class ValidationOff(restplus.Resource): + class ValidationOff(restx.Resource): @api.expect(fields, validate=False) def post(self): return {} @@ -83,15 +83,15 @@ def post(self): assert data == {} def _setup_api_format_checker_tests(self, app, format_checker=None): - class IPAddress(restplus.fields.Raw): + class IPAddress(restx.fields.Raw): __schema_type__ = 'string' __schema_format__ = 'ipv4' - api = restplus.Api(app, format_checker=format_checker) + api = restx.Api(app, format_checker=format_checker) model = api.model('MyModel', {'ip': IPAddress(required=True)}) @api.route('/format_checker/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.expect(model, validate=True) def post(self): return {} @@ -111,16 +111,16 @@ def test_format_checker_object_on_constructor(self, app, client): def test_validation_false_in_config(self, app, client): app.config['RESTPLUS_VALIDATE'] = False - api = restplus.Api(app) + api = restx.Api(app) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class ValidationOff(restplus.Resource): + class ValidationOff(restx.Resource): @api.expect(fields) def post(self): return {} @@ -133,16 +133,16 @@ def post(self): def test_validation_in_config(self, app, client): app.config['RESTPLUS_VALIDATE'] = True - api = restplus.Api(app) + api = restx.Api(app) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class ValidationOn(restplus.Resource): + class ValidationOn(restx.Resource): @api.expect(fields) def post(self): return {} @@ -150,16 +150,16 @@ def post(self): self.assert_errors(client, '/validation/', {}, 'name') def test_api_payload(self, app, client): - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class Payload(restplus.Resource): + class Payload(restx.Resource): payload = None @api.expect(fields) @@ -178,18 +178,18 @@ def post(self): def test_validation_with_inheritance(self, app, client): '''It should perform validation with inheritance (allOf/$ref)''' - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) fields = api.model('Parent', { - 'name': restplus.fields.String(required=True), + 'name': restx.fields.String(required=True), }) child_fields = api.inherit('Child', fields, { - 'age': restplus.fields.Integer, + 'age': restx.fields.Integer, }) @api.route('/validation/') - class Inheritance(restplus.Resource): + class Inheritance(restx.Resource): @api.expect(child_fields) def post(self): return {} @@ -205,20 +205,20 @@ def post(self): def test_validation_on_list(self, app, client): '''It should perform validation on lists''' - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) person = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer(required=True), + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer(required=True), }) family = api.model('Family', { - 'name': restplus.fields.String(required=True), - 'members': restplus.fields.List(restplus.fields.Nested(person)) + 'name': restx.fields.String(required=True), + 'members': restx.fields.List(restx.fields.Nested(person)) }) @api.route('/validation/') - class List(restplus.Resource): + class List(restx.Resource): @api.expect(family) def post(self): return {} @@ -231,14 +231,14 @@ def post(self): def _setup_expect_validation_single_resource_tests(self, app): # Setup a minimal Api with endpoint that expects in input payload # a single object of a resource - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) user = api.model('User', { - 'username': restplus.fields.String() + 'username': restx.fields.String() }) @api.route('/validation/') - class Users(restplus.Resource): + class Users(restx.Resource): @api.expect(user) def post(self): return {} @@ -246,14 +246,14 @@ def post(self): def _setup_expect_validation_collection_resource_tests(self, app): # Setup a minimal Api with endpoint that expects in input payload # one or more objects of a resource - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) user = api.model('User', { - 'username': restplus.fields.String() + 'username': restx.fields.String() }) @api.route('/validation/') - class Users(restplus.Resource): + class Users(restx.Resource): @api.expect([user]) def post(self): return {} @@ -312,16 +312,16 @@ def test_expect_validation_collection_resource_error(self, app, client): def test_validation_with_propagate(self, app, client): app.config['PROPAGATE_EXCEPTIONS'] = True - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) fields = api.model('Person', { - 'name': restplus.fields.String(required=True), - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String(required=True), + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/validation/') - class ValidationOff(restplus.Resource): + class ValidationOff(restx.Resource): @api.expect(fields) def post(self): return {} @@ -329,10 +329,10 @@ def post(self): self.assert_errors(client, '/validation/', {}, 'name') def test_empty_payload(self, app, client): - api = restplus.Api(app, validate=True) + api = restx.Api(app, validate=True) @api.route('/empty/') - class Payload(restplus.Resource): + class Payload(restx.Resource): def post(self): return {} diff --git a/tests/test_postman.py b/tests/test_postman.py index 2ef46b4e..b9e98625 100644 --- a/tests/test_postman.py +++ b/tests/test_postman.py @@ -8,7 +8,7 @@ from jsonschema import validate from werkzeug.datastructures import FileStorage -import flask_restplus as restplus +import flask_restx as restx from six.moves.urllib.parse import parse_qs, urlparse @@ -19,7 +19,7 @@ class PostmanTest(object): def test_basic_export(self, app): - api = restplus.Api(app) + api = restx.Api(app) data = api.as_postman() @@ -28,7 +28,7 @@ def test_basic_export(self, app): assert len(data['requests']) == 0 def test_export_infos(self, app): - api = restplus.Api(app, version='1.0', + api = restx.Api(app, version='1.0', title='My API', description='This is a testing API', ) @@ -41,10 +41,10 @@ def test_export_infos(self, app): assert data['description'] == 'This is a testing API' def test_export_with_one_entry(self, app): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test') - class Test(restplus.Resource): + class Test(restx.Resource): @api.doc('test_post') def post(self): '''A test post''' @@ -67,11 +67,11 @@ def post(self): assert request['folder'] == folder['id'] def test_export_with_namespace(self, app): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('test', 'A test namespace') @ns.route('/test') - class Test(restplus.Resource): + class Test(restx.Resource): @api.doc('test_post') def post(self): '''A test post''' @@ -94,7 +94,7 @@ def post(self): assert request['folder'] == folder['id'] def test_id_is_the_same(self, app): - api = restplus.Api(app) + api = restx.Api(app) first = api.as_postman() @@ -104,23 +104,23 @@ def test_id_is_the_same(self, app): def test_resources_order_in_folder(self, app): '''It should preserve resources order''' - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('test', 'A test namespace') @ns.route('/test1') - class Test1(restplus.Resource): + class Test1(restx.Resource): @api.doc('test_post_z') def post(self): pass @ns.route('/test2') - class Test2(restplus.Resource): + class Test2(restx.Resource): @api.doc('test_post_y') def post(self): pass @ns.route('/test3') - class Test3(restplus.Resource): + class Test3(restx.Resource): @api.doc('test_post_x') def post(self): pass @@ -143,10 +143,10 @@ def post(self): assert request['name'] == expected def test_prefix_with_trailing_slash(self, app): - api = restplus.Api(app, prefix='/prefix/') + api = restx.Api(app, prefix='/prefix/') @api.route('/test/') - class Test(restplus.Resource): + class Test(restx.Resource): @api.doc('test_post') def post(self): pass @@ -160,10 +160,10 @@ def post(self): assert request['url'] == 'http://localhost/prefix/test/' def test_prefix_without_trailing_slash(self, app): - api = restplus.Api(app, prefix='/prefix') + api = restx.Api(app, prefix='/prefix') @api.route('/test/') - class Test(restplus.Resource): + class Test(restx.Resource): @api.doc('test_post') def post(self): pass @@ -177,10 +177,10 @@ def post(self): assert request['url'] == 'http://localhost/prefix/test/' def test_path_variables(self, app): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test////') - class Test(restplus.Resource): + class Test(restx.Resource): @api.doc('test_post') def post(self): pass @@ -199,7 +199,7 @@ def post(self): } def test_url_variables_disabled(self, app): - api = restplus.Api(app) + api = restx.Api(app) parser = api.parser() parser.add_argument('int', type=int) @@ -207,7 +207,7 @@ def test_url_variables_disabled(self, app): parser.add_argument('str', type=str) @api.route('/test/') - class Test(restplus.Resource): + class Test(restx.Resource): @api.expect(parser) def get(self): pass @@ -221,7 +221,7 @@ def get(self): assert request['url'] == 'http://localhost/test/' def test_url_variables_enabled(self, app): - api = restplus.Api(app) + api = restx.Api(app) parser = api.parser() parser.add_argument('int', type=int) @@ -229,7 +229,7 @@ def test_url_variables_enabled(self, app): parser.add_argument('str', type=str) @api.route('/test/') - class Test(restplus.Resource): + class Test(restx.Resource): @api.expect(parser) def get(self): pass @@ -252,14 +252,14 @@ def get(self): assert qs['str'][0] == '' def test_headers(self, app): - api = restplus.Api(app) + api = restx.Api(app) parser = api.parser() parser.add_argument('X-Header-1', location='headers', default='xxx') parser.add_argument('X-Header-2', location='headers', required=True) @api.route('/headers/') - class TestHeaders(restplus.Resource): + class TestHeaders(restx.Resource): @api.doc('headers') @api.expect(parser) def get(self): @@ -275,7 +275,7 @@ def get(self): assert headers['X-Header-2'] == '' def test_content_type_header(self, app): - api = restplus.Api(app) + api = restx.Api(app) form_parser = api.parser() form_parser.add_argument('param', type=int, help='Some param', location='form') @@ -283,27 +283,27 @@ def test_content_type_header(self, app): file_parser.add_argument('in_files', type=FileStorage, location='files') @api.route('/json/') - class TestJson(restplus.Resource): + class TestJson(restx.Resource): @api.doc('json') def post(self): pass @api.route('/form/') - class TestForm(restplus.Resource): + class TestForm(restx.Resource): @api.doc('form') @api.expect(form_parser) def post(self): pass @api.route('/file/') - class TestFile(restplus.Resource): + class TestFile(restx.Resource): @api.doc('file') @api.expect(file_parser) def post(self): pass @api.route('/get/') - class TestGet(restplus.Resource): + class TestGet(restx.Resource): @api.doc('get') def get(self): pass @@ -321,7 +321,7 @@ def get(self): assert requests['get'] == '' def test_method_security_headers(self, app): - api = restplus.Api(app, authorizations={ + api = restx.Api(app, authorizations={ 'apikey': { 'type': 'apiKey', 'in': 'header', @@ -330,13 +330,13 @@ def test_method_security_headers(self, app): }) @api.route('/secure/') - class Secure(restplus.Resource): + class Secure(restx.Resource): @api.doc('secure', security='apikey') def get(self): pass @api.route('/unsecure/') - class Unsecure(restplus.Resource): + class Unsecure(restx.Resource): @api.doc('unsecure') def get(self): pass @@ -350,7 +350,7 @@ def get(self): assert requests['secure'] == 'X-API:' def test_global_security_headers(self, app): - api = restplus.Api(app, security='apikey', authorizations={ + api = restx.Api(app, security='apikey', authorizations={ 'apikey': { 'type': 'apiKey', 'in': 'header', @@ -359,7 +359,7 @@ def test_global_security_headers(self, app): }) @api.route('/test/') - class Test(restplus.Resource): + class Test(restx.Resource): def get(self): pass @@ -372,7 +372,7 @@ def get(self): assert headers['X-API'] == '' def test_oauth_security_headers(self, app): - api = restplus.Api(app, security='oauth', authorizations={ + api = restx.Api(app, security='oauth', authorizations={ 'oauth': { 'type': 'oauth2', 'authorizationUrl': 'https://somewhere.com/oauth/authorize', @@ -385,7 +385,7 @@ def test_oauth_security_headers(self, app): }) @api.route('/test/') - class Test(restplus.Resource): + class Test(restx.Resource): def get(self): pass @@ -398,7 +398,7 @@ def get(self): # assert headers['X-API'] == '' def test_export_with_swagger(self, app): - api = restplus.Api(app) + api = restx.Api(app) data = api.as_postman(swagger=True) diff --git a/tests/test_reqparse.py b/tests/test_reqparse.py index db0bdbbf..31849bfe 100644 --- a/tests/test_reqparse.py +++ b/tests/test_reqparse.py @@ -10,9 +10,9 @@ from werkzeug.wrappers import Request from werkzeug.datastructures import FileStorage, MultiDict -from flask_restplus import Api, Model, fields, inputs -from flask_restplus.errors import SpecsError -from flask_restplus.reqparse import Argument, RequestParser, ParseResult +from flask_restx import Api, Model, fields, inputs +from flask_restx.errors import SpecsError +from flask_restx.reqparse import Argument, RequestParser, ParseResult class ReqParseTest(object): @@ -38,7 +38,7 @@ def test_parse_model(self, app): assert args['todo'] == {'task': 'aaa'} def test_help(self, app, mocker): - abort = mocker.patch('flask_restplus.reqparse.abort', + abort = mocker.patch('flask_restx.reqparse.abort', side_effect=BadRequest('Bad Request')) parser = RequestParser() parser.add_argument('foo', choices=('one', 'two'), help='Bad choice.') @@ -50,7 +50,7 @@ def test_help(self, app, mocker): abort.assert_called_with(400, 'Input payload validation failed', errors=expected) def test_no_help(self, app, mocker): - abort = mocker.patch('flask_restplus.reqparse.abort', + abort = mocker.patch('flask_restx.reqparse.abort', side_effect=BadRequest('Bad Request')) parser = RequestParser() parser.add_argument('foo', choices=['one', 'two']) @@ -765,7 +765,7 @@ def test_default_operators(self): assert len(arg.operators) == 1 def test_default_type(self, mocker): - mock_six = mocker.patch('flask_restplus.reqparse.six') + mock_six = mocker.patch('flask_restx.reqparse.six') arg = Argument('foo') sentinel = object() arg.type(sentinel) diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 9d18fc0d..586453e0 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -5,7 +5,7 @@ from jsonschema import ValidationError -from flask_restplus import errors, schemas +from flask_restx import errors, schemas class SchemasTest: diff --git a/tests/test_swagger.py b/tests/test_swagger.py index 07337088..9942c3de 100644 --- a/tests/test_swagger.py +++ b/tests/test_swagger.py @@ -8,9 +8,9 @@ from flask import url_for, Blueprint from werkzeug.datastructures import FileStorage -import flask_restplus as restplus +import flask_restx as restx -from flask_restplus import inputs +from flask_restx import inputs class SwaggerTest(object): @@ -45,7 +45,7 @@ def output_xml(data, code, headers=None): assert 'application/xml' in data['produces'] def test_specs_endpoint_info(self, app, client): - api = restplus.Api(version='1.0', + api = restx.Api(version='1.0', title='My API', description='This is a testing API', terms_url='http://somewhere.com/terms/', @@ -79,7 +79,7 @@ def test_specs_endpoint_info(self, app, client): } def test_specs_endpoint_info_delayed(self, app, client): - api = restplus.Api(version='1.0') + api = restx.Api(version='1.0') api.init_app(app, title='My API', description='This is a testing API', @@ -114,7 +114,7 @@ def test_specs_endpoint_info_delayed(self, app, client): } def test_specs_endpoint_info_callable(self, app, client): - api = restplus.Api(version=lambda: '1.0', + api = restx.Api(version=lambda: '1.0', title=lambda: 'My API', description=lambda: 'This is a testing API', terms_url=lambda: 'http://somewhere.com/terms/', @@ -148,43 +148,43 @@ def test_specs_endpoint_info_callable(self, app, client): } def test_specs_endpoint_no_host(self, app, client): - restplus.Api(app) + restx.Api(app) data = client.get_specs('') assert 'host' not in data assert data['basePath'] == '/' - @pytest.mark.options(server_name='api.restplus.org') + @pytest.mark.options(server_name='api.restx.org') def test_specs_endpoint_host(self, app, client): - # app.config['SERVER_NAME'] = 'api.restplus.org' - restplus.Api(app) + # app.config['SERVER_NAME'] = 'api.restx.org' + restx.Api(app) data = client.get_specs('') - assert data['host'] == 'api.restplus.org' + assert data['host'] == 'api.restx.org' assert data['basePath'] == '/' - @pytest.mark.options(server_name='api.restplus.org') + @pytest.mark.options(server_name='api.restx.org') def test_specs_endpoint_host_with_url_prefix(self, app, client): blueprint = Blueprint('api', __name__, url_prefix='/api/1') - restplus.Api(blueprint) + restx.Api(blueprint) app.register_blueprint(blueprint) data = client.get_specs('/api/1') - assert data['host'] == 'api.restplus.org' + assert data['host'] == 'api.restx.org' assert data['basePath'] == '/api/1' - @pytest.mark.options(server_name='restplus.org') + @pytest.mark.options(server_name='restx.org') def test_specs_endpoint_host_and_subdomain(self, app, client): blueprint = Blueprint('api', __name__, subdomain='api') - restplus.Api(blueprint) + restx.Api(blueprint) app.register_blueprint(blueprint) - data = client.get_specs(base_url='http://api.restplus.org') - assert data['host'] == 'api.restplus.org' + data = client.get_specs(base_url='http://api.restx.org') + assert data['host'] == 'api.restx.org' assert data['basePath'] == '/' def test_specs_endpoint_tags_short(self, app, client): - restplus.Api(app, tags=['tag-1', 'tag-2', 'tag-3']) + restx.Api(app, tags=['tag-1', 'tag-2', 'tag-3']) data = client.get_specs('') assert data['tags'] == [ @@ -194,7 +194,7 @@ def test_specs_endpoint_tags_short(self, app, client): ] def test_specs_endpoint_tags_tuple(self, app, client): - restplus.Api(app, tags=[ + restx.Api(app, tags=[ ('tag-1', 'Tag 1'), ('tag-2', 'Tag 2'), ('tag-3', 'Tag 3'), @@ -208,7 +208,7 @@ def test_specs_endpoint_tags_tuple(self, app, client): ] def test_specs_endpoint_tags_dict(self, app, client): - restplus.Api(app, tags=[ + restx.Api(app, tags=[ {'name': 'tag-1', 'description': 'Tag 1'}, {'name': 'tag-2', 'description': 'Tag 2'}, {'name': 'tag-3', 'description': 'Tag 3'}, @@ -229,7 +229,7 @@ def test_specs_endpoint_tags_namespaces(self, api, client): assert data['tags'] == [{'name': 'ns'}, {'name': 'tag'}] def test_specs_endpoint_invalid_tags(self, app, client): - api = restplus.Api(app, tags=[ + api = restx.Api(app, tags=[ {'description': 'Tag 1'} ]) @@ -238,15 +238,15 @@ def test_specs_endpoint_invalid_tags(self, app, client): assert list(api.__schema__.keys()) == ['error'] def test_specs_endpoint_default_ns_with_resources(self, app, client): - restplus.Api(app) + restx.Api(app) data = client.get_specs('') assert data['tags'] == [] def test_specs_endpoint_default_ns_without_resources(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) @api.route('/test', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -256,12 +256,12 @@ def get(self): ] def test_specs_endpoint_default_ns_with_specified_ns(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('ns', 'Test namespace') @ns.route('/test2', endpoint='test2') @api.route('/test', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -272,11 +272,11 @@ def get(self): ] def test_specs_endpoint_specified_ns_without_default_ns(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('ns', 'Test namespace') @ns.route('/', endpoint='test2') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -286,11 +286,11 @@ def get(self): ] def test_specs_endpoint_namespace_without_description(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('ns') @ns.route('/test', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -298,23 +298,23 @@ def get(self): assert data['tags'] == [{'name': 'ns'}] def test_specs_endpoint_namespace_all_resources_hidden(self, app, client): - api = restplus.Api(app) + api = restx.Api(app) ns = api.namespace('ns') @ns.route('/test', endpoint='test', doc=False) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @ns.route('/test2', endpoint='test2') @ns.hide - class TestResource2(restplus.Resource): + class TestResource2(restx.Resource): def get(self): return {} @ns.route('/test3', endpoint='test3') @ns.doc(False) - class TestResource3(restplus.Resource): + class TestResource3(restx.Resource): def get(self): return {} @@ -329,7 +329,7 @@ def test_specs_authorizations(self, app, client): 'name': 'X-API' } } - restplus.Api(app, authorizations=authorizations) + restx.Api(app, authorizations=authorizations) data = client.get_specs() @@ -341,7 +341,7 @@ def test_minimal_documentation(self, api, client): ns = api.namespace('ns', 'Test namespace') @ns.route('/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -368,7 +368,7 @@ def get(self): @pytest.mark.api(prefix='/api', version='1.0') def test_default_ns_resource_documentation(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -396,7 +396,7 @@ def get(self): @pytest.mark.api(default='site', default_label='Site namespace') def test_default_ns_resource_documentation_with_override(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -426,7 +426,7 @@ def test_ns_resource_documentation(self, api, client): ns = api.namespace('ns', 'Test namespace') @ns.route('/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -453,11 +453,11 @@ def get(self): assert url_for('api.test') == '/api/ns/' def test_ns_resource_documentation_lazy(self, app, client): - api = restplus.Api() + api = restx.Api() ns = api.namespace('ns', 'Test namespace') @ns.route('/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): return {} @@ -486,7 +486,7 @@ def get(self): def test_methods_docstring_to_summary(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): ''' GET operation @@ -525,7 +525,7 @@ def delete(self): def test_path_parameter_no_type(self, api, client): @api.route('/id//', endpoint='by-id') - class ByIdResource(restplus.Resource): + class ByIdResource(restx.Resource): def get(self, id): return {} @@ -543,7 +543,7 @@ def get(self, id): def test_path_parameter_with_type(self, api, client): @api.route('/name//', endpoint='by-name') - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): def get(self, age): return {} @@ -561,7 +561,7 @@ def get(self, age): def test_path_parameter_with_type_with_argument(self, api, client): @api.route('/name//', endpoint='by-name') - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): def get(self, id): return {} @@ -583,7 +583,7 @@ def test_path_parameter_with_explicit_details(self, api, client): 'age': {'description': 'An age'} } }) - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): def get(self, age): return {} @@ -603,7 +603,7 @@ def get(self, age): def test_path_parameter_with_decorator_details(self, api, client): @api.route('/name//') @api.param('age', 'An age') - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): def get(self, age): return {} @@ -625,7 +625,7 @@ def test_expect_parser(self, api, client): parser.add_argument('param', type=int, help='Some param') @api.route('/with-parser/', endpoint='with-parser') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.expect(parser) def get(self): return {} @@ -648,7 +648,7 @@ def test_expect_parser_on_class(self, api, client): @api.route('/with-parser/', endpoint='with-parser') @api.expect(parser) - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): def get(self): return {} @@ -670,7 +670,7 @@ def test_method_parser_on_class(self, api, client): @api.route('/with-parser/', endpoint='with-parser') @api.doc(get={'expect': parser}) - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): def get(self): return {} @@ -697,7 +697,7 @@ def test_parser_parameters_override(self, api, client): parser.add_argument('param', type=int, help='Some param') @api.route('/with-parser/', endpoint='with-parser') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.expect(parser) @api.doc(params={'param': {'description': 'New description'}}) def get(self): @@ -720,7 +720,7 @@ def test_parser_parameter_in_form(self, api, client): parser.add_argument('param', type=int, help='Some param', location='form') @api.route('/with-parser/', endpoint='with-parser') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.expect(parser) def get(self): return {} @@ -744,7 +744,7 @@ def test_parser_parameter_in_files(self, api, client): parser.add_argument('in_files', type=FileStorage, location='files') @api.route('/with-parser/', endpoint='with-parser') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.expect(parser) def get(self): return {} @@ -768,7 +768,7 @@ def test_parser_parameter_in_files_on_class(self, api, client): @api.route('/with-parser/', endpoint='with-parser') @api.expect(parser) - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): def get(self): return {} @@ -791,7 +791,7 @@ def get(self): def test_explicit_parameters(self, api, client): @api.route('/name//', endpoint='by-name') - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.doc(params={ 'q': { 'type': 'string', @@ -825,7 +825,7 @@ def get(self, age): def test_explicit_parameters_with_decorator(self, api, client): @api.route('/name/') - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.param('q', 'A query string', type='string', _in='formData') def get(self, age): return {} @@ -852,7 +852,7 @@ def test_class_explicit_parameters(self, api, client): } } }) - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): def get(self, age): return {} @@ -889,7 +889,7 @@ def test_explicit_parameters_override(self, api, client): } } }) - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.doc(params={'q': {'description': 'A query string'}}) def get(self, age): return {} @@ -950,7 +950,7 @@ def test_explicit_parameters_override_by_method(self, api, client): } } }) - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.doc(params={'age': {'description': 'Overriden'}}) def get(self, age): return {} @@ -1011,7 +1011,7 @@ def test_parameters_cascading_with_apidoc_false(self, api, client): } } }) - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.doc(params={'age': {'description': 'Overriden'}}) def get(self, age): return {} @@ -1046,7 +1046,7 @@ def test_explicit_parameters_desription_shortcut(self, api, client): 'age': 'An age' } }) - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.doc(params={'age': 'Overriden'}) def get(self, age): return {} @@ -1094,7 +1094,7 @@ def post(self, age): def test_explicit_parameters_native_types(self, api, client): @api.route('/types/', endpoint='native') - class NativeTypesResource(restplus.Resource): + class NativeTypesResource(restx.Resource): @api.doc(params={ 'int': { 'type': int, @@ -1154,11 +1154,11 @@ def get(self, age): def test_response_on_method(self, api, client): api.model('ErrorModel', { - 'message': restplus.fields.String, + 'message': restx.fields.String, }) @api.route('/test/') - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.doc(responses={ 404: 'Not found', 405: ('Some message', 'ErrorModel'), @@ -1189,7 +1189,7 @@ def get(self): def test_api_response(self, api, client): @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.response(200, 'Success') def get(self): @@ -1207,7 +1207,7 @@ def get(self): def test_api_response_multiple(self, api, client): @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.response(200, 'Success') @api.response(400, 'Validation error') @@ -1229,11 +1229,11 @@ def get(self): def test_api_response_with_model(self, api, client): model = api.model('SomeModel', { - 'message': restplus.fields.String, + 'message': restx.fields.String, }) @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.response(200, 'Success', model) def get(self): @@ -1256,7 +1256,7 @@ def get(self): def test_api_response_default(self, api, client): @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.response('default', 'Error') def get(self): @@ -1275,7 +1275,7 @@ def get(self): def test_api_header(self, api, client): @api.route('/test/') @api.header('X-HEADER', 'A class header') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.header('X-HEADER-2', 'Another header', type=[int], collectionFormat='csv') @api.header('X-HEADER-3', type=int) @@ -1308,7 +1308,7 @@ def get(self): def test_response_header(self, api, client): @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.response(200, 'Success') @api.response(400, 'Validation', headers={'X-HEADER': 'An header'}) def get(self): @@ -1326,7 +1326,7 @@ def get(self): def test_api_and_response_header(self, api, client): @api.route('/test/') @api.header('X-HEADER', 'A class header') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.header('X-HEADER-2', type=int) @api.response(200, 'Success') @@ -1353,7 +1353,7 @@ def test_expect_header(self, api, client): parser.add_argument('X-Header-4', location='headers', type=inputs.boolean) @api.route('/test/') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.expect(parser) def get(self): @@ -1393,7 +1393,7 @@ def test_description(self, api, client): 'description': 'Parent description.', 'delete': {'description': 'A delete operation'}, }) - class ResourceWithDescription(restplus.Resource): + class ResourceWithDescription(restx.Resource): @api.doc(description='Some details') def get(self): return {} @@ -1413,7 +1413,7 @@ def delete(self): '''No description (only summary)''' @api.route('/descriptionless/', endpoint='descriptionless') - class ResourceWithoutDescription(restplus.Resource): + class ResourceWithoutDescription(restx.Resource): def get(self): '''No description (only summary)''' return {} @@ -1442,7 +1442,7 @@ def get(self): def test_operation_id(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.doc(id='get_objects') def get(self): return {} @@ -1458,7 +1458,7 @@ def post(self): def test_operation_id_shortcut(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.doc('get_objects') def get(self): return {} @@ -1472,10 +1472,10 @@ def test_custom_default_operation_id(self, app, client): def default_id(resource, method): return '{0}{1}'.format(method, resource) - api = restplus.Api(app, default_id=default_id) + api = restx.Api(app, default_id=default_id) @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.doc(id='get_objects') def get(self): return {} @@ -1492,7 +1492,7 @@ def post(self): @pytest.mark.api(default_id=lambda r, m: '{0}{1}'.format(m, r)) def test_custom_default_operation_id_blueprint(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.doc(id='get_objects') def get(self): return {} @@ -1508,7 +1508,7 @@ def post(self): def test_model_primitive_types(self, api, client): @api.route('/model-int/') - class ModelInt(restplus.Resource): + class ModelInt(restx.Resource): @api.doc(model=int) def get(self): return {} @@ -1527,13 +1527,13 @@ def get(self): def test_model_as_flat_dict(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=fields) def get(self): return {} @@ -1553,15 +1553,15 @@ def post(self): def test_model_as_nested_dict(self, api, client): address_fields = api.model('Address', { - 'road': restplus.fields.String, + 'road': restx.fields.String, }) fields = api.model('Person', { - 'address': restplus.fields.Nested(address_fields) + 'address': restx.fields.Nested(address_fields) }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=fields) def get(self): return {} @@ -1599,15 +1599,15 @@ def post(self): def test_model_as_nested_dict_with_details(self, api, client): address_fields = api.model('Address', { - 'road': restplus.fields.String, + 'road': restx.fields.String, }) fields = api.model('Person', { - 'address': restplus.fields.Nested(address_fields, description='description', readonly=True) + 'address': restx.fields.Nested(address_fields, description='description', readonly=True) }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=fields) def get(self): return {} @@ -1643,13 +1643,13 @@ def post(self): def test_model_as_flat_dict_with_marchal_decorator(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(fields) def get(self): return {} @@ -1676,7 +1676,7 @@ def test_model_with_non_uri_chars_in_name(self, api, client): }) @api.route('/model-bad-uri/') - class ModelBadUri(restplus.Resource): + class ModelBadUri(restx.Resource): @api.doc(model=fields) def get(self): return {} @@ -1698,13 +1698,13 @@ def post(self): def test_marchal_decorator_with_code(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(fields, code=204) def delete(self): return {} @@ -1726,13 +1726,13 @@ def delete(self): def test_marchal_decorator_with_description(self, api, client): person = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(person, description='Some details') def get(self): return {} @@ -1754,13 +1754,13 @@ def get(self): def test_marhsal_decorator_with_envelope(self, api, client): person = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(person, envelope='person') def get(self): return {} @@ -1786,13 +1786,13 @@ def get(self): def test_model_as_flat_dict_with_marchal_decorator_list(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(fields, as_list=True) def get(self): return {} @@ -1825,13 +1825,13 @@ def get(self): def test_model_as_flat_dict_with_marchal_decorator_list_alt(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_list_with(fields) def get(self): return {} @@ -1849,13 +1849,13 @@ def get(self): def test_model_as_flat_dict_with_marchal_decorator_list_kwargs(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_list_with(fields, code=201, description='Some details') def get(self): return {} @@ -1878,13 +1878,13 @@ def get(self): def test_model_as_dict_with_list(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'tags': restplus.fields.List(restplus.fields.String), + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'tags': restx.fields.List(restx.fields.String), }) @api.route('/model-with-list/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=fields) def get(self): return {} @@ -1916,18 +1916,18 @@ def get(self): def test_model_as_nested_dict_with_list(self, api, client): address = api.model('Address', { - 'road': restplus.fields.String, + 'road': restx.fields.String, }) person = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, - 'addresses': restplus.fields.List(restplus.fields.Nested(address)) + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, + 'addresses': restx.fields.List(restx.fields.Nested(address)) }) @api.route('/model-with-list/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=person) def get(self): return {} @@ -1940,7 +1940,7 @@ def get(self): def test_model_list_of_primitive_types(self, api, client): @api.route('/model-list/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=[int]) def get(self): return {} @@ -1965,13 +1965,13 @@ def post(self): def test_model_list_as_flat_dict(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=[fields]) def get(self): return {} @@ -1994,14 +1994,14 @@ def post(self): def test_model_doc_on_class(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') @api.doc(model=fields) - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): def get(self): return {} @@ -2018,14 +2018,14 @@ def post(self): def test_model_doc_for_method_on_class(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') @api.doc(get={'model': fields}) - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): def get(self): return {} @@ -2042,12 +2042,12 @@ def post(self): def test_model_with_discriminator(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String(discriminator=True), - 'age': restplus.fields.Integer, + 'name': restx.fields.String(discriminator=True), + 'age': restx.fields.Integer, }) @api.route('/model-with-discriminator/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(fields) def get(self): return {} @@ -2068,12 +2068,12 @@ def get(self): def test_model_with_discriminator_override_require(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String(discriminator=True, required=False), - 'age': restplus.fields.Integer, + 'name': restx.fields.String(discriminator=True, required=False), + 'age': restx.fields.Integer, }) @api.route('/model-with-discriminator/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(fields) def get(self): return {} @@ -2094,7 +2094,7 @@ def get(self): def test_model_not_found(self, api, client): @api.route('/model-not-found/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model='NotFound') def get(self): return {} @@ -2108,12 +2108,12 @@ def test_specs_no_duplicate_response_keys(self, api, client): ''' # Note the use of a strings '404' and '200' in class decorators as opposed to ints in method decorators. @api.response('404', 'Not Found') - class BaseResource(restplus.Resource): + class BaseResource(restx.Resource): def get(self): pass model = api.model('SomeModel', { - 'message': restplus.fields.String, + 'message': restx.fields.String, }) @api.route('/test/') @@ -2144,17 +2144,17 @@ def get(self): def test_clone(self, api, client): parent = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) child = api.clone('Child', parent, { - 'extra': restplus.fields.String, + 'extra': restx.fields.String, }) @api.route('/extend/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model=child) def get(self): return {} @@ -2175,16 +2175,16 @@ def post(self): def test_inherit(self, api, client): parent = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, + 'name': restx.fields.String, + 'age': restx.fields.Integer, }) child = api.inherit('Child', parent, { - 'extra': restplus.fields.String, + 'extra': restx.fields.String, }) @api.route('/inherit/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(child) def get(self): return { @@ -2233,21 +2233,21 @@ def post(self): def test_inherit_inline(self, api, client): parent = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, + 'name': restx.fields.String, + 'age': restx.fields.Integer, }) child = api.inherit('Child', parent, { - 'extra': restplus.fields.String, + 'extra': restx.fields.String, }) output = api.model('Output', { - 'child': restplus.fields.Nested(child), - 'children': restplus.fields.List(restplus.fields.Nested(child)) + 'child': restx.fields.Nested(child), + 'children': restx.fields.List(restx.fields.Nested(child)) }) @api.route('/inherit/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(output) def get(self): return { @@ -2299,16 +2299,16 @@ class Child2: pass parent = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, + 'name': restx.fields.String, + 'age': restx.fields.Integer, }) child1 = api.inherit('Child1', parent, { - 'extra1': restplus.fields.String, + 'extra1': restx.fields.String, }) child2 = api.inherit('Child2', parent, { - 'extra2': restplus.fields.String, + 'extra2': restx.fields.String, }) mapping = { @@ -2317,11 +2317,11 @@ class Child2: } output = api.model('Output', { - 'child': restplus.fields.Polymorph(mapping) + 'child': restx.fields.Polymorph(mapping) }) @api.route('/polymorph/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(output) def get(self): return {} @@ -2347,15 +2347,15 @@ class Child2(object): extra2 = 'extra2' parent = api.model('Person', { - 'name': restplus.fields.String, + 'name': restx.fields.String, }) child1 = api.inherit('Child1', parent, { - 'extra1': restplus.fields.String, + 'extra1': restx.fields.String, }) child2 = api.inherit('Child2', parent, { - 'extra2': restplus.fields.String, + 'extra2': restx.fields.String, }) mapping = { @@ -2364,11 +2364,11 @@ class Child2(object): } output = api.model('Output', { - 'children': restplus.fields.List(restplus.fields.Polymorph(mapping)) + 'children': restx.fields.List(restx.fields.Polymorph(mapping)) }) @api.route('/polymorph/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.marshal_with(output) def get(self): return { @@ -2399,13 +2399,13 @@ def get(self): def test_expect_model(self, api, client): person = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.expect(person) def post(self): return {} @@ -2446,13 +2446,13 @@ def post(self): def test_body_model_shortcut(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(model='Person') @api.expect(fields) def post(self): @@ -2496,13 +2496,13 @@ def post(self): def test_expect_model_list(self, api, client): model = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-list/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.expect([model]) def post(self): return {} @@ -2545,13 +2545,13 @@ def test_both_model_and_parser_from_expect(self, api, client): parser.add_argument('param', type=int, help='Some param') person = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/with-parser/', endpoint='with-parser') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.expect(parser, person) def get(self): return {} @@ -2601,8 +2601,8 @@ def get(self): def test_expect_primitive_list(self, api, client): @api.route('/model-list/') - class ModelAsDict(restplus.Resource): - @api.expect([restplus.fields.String]) + class ModelAsDict(restx.Resource): + @api.expect([restx.fields.String]) def post(self): return {} @@ -2622,13 +2622,13 @@ def post(self): def test_body_model_list(self, api, client): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-list/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.expect([fields]) def post(self): return {} @@ -2668,13 +2668,13 @@ def post(self): def test_expect_model_with_description(self, api, client): person = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.expect((person, 'Body description')) def post(self): return {} @@ -2715,7 +2715,7 @@ def post(self): } def test_authorizations(self, app, client): - restplus.Api(app, authorizations={ + restx.Api(app, authorizations={ 'apikey': { 'type': 'apiKey', 'in': 'header', @@ -2724,7 +2724,7 @@ def test_authorizations(self, app, client): }) # @api.route('/authorizations/') - # class ModelAsDict(restplus.Resource): + # class ModelAsDict(restx.Resource): # def get(self): # return {} @@ -2740,7 +2740,7 @@ def test_authorizations(self, app, client): # assert path['post']['security'] == {'apikey': []} def test_single_root_security_string(self, app, client): - api = restplus.Api(app, security='apikey', authorizations={ + api = restx.Api(app, security='apikey', authorizations={ 'apikey': { 'type': 'apiKey', 'in': 'header', @@ -2749,7 +2749,7 @@ def test_single_root_security_string(self, app, client): }) @api.route('/authorizations/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): def post(self): return {} @@ -2788,7 +2788,7 @@ def test_single_root_security_object(self, app, client): } } - api = restplus.Api(app, + api = restx.Api(app, security={ 'oauth2': 'read', 'implicit': ['read', 'write'] @@ -2797,7 +2797,7 @@ def test_single_root_security_object(self, app, client): ) @api.route('/authorizations/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): def post(self): return {} @@ -2828,10 +2828,10 @@ def test_root_security_as_list(self, app, client): } } } - api = restplus.Api(app, security=['apikey', {'oauth2': 'read'}], authorizations=security_definitions) + api = restx.Api(app, security=['apikey', {'oauth2': 'read'}], authorizations=security_definitions) @api.route('/authorizations/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): def post(self): return {} @@ -2843,7 +2843,7 @@ def post(self): assert 'security' not in op def test_method_security(self, app, client): - api = restplus.Api(app, authorizations={ + api = restx.Api(app, authorizations={ 'apikey': { 'type': 'apiKey', 'in': 'header', @@ -2852,7 +2852,7 @@ def test_method_security(self, app, client): }) @api.route('/authorizations/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(security=['apikey']) def get(self): return {} @@ -2892,10 +2892,10 @@ def test_security_override(self, app, client): } } } - api = restplus.Api(app, security=['apikey', {'oauth2': 'read'}], authorizations=security_definitions) + api = restx.Api(app, security=['apikey', {'oauth2': 'read'}], authorizations=security_definitions) @api.route('/authorizations/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(security=[{'oauth2': ['read', 'write']}]) def get(self): return {} @@ -2923,10 +2923,10 @@ def test_security_nullify(self, app, client): } } } - api = restplus.Api(app, security=['apikey', {'oauth2': 'read'}], authorizations=security_definitions) + api = restx.Api(app, security=['apikey', {'oauth2': 'read'}], authorizations=security_definitions) @api.route('/authorizations/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(security=[]) def get(self): return {} @@ -2944,7 +2944,7 @@ def post(self): def test_hidden_resource(self, api, client): @api.route('/test/', endpoint='test', doc=False) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): ''' GET operation @@ -2953,7 +2953,7 @@ def get(self): @api.hide @api.route('/test2/', endpoint='test2') - class TestResource2(restplus.Resource): + class TestResource2(restx.Resource): def get(self): ''' GET operation @@ -2962,7 +2962,7 @@ def get(self): @api.doc(False) @api.route('/test3/', endpoint='test3') - class TestResource3(restplus.Resource): + class TestResource3(restx.Resource): def get(self): ''' GET operation @@ -2980,7 +2980,7 @@ def test_hidden_resource_from_namespace(self, api, client): ns = api.namespace('ns') @ns.route('/test/', endpoint='test', doc=False) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): ''' GET operation @@ -2996,7 +2996,7 @@ def get(self): def test_hidden_methods(self, api, client): @api.route('/test/', endpoint='test') @api.doc(delete=False) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): ''' GET operation @@ -3032,7 +3032,7 @@ def delete(self): def test_produces_method(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3052,7 +3052,7 @@ def post(self): def test_deprecated_resource(self, api, client): @api.deprecated @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3067,7 +3067,7 @@ def post(self): def test_deprecated_method(self, api, client): @api.route('/test/', endpoint='test') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3086,7 +3086,7 @@ def post(self): def test_vendor_as_kwargs(self, api, client): @api.route('/vendor_fields', endpoint='vendor_fields') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.vendor(integration={'integration1': '1'}) def get(self): return {} @@ -3103,7 +3103,7 @@ def get(self): def test_vendor_as_dict(self, api, client): @api.route('/vendor_fields', endpoint='vendor_fields') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): @api.vendor({ 'x-some-integration': { 'integration1': '1' @@ -3132,7 +3132,7 @@ def get(self, age): def test_method_restrictions(self, api, client): @api.route('/foo/bar', endpoint='foo') @api.route('/bar', methods=['GET'], endpoint='bar') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3153,7 +3153,7 @@ def test_multiple_routes_inherit_doc(self, api, client): @api.route('/foo/bar') @api.route('/bar') @api.doc(description='an endpoint') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3168,7 +3168,7 @@ def get(self): def test_multiple_routes_individual_doc(self, api, client): @api.route('/foo/bar', doc={'description': 'the same endpoint'}) @api.route('/bar', doc={'description': 'an endpoint'}) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3184,7 +3184,7 @@ def test_multiple_routes_override_doc(self, api, client): @api.route('/foo/bar', doc={'description': 'the same endpoint'}) @api.route('/bar') @api.doc(description='an endpoint') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3199,7 +3199,7 @@ def get(self): def test_multiple_routes_no_doc_same_operationIds(self, api, client): @api.route('/foo/bar') @api.route('/bar') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3219,7 +3219,7 @@ def test_multiple_routes_with_doc_unique_operationIds(self, api, client): doc={"description": "I should be treated separately"}, ) @api.route("/bar") - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3235,7 +3235,7 @@ def test_mutltiple_routes_merge_doc(self, api, client): @api.route('/foo/bar', doc={'description': 'the same endpoint'}) @api.route('/bar', doc={'description': False}) @api.doc(security=[{'oauth2': ['read', 'write']}]) - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3252,7 +3252,7 @@ def get(self): def test_multiple_routes_deprecation(self, api, client): @api.route('/foo/bar', doc={'deprecated': True}) @api.route('/bar') - class TestResource(restplus.Resource): + class TestResource(restx.Resource): def get(self): pass @@ -3278,7 +3278,7 @@ def test_multiple_routes_explicit_parameters_override(self, path_name, api, clie "age": {"description": "An age"}, } ) - class ByNameResource(restplus.Resource): + class ByNameResource(restx.Resource): @api.doc( params={"q": {"description": "A query string"}} ) @@ -3332,7 +3332,7 @@ def test_doc_parser_parameters(self, api): with pytest.warns(DeprecationWarning): @api.route('/with-parser/') - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): @api.doc(parser=parser) def get(self): return {} @@ -3349,7 +3349,7 @@ def test_doc_method_parser_on_class(self, api): with pytest.warns(DeprecationWarning): @api.route('/with-parser/') @api.doc(get={'parser': parser}) - class WithParserResource(restplus.Resource): + class WithParserResource(restx.Resource): def get(self): return {} @@ -3363,14 +3363,14 @@ def post(self): def test_doc_body_as_tuple(self, api): fields = api.model('Person', { - 'name': restplus.fields.String, - 'age': restplus.fields.Integer, - 'birthdate': restplus.fields.DateTime, + 'name': restx.fields.String, + 'age': restx.fields.Integer, + 'birthdate': restx.fields.DateTime, }) with pytest.warns(DeprecationWarning): @api.route('/model-as-dict/') - class ModelAsDict(restplus.Resource): + class ModelAsDict(restx.Resource): @api.doc(body=(fields, 'Body description')) def post(self): return {} diff --git a/tests/test_swagger_utils.py b/tests/test_swagger_utils.py index 1f7802a3..bec6eeaa 100644 --- a/tests/test_swagger_utils.py +++ b/tests/test_swagger_utils.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from flask_restplus.swagger import extract_path, extract_path_params, parse_docstring +from flask_restx.swagger import extract_path, extract_path_params, parse_docstring class ExtractPathTest(object): diff --git a/tests/test_utils.py b/tests/test_utils.py index c648ba36..9c6d3e5e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,7 +3,7 @@ import pytest -from flask_restplus import utils +from flask_restx import utils class MergeTestCase(object):