from typing import Dict, Union, Type

from dihttpmessageprocessor import AutoMappedRouteBuilder, AutoMappedWebApi
from httpmessageprocessorutil.automapped import AutoMappedMessageProcessor
from messageprocessor import MessageProcessor
from simplehttprouter import Route

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


class OpenApiRouteBuilder(AutoMappedRouteBuilder):
    def build_routes(self) -> Dict[Route, Union[Type[MessageProcessor], AutoMappedWebApi]]:
        return {
            Route("GET", "/oas/yaml"): AutoMappedWebApi(
                processor_type=AutoMappedMessageProcessor,
                request_type=AutoOpenApiYamlBuilderRequest,
                interactor_type=AutoOpenApiYamlBuilderInteractor,
                response_content_type="application/yaml",
            ),
        }
