def create_app(spec_dict): spec = create_spec_from_dict(spec_dict) app = falcon.API( middleware=[falcon_oas.Middleware(spec)], request_type=falcon_oas.Request, ) return app
def test_generate_routes(petstore_dict): path_item = petstore_dict['paths']['/v1/pets'] path_item[extensions.IMPLEMENTATION] = 'test_routing.Resource' spec = create_spec_from_dict(petstore_dict) routes = list(generate_routes(spec, base_module='tests')) assert routes == [('/api/v1/pets', Resource)]
def test_get_security_schemes(petstore_dict_with_implementation): spec_dict = petstore_dict_with_implementation security_schemes = spec_dict['components']['securitySchemes'] spec = create_spec_from_dict(spec_dict) result = _get_security_schemes(spec) assert result == { 'api_key': (security_schemes['api_key'], api_key_validator), 'session': (security_schemes['session'], session_cookie_loader), }
def __init__( self, spec_dict, formats=None, base_module='', api_factory=falcon.API, problems=True, ): self.spec = create_spec_from_dict(spec_dict) self.formats = formats self.base_module = base_module self.api_factory = api_factory self.problems = problems
def __init__(self, spec_dict): self.spec = oas.create_spec_from_dict(spec_dict)
def test_get_security_schemes_without_user_loader(petstore_dict): spec = create_spec_from_dict(petstore_dict) assert _get_security_schemes(spec) == {}
def test_get_security_schemes_none(): spec = create_spec_from_dict({}) assert _get_security_schemes(spec) is None