Beispiel #1
0
    def get(self, path, session=None):
        path = "/schema/%s" % path

        if path == "/schema/plugins":
            global _plugins_cache
            if not _plugins_cache:
                _plugins_cache = resolve_ref(path)
                self._rewrite_refs(_plugins_cache)
            return _plugins_cache

        if path in schema_paths:
            schema = resolve_ref(path)
            self._rewrite_refs(schema)
            return schema
        return {"error": "invalid schema path"}, 404
Beispiel #2
0
    def get(self, session=None):
        """ List all schema definitions """
        schemas = {}
        for path in schema_paths:
            schemas[path] = resolve_ref(path)

        return jsonify({'schemas': schemas})
Beispiel #3
0
    def get(self, session=None):
        """ List all schema definitions """
        schemas = {}
        for path in schema_paths:
            schemas[path] = resolve_ref(path)

        return jsonify({'schemas': schemas})
Beispiel #4
0
def get_schema(path):
    refpath = '/schema/' + path
    if request.query_string:
        refpath += '?' + request.query_string
    try:
        return jsonify(resolve_ref(refpath))
    except RefResolutionError:
        return 'Schema not found', 404
Beispiel #5
0
 def get(self, session: Session = None) -> Response:
     """List all schema definitions"""
     schemas = []
     for path in schema_paths:
         schema = rewrite_refs(resolve_ref(path), request.url_root)
         schema['id'] = rewrite_ref(path, request.url_root)
         schemas.append(schema)
     return jsonify({'schemas': schemas})
Beispiel #6
0
 def get(self, path: str, session: Session = None) -> Response:
     """Get schema definition"""
     try:
         schema = resolve_ref(request.full_path)
     except RefResolutionError:
         raise NotFoundError('invalid schema path')
     schema['id'] = request.url
     return jsonify(rewrite_refs(schema, request.url_root))
Beispiel #7
0
 def get(self, path, session=None):
     """ Get schema definition """
     path = '/schema/%s' % path
     if request.query_string:
         path += '?' + request.query_string
     try:
         return resolve_ref(path)
     except RefResolutionError:
         return {'error': 'invalid schema path'}, 404
Beispiel #8
0
 def get(self, path, session=None):
     """ Get schema definition """
     path = '/schema/%s' % path
     if request.query_string:
         path += '?' + request.query_string
     try:
         return resolve_ref(path)
     except RefResolutionError:
         return {'error': 'invalid schema path'}, 404
Beispiel #9
0
    def get(self, path, session=None):
        """ Get schema definition """
        path = '/schema/%s' % path

        if path in schema_paths:
            schema = resolve_ref(path)
            if hasattr(schema, '__call__'):
                schema = schema()
            return schema
        return {'error': 'invalid schema path'}, 404
Beispiel #10
0
    def get(self, path, session=None):
        """ Get schema definition """
        path = '/schema/%s' % path

        if path in schema_paths:
            schema = resolve_ref(path)
            if hasattr(schema, '__call__'):
                schema = schema()
            return schema
        return {'error': 'invalid schema path'}, 404
Beispiel #11
0
def config_root_key(root_key):
    if request.method == 'PUT':
        schema = resolve_ref('/schema/config/%s' % root_key)
        errors = process_config(request.json, schema, set_defaults=False)
        if errors:
            return jsonify({'$errors': errors}), 400
        manager.config[root_key] = request.json
    if root_key not in manager.config:
        return 'Not found', 404
    response = jsonify(manager.config[root_key])
    response.headers[b'Content-Type'] += '; profile=/schema/config/%s' % root_key
    return response
Beispiel #12
0
def config_root_key(root_key):
    if request.method == 'PUT':
        schema = resolve_ref('/schema/config/%s' % root_key)
        errors = process_config(request.json, schema, set_defaults=False)
        if errors:
            return jsonify({'$errors': errors}), 400
        manager.config[root_key] = request.json
    if root_key not in manager.config:
        return 'Not found', 404
    response = jsonify(manager.config[root_key])
    response.headers[
        b'Content-Type'] += '; profile=/schema/config/%s' % root_key
    return response
Beispiel #13
0
    def _rewrite_refs(self, schema):
        """ Used to resolve all the refs as swagger ui does not handle this properly """
        if isinstance(schema, list):
            for value in schema:
                self._rewrite_refs(value)

        if isinstance(schema, dict):
            for key, value in schema.iteritems():
                if isinstance(value, (list, dict)):
                    self._rewrite_refs(value)

            if key == "$ref" and value in schema_paths:
                del schema[key]
                schema.update(resolve_ref(value))
Beispiel #14
0
def config_section(section):
    if request.method == "PUT":
        schema = resolve_ref("/schema/config/%s" % section)
        errors = process_config(request.json, schema, set_defaults=False)
        if errors:
            return jsonify({"$errors": errors}), 400
        manager.config[section] = request.json
    if section not in manager.config:
        return jsonify(error="Not found"), 404
    if request.method == "DELETE":
        del manager.config[section]
        return Response(status=204)
    response = jsonify(manager.config[section])
    response.headers[b"Content-Type"] += "; profile=/schema/config/%s" % section
    return response
Beispiel #15
0
def config_section(section):
    if request.method == 'PUT':
        schema = resolve_ref('/schema/config/%s' % section)
        errors = process_config(request.json, schema, set_defaults=False)
        if errors:
            return jsonify({'$errors': errors}), 400
        manager.config[section] = request.json
    if section not in manager.config:
        return jsonify(error='Not found'), 404
    if request.method == 'DELETE':
        del manager.config[section]
        return Response(status=204)
    response = jsonify(manager.config[section])
    response.headers[b'Content-Type'] += '; profile=/schema/config/%s' % section
    return response
Beispiel #16
0
def config_section(section):
    if request.method == 'PUT':
        schema = resolve_ref('/schema/config/%s' % section)
        errors = process_config(request.json, schema, set_defaults=False)
        if errors:
            return jsonify({'$errors': errors}), 400
        manager.config[section] = request.json
    if section not in manager.config:
        return jsonify(error='Not found'), 404
    if request.method == 'DELETE':
        del manager.config[section]
        return Response(status=204)
    response = jsonify(manager.config[section])
    response.headers[
        b'Content-Type'] += '; profile=/schema/config/%s' % section
    return response
Beispiel #17
0
 def get(self, path, session=None):
     path = '/schema/%s' % path
     if path in schema_paths:
         return resolve_ref(path)
     return {'error': 'invalid schema path'}, 404
Beispiel #18
0
    def get(self, session=None):
        schemas = {}
        for path in schema_paths:
            schemas[path] = resolve_ref(path)

        return jsonify({'schemas': schemas})
def iter_registered_schemas():
    for path in config_schema.schema_paths:
        schema = config_schema.resolve_ref(path)
        yield path, schema
Beispiel #20
0
def iter_registered_schemas():
    for path in config_schema.schema_paths:
        schema = config_schema.resolve_ref(path)
        yield path, schema
Beispiel #21
0
    def get(self, session=None):
        schemas = {}
        for path in schema_paths:
            schemas[path] = resolve_ref(path)

        return jsonify({'schemas': schemas})
Beispiel #22
0
 def get(self, path, session=None):
     path = '/schema/%s' % path
     if path in schema_paths:
         return resolve_ref(path)
     return {'error': 'invalid schema path'}, 404
Beispiel #23
0
def schema_config_section(section):
    return jsonify(resolve_ref('/schema/config/%s' % section))
Beispiel #24
0
def schema_config_section(section):
    return jsonify(resolve_ref('/schema/config/%s' % section))