# Path: shelf/error_code.py
# class ErrorCode(object):
#     RESOURCE_NOT_FOUND = "resource_not_found"
#     INTERNAL_SERVER_ERROR = "internal_server_error"
#     DUPLICATE_ARTIFACT = "duplicate_artifact"
#     INVALID_ARTIFACT_NAME = "invalid_artifact_name"
#     FORBIDDEN = "forbidden"
#     INVALID_SEARCH_CRITERIA = "invalid_search_criteria"
#     BAD_REQUEST = "bad_request"
#     PERMISSION_DENIED = "permission_denied"
#     INVALID_REQUEST_DATA_FORMAT = "invalid_request_data_format"
# 
# Path: shelf/get_container.py
# def get_container():
#     container = None
#     if hasattr(flask, "g") and flask.g:
#         container = getattr(flask.g, "container", None)
#         if not container:
#             container = Container(flask.current_app, flask.request)
#             flask.g.container = container
# 
#     return container


import functools
import json
import shelf.response_map as response_map
from shelf.error_code import ErrorCode
from shelf.get_container import get_container
from jsonschema import ValidationError
from fuzzywuzzy import fuzz
from copy import deepcopy

        return data

    def validate_request(self, schema_path, default_request_body=None):
        """
            It decodes data as JSON, validates request data against schema,
            and injects that data into the route.

            Args:
                schema_path(string)
                default_request_body(dict) - This argument is used to allow
                                             an empty request body. To use it,
                                             pass an empty dict ({}) to the
                                             decorator.

            Returns:
                function
        """
        def validation_decorator(func):
            @functools.wraps(func)
            def wrapper(container, *args, **kwargs):
                data = self.decode_request(container, default_request_body)

                if container.context.has_error():
                    return response_map.map_context_error(container.context)
                else:
                    try:
                        container.schema_validator.validate(schema_path, data)
                    except ValidationError as e:
                        msg = container.schema_validator.format_error(e)

# Path: shelf/error_code.py
# class ErrorCode(object):
#     RESOURCE_NOT_FOUND = "resource_not_found"
#     INTERNAL_SERVER_ERROR = "internal_server_error"
#     DUPLICATE_ARTIFACT = "duplicate_artifact"
#     INVALID_ARTIFACT_NAME = "invalid_artifact_name"
#     FORBIDDEN = "forbidden"
#     INVALID_SEARCH_CRITERIA = "invalid_search_criteria"
#     BAD_REQUEST = "bad_request"
#     PERMISSION_DENIED = "permission_denied"
#     INVALID_REQUEST_DATA_FORMAT = "invalid_request_data_format"
# 
# Path: shelf/get_container.py
# def get_container():
#     container = None
#     if hasattr(flask, "g") and flask.g:
#         container = getattr(flask.g, "container", None)
#         if not container:
#             container = Container(flask.current_app, flask.request)
#             flask.g.container = container
# 
#     return container


# Path: shelf/endpoint_decorators.py
import functools
import json
import shelf.response_map as response_map
from shelf.error_code import ErrorCode
from shelf.get_container import get_container
from jsonschema import ValidationError
from fuzzywuzzy import fuzz
from copy import deepcopy


        return data

    def validate_request(self, schema_path, default_request_body=None):
        """
            It decodes data as JSON, validates request data against schema,
            and injects that data into the route.

            Args:
                schema_path(string)
                default_request_body(dict) - This argument is used to allow
                                             an empty request body. To use it,
                                             pass an empty dict ({}) to the
                                             decorator.

            Returns:
                function
        """
        def validation_decorator(func):
            @functools.wraps(func)
            def wrapper(container, *args, **kwargs):
                data = self.decode_request(container, default_request_body)

                if container.context.has_error():
                    return response_map.map_context_error(container.context)
                else:
                    try:
                        container.schema_validator.validate(schema_path, data)
                    except ValidationError as e:
                        msg = container.schema_validator.format_error(e)

                        response = response_map.create_400(ErrorCode.INVALID_REQUEST_DATA_FORMAT, msg)