A library for generating swagger open api specifications for the Flask web framework
Project description
Flask Swagger Generator
Flask swagger generator is a library to create Swagger Open API definitions for Flask based applications. Swagger is an Interface Description Language for describing REST APIs expressed using JSON and YAML.
Installing
Install and update using pip:
pip install flask-swagger-generator
Documentation
COMING SOON
A Simple Example
from flask import Blueprint, jsonify
from flask import Flask
from flask_swagger_generator.generators import Generator
from flask_swagger_generator.specifiers import SwaggerVersion
from flask_swagger_generator.utils import SecurityType
swagger_destination_path = '/static/swagger.yaml'
# Create the bluepints
blueprint = Blueprint('objects', __name__)
# Create the flask app
app = Flask(__name__)
# Create swagger version 3.0 generator
generator = Generator.of(SwaggerVersion.VERSION_THREE)
# Add security, response and request body definitions
@generator.security(SecurityType.BEARER_AUTH)
@generator.response(status_code=200, schema={'id': 10, 'name': 'test_object'})
@generator.request_body({'id': 10, 'name': 'test_object'})
@blueprint.route('/objects/<int:object_id>', methods=['PUT'])
def update_object(object_id):
return jsonify({'id': 1, 'name': 'test_object_name'}), 201
app.register_blueprint(blueprint)
generator.generate_swagger(app, destination_path=swagger_destination_path)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask-swagger-generator-0.4.tar.gz
.
File metadata
- Download URL: flask-swagger-generator-0.4.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e53c8fc1d1db28fa20749ba3a49432ccf3f1dba442922d591fc78e54d9768c6 |
|
MD5 | 480efdf18fddb9bfd9aca46e9176f957 |
|
BLAKE2b-256 | fc20515cc1497b31fe7176b2dfbe7c4b5b98929416dbaf109fe338fc811d5c8d |
File details
Details for the file flask_swagger_generator-0.4-py3-none-any.whl
.
File metadata
- Download URL: flask_swagger_generator-0.4-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e0cdc392b42e923a847330bcd8769ac9cdc0d7aec3689d64beabd61dbe63533 |
|
MD5 | 8c581186f4899683dd582d3eba1b127d |
|
BLAKE2b-256 | 90fb490f1f42dec8e5d6bb155f44c5cfd2b6938c36e54dccbdc6cdafe1cb2c03 |