def __init__(self): from graphx.configurations.app.settings import Props from graphx.configurations.app.main import app from graphx.configurations.app.main import container # todo: should be moved to env vars self.spec = APISpec(title='graphx', version='1.0.0', openapi_version='2.0', plugins=[ FalconPlugin(app), MarshmallowPlugin(), ]) injector = container.get(Props.DI_PROVIDER).get_injector() self.spec.components.schema('Node', schema=injector.get(Node)) self.spec.path(resource=injector.get(NodeCollection)) self.spec.components.schema('Edge', schema=injector.get(Edge)) self.spec.path(resource=injector.get(EdgeCollection))
def setup_swagger(app): app.config.update({ 'APISPEC_SPEC': APISpec(title='Flask Template', version='v1', plugins=['apispec.ext.marshmallow'], securityDefinitions={ "json-web-token": { "in": "header", "name": "Authorization", "type": "apiKey" } }, tags=[]), 'APISPEC_SWAGGER_URL': '/swagger.json' }) docs = FlaskApiSpec(app) docs.register_existing_resources()
def test_plugin_schema_helper_is_used(self, openapi_version, return_none): spec = APISpec( title='Swagger Petstore', version='1.0.0', openapi_version=openapi_version, plugins=(self.test_plugin_factory(return_none), ), ) spec.components.schema('Pet', {}) definitions = get_definitions(spec) if return_none: assert definitions['Pet'] == {} else: assert definitions['Pet'] == { 'properties': { 'name': { 'type': 'string' } } }
def test_plugin_path_helper_is_used(self, openapi_version, return_none): spec = APISpec( title='Swagger Petstore', version='1.0.0', openapi_version=openapi_version, plugins=(self.test_plugin_factory(return_none), ), ) spec.path('/path_1') paths = get_paths(spec) assert len(paths) == 1 if return_none: assert paths['/path_1'] == {} else: assert paths['/path_1_modified'] == { 'get': { 'responses': { '200': {} } } }