Пример #1
0
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
Пример #2
0
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)]
Пример #3
0
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),
    }
Пример #4
0
 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
Пример #5
0
 def __init__(self, spec_dict):
     self.spec = oas.create_spec_from_dict(spec_dict)
Пример #6
0
def test_get_security_schemes_without_user_loader(petstore_dict):
    spec = create_spec_from_dict(petstore_dict)

    assert _get_security_schemes(spec) == {}
Пример #7
0
def test_get_security_schemes_none():
    spec = create_spec_from_dict({})

    assert _get_security_schemes(spec) is None