from odoo import models, fields
from fastapi import APIRouter
from typing import List


class FastapiEndpoint(models.Model):
    _inherit = "fastapi.endpoint"

    app = fields.Selection(
        selection_add=[("products", "Products API")],
        ondelete={"products": "cascade"}
    )

    def _get_fastapi_routers(self) -> List[APIRouter]:
        if self.app == "products":
            from ..routers.products_api import router
            return [router]
        return super()._get_fastapi_routers()