{"id":13705476,"url":"https://github.com/ashleysommer/sanic-restplus","last_synced_at":"2025-05-05T16:32:54.957Z","repository":{"id":44900482,"uuid":"84788602","full_name":"ashleysommer/sanic-restplus","owner":"ashleysommer","description":"Fully featured framework for fast, easy and documented API development with Sanic","archived":false,"fork":true,"pushed_at":"2022-10-07T03:29:25.000Z","size":1563,"stargazers_count":104,"open_issues_count":3,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-03-15T03:55:11.130Z","etag":null,"topics":["python","python-3","python3","python3-5","python3-6","rest","rest-api","sanic"],"latest_commit_sha":null,"homepage":"http://flask-restplus.readthedocs.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"noirbizarre/flask-restplus","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ashleysommer.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-13T05:47:24.000Z","updated_at":"2024-02-07T17:35:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ashleysommer/sanic-restplus","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleysommer%2Fsanic-restplus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleysommer%2Fsanic-restplus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleysommer%2Fsanic-restplus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleysommer%2Fsanic-restplus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashleysommer","download_url":"https://codeload.github.com/ashleysommer/sanic-restplus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224455878,"owners_count":17314200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","python-3","python3","python3-5","python3-6","rest","rest-api","sanic"],"created_at":"2024-08-02T22:00:42.164Z","updated_at":"2024-11-13T13:30:34.148Z","avatar_url":"https://github.com/ashleysommer.png","language":"Python","funding_links":[],"categories":["Extensions"],"sub_categories":["API"],"readme":"==============\nSanic RestPlus\n==============\n\nSanic-RESTPlus is an extension for `Sanic`_ that adds support for quickly building REST APIs.\nSanic-RESTPlus encourages best practices with minimal setup.\nIf you are familiar with Sanic, Sanic-RESTPlus should be easy to pick up.\nIt provides a coherent collection of decorators and tools to describe your API\nand expose its documentation properly using `Swagger`_.\n\n\nCompatibility\n=============\n\n* Sanic-RestPlus requires Python 3.7+.\n* Sanic-RestPlus works with Sanic v21.3+\n* Sanic-RestPlus IS NOT CURRENTLY COMPATIBLE with Sanic v21.12 or above (due to limitations in sanic-plugin-toolkit).\n\n\n\nBackward Compatibility Notice\n------------------------------\n\nSanic-RestPlus version 0.6.0 was reworked and now requires Sanic v21.3 or later.\n\nSanic-RestPlus version 0.4.1 (and previous versions) **does not work** on Sanic 19.12+, see this bug here: https://github.com/ashleysommer/sanicpluginsframework/issues/15\n\nPlease use Sanic-Restplus v0.5.x if you need to deploy on Sanic v19.12 or v20.12\n\nIf you are using the Sanic v20.12LTS, please use Sanic-RestPlus v0.5.6.\n\n\nInstallation\n============\n\nIn the near future, you will be able to install Sanic-Restplus with pip:\n\n.. code-block:: console\n\n    $ pip install sanic-restplus\n\nor with easy_install:\n\n.. code-block:: console\n\n    $ easy_install sanic-restplus\n\n\nQuick start\n===========\n\nWith Sanic-Restplus, you only import the api instance to route and document your endpoints.\n\n.. code-block:: python\n\n    from sanic import Sanic\n    from sanic_restplus import Api, Resource, fields\n    from sanic_restplus.restplus import restplus\n    from sanic_plugin_toolkit import SanicPluginRealm\n    app = Sanic(__name__)\n    realm = SanicPluginRealm(app)\n    rest_assoc = realm.register_plugin(restplus)\n\n    api = Api(version='1.0', title='TodoMVC API',\n              description='A simple TodoMVC API')\n\n    ns = api.namespace('todos', description='TODO operations')\n\n    todo = api.model('Todo', {\n        'id': fields.Integer(readOnly=True, description='The task unique identifier'),\n        'task': fields.String(required=True, description='The task details')\n    })\n\n\n    class TodoDAO(object):\n        def __init__(self):\n            self.counter = 0\n            self.todos = []\n\n        def get(self, id):\n            for todo in self.todos:\n                if todo['id'] == id:\n                    return todo\n            api.abort(404, \"Todo {} doesn't exist\".format(id))\n\n        def create(self, data):\n            todo = data\n            todo['id'] = self.counter = self.counter + 1\n            self.todos.append(todo)\n            return todo\n\n        def update(self, id, data):\n            todo = self.get(id)\n            todo.update(data)\n            return todo\n\n        def delete(self, id):\n            todo = self.get(id)\n            self.todos.remove(todo)\n\n\n    DAO = TodoDAO()\n    DAO.create({'task': 'Build an API'})\n    DAO.create({'task': '?????'})\n    DAO.create({'task': 'profit!'})\n\n\n    @ns.route('/')\n    class TodoList(Resource):\n        '''Shows a list of all todos, and lets you POST to add new tasks'''\n\n        @ns.doc('list_todos')\n        @ns.marshal_list_with(todo)\n        async def get(self, request):\n            '''List all tasks'''\n            return DAO.todos\n\n        @ns.doc('create_todo')\n        @ns.expect(todo)\n        @ns.marshal_with(todo, code=201)\n        async def post(self, request):\n            '''Create a new task'''\n            return DAO.create(request.json), 201\n\n\n    @ns.route('/\u003cid:int\u003e')\n    @ns.response(404, 'Todo not found')\n    @ns.param('id', 'The task identifier')\n    class Todo(Resource):\n        '''Show a single todo item and lets you delete them'''\n\n        @ns.doc('get_todo')\n        @ns.marshal_with(todo)\n        async def get(self, request, id):\n            '''Fetch a given resource'''\n            return DAO.get(id)\n\n        @ns.doc('delete_todo')\n        @ns.response(204, 'Todo deleted')\n        async def delete(self, request, id):\n            '''Delete a task given its identifier'''\n            DAO.delete(id)\n            return '', 204\n\n        @ns.expect(todo)\n        @ns.marshal_with(todo)\n        async def put(self, request, id):\n            '''Update a task given its identifier'''\n            return DAO.update(id, request.json)\n\n    rest_assoc.api(api)\n\n    if __name__ == '__main__':\n        app.run(debug=True, auto_reload=False)\n\n\n\n\nDocumentation\n=============\n\nThe documentation is hosted `on Read the Docs \u003chttp://flask-restplus.readthedocs.io/en/latest/\u003e`_\nThat is the Flask RestPlus documentation, the Sanic-Restplus docs are not converted yet.\n\n.. _Sanic: https://github.com/channelcat/sanic\n.. _Swagger: http://swagger.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashleysommer%2Fsanic-restplus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashleysommer%2Fsanic-restplus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashleysommer%2Fsanic-restplus/lists"}