Skip to content

Instantly share code, notes, and snippets.

@tarekziade
Last active August 1, 2018 16:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarekziade/595f003c0a9b9aa0934f21b814717441 to your computer and use it in GitHub Desktop.
Save tarekziade/595f003c0a9b9aa0934f21b814717441 to your computer and use it in GitHub Desktop.
connexion as an extension
import pathlib
from connexion.api import Api, Resolver
import werkzeug.exceptions
def swagger_blueprint(specification, specification_dir=None, validate_responses=False,
strict_validation=False, resolver_error=None,
base_path='', debug=False):
resolver = Resolver()
swagger_json = False
swagger_ui = False
swagger_path = None
swagger_url = None
auth_all_paths = False
arguments = dict()
specification_dir = pathlib.Path(specification_dir)
specification = specification_dir / specification
resolver_error_handler = None
validator_map = None
api = Api(specification=specification,
base_url=base_path, arguments=arguments,
swagger_json=swagger_json,
swagger_ui=swagger_ui,
swagger_path=swagger_path,
swagger_url=swagger_url,
resolver=resolver,
resolver_error_handler=resolver_error_handler,
validate_responses=validate_responses,
strict_validation=strict_validation,
auth_all_paths=auth_all_paths,
debug=debug,
validator_map=validator_map)
return api.blueprint
@jasonrhaas
Copy link

Note that the way to do this as of the version 1.1.15 is from connexion import Api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment