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=[('companies', 'Companies API')],
        ondelete={'companies': 'cascade'}
    )

    def _get_fastapi_routers(self) -> List[APIRouter]:
        if self.app == 'companies':
            from ..routers.companies_api import router
            return [router]
        return super()._get_fastapi_routers()