{"id":13421651,"url":"https://github.com/jmcarp/flask-apispec","last_synced_at":"2025-05-14T08:06:58.717Z","repository":{"id":34926678,"uuid":"38987911","full_name":"jmcarp/flask-apispec","owner":"jmcarp","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-04T14:03:06.000Z","size":215,"stargazers_count":656,"open_issues_count":116,"forks_count":154,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-04T15:20:43.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmcarp.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-13T02:46:44.000Z","updated_at":"2025-05-04T14:03:10.000Z","dependencies_parsed_at":"2024-01-17T03:17:35.326Z","dependency_job_id":"6344a772-a7d8-452a-8cb6-0d0dd2f7b29c","html_url":"https://github.com/jmcarp/flask-apispec","commit_stats":{"total_commits":194,"total_committers":32,"mean_commits":6.0625,"dds":0.634020618556701,"last_synced_commit":"db85956115262d02dc10d41c304ff48ddd1057fb"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcarp%2Fflask-apispec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcarp%2Fflask-apispec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcarp%2Fflask-apispec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcarp%2Fflask-apispec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmcarp","download_url":"https://codeload.github.com/jmcarp/flask-apispec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101618,"owners_count":22014909,"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":[],"created_at":"2024-07-30T23:00:27.694Z","updated_at":"2025-05-14T08:06:53.707Z","avatar_url":"https://github.com/jmcarp.png","language":"Python","readme":"=============\nflask-apispec\n=============\n\n.. image:: https://img.shields.io/pypi/v/flask-apispec.svg\n    :target: http://badge.fury.io/py/flask-apispec\n    :alt: Latest version\n\n.. image:: https://readthedocs.org/projects/flask-apispec/badge/?version=latest\n    :target: https://flask-apispec.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation status\n\n.. image:: https://img.shields.io/travis/jmcarp/flask-apispec/master.svg\n    :target: https://travis-ci.org/jmcarp/flask-apispec\n    :alt: Travis-CI\n\n.. image:: https://img.shields.io/codecov/c/github/jmcarp/flask-apispec/master.svg\n    :target: https://codecov.io/github/jmcarp/flask-apispec\n    :alt: Code coverage\n\n**flask-apispec** is a lightweight tool for building REST APIs in Flask. **flask-apispec** uses webargs_ for request parsing, marshmallow_ for response formatting, and apispec_ to automatically generate Swagger markup. You can use **flask-apispec** with vanilla Flask or a fuller-featured framework like Flask-RESTful_.\n\nInstall\n-------\n\n::\n\n    pip install flask-apispec\n\nQuickstart\n----------\n\n.. code-block:: python\n\n    from flask import Flask\n    from flask_apispec import use_kwargs, marshal_with\n\n    from marshmallow import Schema\n    from webargs import fields\n\n    from .models import Pet\n\n    app = Flask(__name__)\n\n    class PetSchema(Schema):\n        class Meta:\n            fields = ('name', 'category', 'size')\n\n    @app.route('/pets')\n    @use_kwargs({'category': fields.Str(), 'size': fields.Str()})\n    @marshal_with(PetSchema(many=True))\n    def get_pets(**kwargs):\n        return Pet.query.filter_by(**kwargs)\n\n**flask-apispec** works with function- and class-based views:\n\n.. code-block:: python\n\n    from flask import make_response\n    from flask_apispec.views import MethodResource\n\n    class PetResource(MethodResource):\n\n        @marshal_with(PetSchema)\n        def get(self, pet_id):\n            return Pet.query.filter(Pet.id == pet_id).one()\n\n        @use_kwargs(PetSchema)\n        @marshal_with(PetSchema, code=201)\n        def post(self, **kwargs):\n            return Pet(**kwargs)\n\n        @use_kwargs(PetSchema)\n        @marshal_with(PetSchema)\n        def put(self, pet_id, **kwargs):\n            pet = Pet.query.filter(Pet.id == pet_id).one()\n            pet.__dict__.update(**kwargs)\n            return pet\n\n        @marshal_with(None, code=204)\n        def delete(self, pet_id):\n            pet = Pet.query.filter(Pet.id == pet_id).one()\n            pet.delete()\n            return make_response('', 204)\n\n**flask-apispec** generates Swagger markup for your view functions and classes. By default, Swagger JSON is served at `/swagger/`, and Swagger-UI at `/swagger-ui/`.\n\n.. code-block:: python\n\n    from apispec import APISpec\n    from apispec.ext.marshmallow import MarshmallowPlugin\n    from flask_apispec.extension import FlaskApiSpec\n\n    app.config.update({\n        'APISPEC_SPEC': APISpec(\n            title='pets',\n            version='v1',\n            plugins=[MarshmallowPlugin()],\n        ),\n        'APISPEC_SWAGGER_URL': '/swagger/',\n    })\n    docs = FlaskApiSpec(app)\n\n    docs.register(get_pets)\n    docs.register(PetResource)\n\nDocumentation\n-------------\n\nhttps://flask-apispec.readthedocs.io/\n\nNotes\n-----\n\n**flask-apispec** is strongly inspired by Flask-RESTful_ and Flask-RESTplus_, but attempts to provide similar functionality with greater flexibility and less code.\n\n.. _webargs: https://webargs.readthedocs.io/\n.. _marshmallow: https://marshmallow.readthedocs.io/\n.. _apispec: https://apispec.readthedocs.io/\n.. _Flask-RESTful: https://flask-restful.readthedocs.io/\n.. _Flask-RESTplus: https://flask-restplus.readthedocs.io/\n","funding_links":[],"categories":["介绍","Python","Flask Utilities","Development (Debugging/Testing/Documentation)"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcarp%2Fflask-apispec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmcarp%2Fflask-apispec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcarp%2Fflask-apispec/lists"}