Skip to content

Instantly share code, notes, and snippets.

@jasonrhaas
Created January 30, 2019 19:27
Show Gist options
  • Save jasonrhaas/fb1a3b6303fb2953b61af84fd76710d8 to your computer and use it in GitHub Desktop.
Save jasonrhaas/fb1a3b6303fb2953b61af84fd76710d8 to your computer and use it in GitHub Desktop.
Swagger blueprint
from flask import Blueprint, jsonify
from connexion import Api
class Swagger:
def blueprint(spec, **yaml_kwargs):
api = Api(spec, swagger_ui=True, strict_validation=True, validate_responses=False, arguments=yaml_kwargs)
bp = api.blueprint
@bp.errorhandler(404)
def endpoint_not_found(e):
return jsonify({'not': 'found'}), 404
return bp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment