Exemplo n.º 1
0
def test_dump():
    base_dir = _get_base_dir()
    parts = ["base.yml", "definitions.yml", "paths.yml", "security.yml"]
    full = yaml.load(open(path.join(base_dir, "full.yml")).read())

    spec = SpecBuilder()
    for p in parts:
        spec.add_spec(path.join(base_dir, p))

    # Dumping and reloading the yaml is slow, but we can't compare dumped
    # strings because of potential key ordering differences.
    assert full == yaml.load(spec.dump())
Exemplo n.º 2
0
def pytest_generate_tests(metafunc):
    if 'path' in metafunc.fixturenames:
        from swagger_parser import SwaggerParser
        from specsynthase.specbuilder import SpecBuilder
        import glob
        from os import path

        spec = SpecBuilder()
        for spec_file in glob.glob(path.join(path.dirname(__file__), '../swagger/*')):
            spec.add_spec(spec_file)

        requests = []
        for path_name, path_spec in spec['paths'].iteritems():
            url = _url_from_swagger_spec(path_name, path_spec)
            service = _identify_service_from_tag(path_spec['get']['tags'])
            requests.append((service, url))
        metafunc.parametrize("service,path", requests)
Exemplo n.º 3
0
from services.cache import cache
cache.init_app(app.app)

import services.limiter
limiter = services.limiter.init(app.app)

import config
from specsynthase.specbuilder import SpecBuilder
import glob
from os import path

spec = SpecBuilder()
if not 'EXPOSED_APIS' in dir(config) or len(config.EXPOSED_APIS) == 0:
    for spec_file in glob.glob(path.join(path.dirname(__file__), 'swagger/*')):
        spec.add_spec(spec_file)
else:
    spec.add_spec(path.join(path.dirname(__file__), 'swagger/api.yaml'))
    for api in config.EXPOSED_APIS:
        spec.add_spec(
            path.join(path.dirname(__file__),
                      'swagger/paths_{}.yaml'.format(api)))
app.add_api(spec)

import services.profiler
services.profiler.init_app(app.app)

application = app.app

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=5000)
Exemplo n.º 4
0
import connexion

options = {'swagger_url': '/apidocs'}
# strict_validation=True: requests that include parameters not defined return a 400 error
app = connexion.App('bitshares-explorer-api',
                    specification_dir='swagger/',
                    options=options)

from flask_cors import CORS
CORS(app.app)

from services.cache import cache
cache.init_app(app.app)

from specsynthase.specbuilder import SpecBuilder
import glob
from os import path

spec = SpecBuilder()
for spec_file in glob.glob(path.join(path.dirname(__file__), 'swagger/*')):
    spec.add_spec(spec_file)
app.add_api(spec)

import services.profiler
services.profiler.init_app(app.app)

application = app.app

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=5000)