from typing import Dict

from httpmessageprocessorutil.automapped import AutoMappedMessageProcessor
from messageprocessor import MessageProcessor
from simplehttprouter import Route

from ..interactor import AutoOpenApiYamlBuilderInteractor
from ..interactor.dto import AutoOpenApiYamlBuilderRequest


def append_open_api_build_route(routes: Dict[Route, MessageProcessor]) -> Dict[Route, MessageProcessor]:
    processor = AutoMappedMessageProcessor(
        request_type=AutoOpenApiYamlBuilderRequest,
        interactor=AutoOpenApiYamlBuilderInteractor(routes=routes),
        response_content_type="application/yaml",
    )
    routes[Route("GET", "/oas/yaml")] = processor
    return routes
