Extractor

You can extract swagger spec from flask’s view function using flask_swag.extractor. And you can also customize it.

Extractor

This is base class & implementation of extractor.

extract_paths() method excutes extraction, and returns list of path items.

Fields

Basic implementation of extractor extracts following fields from view functions.

Filtering

You can filter endpoints by using endpoint & exclude_endpoint parameters, and also can filter blueprints by using blueprint & exclude_blueprint parameters.

Note

Since flask can have non-blueprint endpoints like

@app.route('/non-blueprint')
def non_blueprint():
    pass

Endpoints with None blueprint means non-blueprint endpoints. So, you can collect non-blueprint only endpoints by extractor.extract_paths(app, blueprint=None)

Customization

You can customize extractor by subclassing Extractor.

extract_others() will be best point to override.

flask_swag.extractor.mark.MarkExtractor is simple example for customization.

MarkExtractor

Mark extractor extracts extra swagger specs from view functions. This is the default extractor of flask_swag.Swag.

This will be useful when you want to write parameter info to view functions.