# Path: mass_flask_api/config.py
# class BasePathAPISpec(APISpec):
#     def to_dict(self):
# def api_root():
# def swagger():
# def api_unauthorized_callback():
# def before_request_set_unauthorized_callback():


from mass_flask_api.config import api_blueprint
    from marshmallow import Schema
    from marshmallow.fields import Nested, Int


def get_pagination_compatible_schema(schema_class):

    class PaginationCompatibleSchema(Schema):
        results = Nested(schema_class, many=True)
        next = Int()
        previous = Int()
    return PaginationCompatibleSchema()


def register_api_endpoint(endpoint_name, resource):
    endpoint_path = '/{}/'.format(endpoint_name)
    endpoint_detail_path = endpoint_path + '<{}>/'.format(resource.query_key_field)
    endpoint_detail_path_spec = endpoint_path + '{{{}}}/'.format(resource.query_key_field)
    resource_view = resource.as_view(endpoint_name)
    resource_detail_view = resource.as_view(endpoint_name + '_detail')

# Path: mass_flask_api/config.py
# class BasePathAPISpec(APISpec):
#     def to_dict(self):
# def api_root():
# def swagger():
# def api_unauthorized_callback():
# def before_request_set_unauthorized_callback():


# Path: mass_flask_api/utils.py
from mass_flask_api.config import api_blueprint
    from marshmallow import Schema
    from marshmallow.fields import Nested, Int



def get_pagination_compatible_schema(schema_class):

    class PaginationCompatibleSchema(Schema):
        results = Nested(schema_class, many=True)
        next = Int()
        previous = Int()
    return PaginationCompatibleSchema()


def register_api_endpoint(endpoint_name, resource):
    endpoint_path = '/{}/'.format(endpoint_name)
    endpoint_detail_path = endpoint_path + '<{}>/'.format(resource.query_key_field)
    endpoint_detail_path_spec = endpoint_path + '{{{}}}/'.format(resource.query_key_field)
    resource_view = resource.as_view(endpoint_name)
    resource_detail_view = resource.as_view(endpoint_name + '_detail')

    api_blueprint.add_url_rule(endpoint_path, view_func=resource_view, methods=['GET'])