METADATA 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. Metadata-Version: 2.1
  2. Name: flask-restx
  3. Version: 0.5.1
  4. Summary: Fully featured framework for fast, easy and documented API development with Flask
  5. Home-page: https://github.com/python-restx/flask-restx
  6. Author: python-restx Authors
  7. License: BSD-3-Clause
  8. Keywords: flask restx rest api swagger openapi
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 3 - Alpha
  11. Classifier: Programming Language :: Python
  12. Classifier: Environment :: Web Environment
  13. Classifier: Operating System :: OS Independent
  14. Classifier: Intended Audience :: Developers
  15. Classifier: Topic :: System :: Software Distribution
  16. Classifier: Programming Language :: Python
  17. Classifier: Programming Language :: Python :: 2
  18. Classifier: Programming Language :: Python :: 2.7
  19. Classifier: Programming Language :: Python :: 3
  20. Classifier: Programming Language :: Python :: 3.5
  21. Classifier: Programming Language :: Python :: 3.6
  22. Classifier: Programming Language :: Python :: 3.7
  23. Classifier: Programming Language :: Python :: 3.8
  24. Classifier: Programming Language :: Python :: Implementation :: PyPy
  25. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  26. Classifier: License :: OSI Approved :: BSD License
  27. Requires-Dist: jsonschema
  28. Requires-Dist: Flask (!=2.0.0,>=0.8)
  29. Requires-Dist: werkzeug (!=2.0.0)
  30. Requires-Dist: pytz
  31. Requires-Dist: six (>=1.3.0)
  32. Requires-Dist: enum34 ; python_version < "3.4"
  33. Requires-Dist: aniso8601 (==8.0.0) ; python_version < "3.5"
  34. Requires-Dist: aniso8601 (>=0.82) ; python_version >= "3.5"
  35. Provides-Extra: dev
  36. Requires-Dist: blinker ; extra == 'dev'
  37. Requires-Dist: Faker (==2.0.0) ; extra == 'dev'
  38. Requires-Dist: mock (==3.0.5) ; extra == 'dev'
  39. Requires-Dist: pytest-benchmark (==3.2.2) ; extra == 'dev'
  40. Requires-Dist: pytest-cov (==2.7.1) ; extra == 'dev'
  41. Requires-Dist: pytest-flask (==0.15.1) ; extra == 'dev'
  42. Requires-Dist: pytest-mock (==1.10.4) ; extra == 'dev'
  43. Requires-Dist: pytest-profiling (==1.7.0) ; extra == 'dev'
  44. Requires-Dist: tzlocal ; extra == 'dev'
  45. Requires-Dist: invoke (==1.3.0) ; extra == 'dev'
  46. Requires-Dist: readme-renderer (==24.0) ; extra == 'dev'
  47. Requires-Dist: twine (==1.15.0) ; extra == 'dev'
  48. Requires-Dist: tox ; extra == 'dev'
  49. Requires-Dist: pytest (==4.6.5) ; (python_version < "3.5") and extra == 'dev'
  50. Requires-Dist: pytest (==5.4.1) ; (python_version >= "3.5") and extra == 'dev'
  51. Requires-Dist: ossaudit ; (python_version >= "3.5") and extra == 'dev'
  52. Requires-Dist: black ; (python_version >= "3.6") and extra == 'dev'
  53. Provides-Extra: doc
  54. Requires-Dist: alabaster (==0.7.12) ; extra == 'doc'
  55. Requires-Dist: Sphinx (==2.1.2) ; extra == 'doc'
  56. Requires-Dist: sphinx-issues (==1.2.0) ; extra == 'doc'
  57. Provides-Extra: test
  58. Requires-Dist: blinker ; extra == 'test'
  59. Requires-Dist: Faker (==2.0.0) ; extra == 'test'
  60. Requires-Dist: mock (==3.0.5) ; extra == 'test'
  61. Requires-Dist: pytest-benchmark (==3.2.2) ; extra == 'test'
  62. Requires-Dist: pytest-cov (==2.7.1) ; extra == 'test'
  63. Requires-Dist: pytest-flask (==0.15.1) ; extra == 'test'
  64. Requires-Dist: pytest-mock (==1.10.4) ; extra == 'test'
  65. Requires-Dist: pytest-profiling (==1.7.0) ; extra == 'test'
  66. Requires-Dist: tzlocal ; extra == 'test'
  67. Requires-Dist: invoke (==1.3.0) ; extra == 'test'
  68. Requires-Dist: readme-renderer (==24.0) ; extra == 'test'
  69. Requires-Dist: twine (==1.15.0) ; extra == 'test'
  70. Requires-Dist: pytest (==4.6.5) ; (python_version < "3.5") and extra == 'test'
  71. Requires-Dist: pytest (==5.4.1) ; (python_version >= "3.5") and extra == 'test'
  72. Requires-Dist: ossaudit ; (python_version >= "3.5") and extra == 'test'
  73. ===========
  74. Flask RESTX
  75. ===========
  76. .. image:: https://github.com/python-restx/flask-restx/workflows/Tests/badge.svg?tag=0.5.1&event=push
  77. :target: https://github.com/python-restx/flask-restx/actions?query=workflow%3ATests
  78. :alt: Tests status
  79. .. image:: https://codecov.io/gh/python-restx/flask-restx/branch/master/graph/badge.svg
  80. :target: https://codecov.io/gh/python-restx/flask-restx
  81. :alt: Code coverage
  82. .. image:: https://readthedocs.org/projects/flask-restx/badge/?version=0.5.1
  83. :target: https://flask-restx.readthedocs.io/en/0.5.1/
  84. :alt: Documentation status
  85. .. image:: https://img.shields.io/pypi/l/flask-restx.svg
  86. :target: https://pypi.org/project/flask-restx
  87. :alt: License
  88. .. image:: https://img.shields.io/pypi/pyversions/flask-restx.svg
  89. :target: https://pypi.org/project/flask-restx
  90. :alt: Supported Python versions
  91. .. image:: https://badges.gitter.im/Join%20Chat.svg
  92. :target: https://gitter.im/python-restx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
  93. :alt: Join the chat at https://gitter.im/python-restx
  94. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  95. :target: https://github.com/psf/black
  96. :alt: Code style: black
  97. Flask-RESTX is a community driven fork of `Flask-RESTPlus <https://github.com/noirbizarre/flask-restplus>`_.
  98. Flask-RESTX is an extension for `Flask`_ that adds support for quickly building REST APIs.
  99. Flask-RESTX encourages best practices with minimal setup.
  100. If you are familiar with Flask, Flask-RESTX should be easy to pick up.
  101. It provides a coherent collection of decorators and tools to describe your API
  102. and expose its documentation properly using `Swagger`_.
  103. Compatibility
  104. =============
  105. Flask-RESTX requires Python 2.7 or 3.4+.
  106. On Flask Compatibility
  107. ======================
  108. Flask and Werkzeug moved to versions 2.0 in March 2020. This caused a breaking change in Flask-RESTX.
  109. .. list-table:: RESTX and Flask / Werkzeug Compatibility
  110. :widths: 25 25 25
  111. :header-rows: 1
  112. * - Flask-RESTX version
  113. - Flask version
  114. - Note
  115. * - <= 0.3.0
  116. - < 2.0.0
  117. - unpinned in Flask-RESTX. Pin your projects!
  118. * - == 0.4.0
  119. - < 2.0.0
  120. - pinned in Flask-RESTX.
  121. * - >= 0.5.0
  122. - All (For Now)
  123. - unpinned, import statements wrapped for compatibility
  124. * - trunk branch in Github
  125. - All (and updated more often)
  126. - unpinned, will address issues faster than releases.
  127. Installation
  128. ============
  129. You can install Flask-RESTX with pip:
  130. .. code-block:: console
  131. $ pip install flask-restx
  132. or with easy_install:
  133. .. code-block:: console
  134. $ easy_install flask-restx
  135. Quick start
  136. ===========
  137. With Flask-RESTX, you only import the api instance to route and document your endpoints.
  138. .. code-block:: python
  139. from flask import Flask
  140. from flask_restx import Api, Resource, fields
  141. app = Flask(__name__)
  142. api = Api(app, version='1.0', title='TodoMVC API',
  143. description='A simple TodoMVC API',
  144. )
  145. ns = api.namespace('todos', description='TODO operations')
  146. todo = api.model('Todo', {
  147. 'id': fields.Integer(readonly=True, description='The task unique identifier'),
  148. 'task': fields.String(required=True, description='The task details')
  149. })
  150. class TodoDAO(object):
  151. def __init__(self):
  152. self.counter = 0
  153. self.todos = []
  154. def get(self, id):
  155. for todo in self.todos:
  156. if todo['id'] == id:
  157. return todo
  158. api.abort(404, "Todo {} doesn't exist".format(id))
  159. def create(self, data):
  160. todo = data
  161. todo['id'] = self.counter = self.counter + 1
  162. self.todos.append(todo)
  163. return todo
  164. def update(self, id, data):
  165. todo = self.get(id)
  166. todo.update(data)
  167. return todo
  168. def delete(self, id):
  169. todo = self.get(id)
  170. self.todos.remove(todo)
  171. DAO = TodoDAO()
  172. DAO.create({'task': 'Build an API'})
  173. DAO.create({'task': '?????'})
  174. DAO.create({'task': 'profit!'})
  175. @ns.route('/')
  176. class TodoList(Resource):
  177. '''Shows a list of all todos, and lets you POST to add new tasks'''
  178. @ns.doc('list_todos')
  179. @ns.marshal_list_with(todo)
  180. def get(self):
  181. '''List all tasks'''
  182. return DAO.todos
  183. @ns.doc('create_todo')
  184. @ns.expect(todo)
  185. @ns.marshal_with(todo, code=201)
  186. def post(self):
  187. '''Create a new task'''
  188. return DAO.create(api.payload), 201
  189. @ns.route('/<int:id>')
  190. @ns.response(404, 'Todo not found')
  191. @ns.param('id', 'The task identifier')
  192. class Todo(Resource):
  193. '''Show a single todo item and lets you delete them'''
  194. @ns.doc('get_todo')
  195. @ns.marshal_with(todo)
  196. def get(self, id):
  197. '''Fetch a given resource'''
  198. return DAO.get(id)
  199. @ns.doc('delete_todo')
  200. @ns.response(204, 'Todo deleted')
  201. def delete(self, id):
  202. '''Delete a task given its identifier'''
  203. DAO.delete(id)
  204. return '', 204
  205. @ns.expect(todo)
  206. @ns.marshal_with(todo)
  207. def put(self, id):
  208. '''Update a task given its identifier'''
  209. return DAO.update(id, api.payload)
  210. if __name__ == '__main__':
  211. app.run(debug=True)
  212. Contributors
  213. ============
  214. Flask-RESTX is brought to you by @python-restx. Since early 2019 @SteadBytes,
  215. @a-luna, @j5awry, @ziirish volunteered to help @python-restx keep the project up
  216. and running.
  217. Of course everyone is welcome to contribute and we will be happy to review your
  218. PR's or answer to your issues.
  219. Documentation
  220. =============
  221. The documentation is hosted `on Read the Docs <http://flask-restx.readthedocs.io/en/latest/>`_
  222. .. _Flask: https://flask.palletsprojects.com/
  223. .. _Swagger: https://swagger.io/
  224. Contribution
  225. ============
  226. Want to contribute! That's awesome! Check out `CONTRIBUTING.rst! <https://github.com/python-restx/flask-restx/blob/master/CONTRIBUTING.rst>`_