# Generated by smithplates HTTP codegen. Do not edit.
from typing import Annotated

from fastapi import (
    APIRouter,
    Depends,
    Path,
)
from generated.example.widget_list_output import WidgetListOutput
from generated.example.widget_output import WidgetOutput
from generated.widget_api.widget_api.api_response import dispatch_api_response
from generated.widget_api.widget_api.app_services import ApiServices, get_api_services
from generated.widget_api.widget_api.operation_bindings import OPERATION_HTTP_BINDINGS
from pydantic import Field  # noqa: F401

router = APIRouter()


@router.get(
    "/v1/widgets/{id}",
    responses={
        200: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def get_widget(
    services: Annotated[ApiServices, Depends(get_api_services)],
    id_: str = Path(..., alias="id"),
) -> WidgetOutput:
    return dispatch_api_response(
        await services.v1_widgets_api.get_widget(id_=id_),
        OPERATION_HTTP_BINDINGS["get_widget"],
    )


@router.get(
    "/v1/widgets",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def list_widgets(
    services: Annotated[ApiServices, Depends(get_api_services)],
) -> WidgetListOutput:
    return dispatch_api_response(
        await services.v1_widgets_api.list_widgets(),
        OPERATION_HTTP_BINDINGS["list_widgets"],
    )
