def get_endpoints(
        self, routes: typing.List[BaseRoute]
    ) -> typing.List[EndpointInfo]:
        """
        Given the routes, yields the following information:

        - path
            eg: /users/
        - http_method
            one of 'get', 'post', 'put', 'patch', 'delete', 'options'
        - func
            method ready to extract the docstring
        """
        endpoints_info: list = []

        for route in routes:
            if isinstance(route, Mount):
                routes = route.routes or []
                sub_endpoints = [
                    EndpointInfo(
                        path="".join((route.path, sub_endpoint.path)),
                        http_method=sub_endpoint.http_method,
                        func=sub_endpoint.func,
                    )
                    for sub_endpoint in self.get_endpoints(routes)
                ]
                endpoints_info.extend(sub_endpoints)

            elif not isinstance(route, Route) or not route.include_in_schema:
                continue

            elif inspect.isfunction(route.endpoint) or inspect.ismethod(route.endpoint):
                for method in route.methods or ["GET"]:
                    if method == "HEAD":
                        continue
                    endpoints_info.append(
                        EndpointInfo(route.path, method.lower(), route.endpoint)
                    )
            else:
                for method in ["get", "post", "put", "patch", "delete", "options"]:
                    if not hasattr(route.endpoint, method):
                        continue
                    func = getattr(route.endpoint, method)
                    endpoints_info.append(
                        EndpointInfo(route.path, method.lower(), func)
                    )

        return endpoints_info
def get_endpoints(
        self, routes: typing.List[BaseRoute]
    ) -> typing.List[EndpointInfo]:
        """
        Given the routes, yields the following information:

        - path
            eg: /users/
        - http_method
            one of 'get', 'post', 'put', 'patch', 'delete', 'options'
        - func
            method ready to extract the docstring
        """
        endpoints_info: list = []

        for route in routes:
            if isinstance(route, Mount):
                routes = route.routes or []
                sub_endpoints = [
                    EndpointInfo(
                        path="".join((route.path, sub_endpoint.path)),
                        http_method=sub_endpoint.http_method,
                        func=sub_endpoint.func,
                    )
                    for sub_endpoint in self.get_endpoints(routes)
                ]
                endpoints_info.extend(sub_endpoints)

            elif not isinstance(route, Route) or not route.include_in_schema:
                continue

            elif inspect.isfunction(route.endpoint) or inspect.ismethod(route.endpoint):
                for method in route.methods or ["GET"]:
                    if method == "HEAD":
                        continue
                    endpoints_info.append(
                        EndpointInfo(route.path, method.lower(), route.endpoint)
                    )
            else:
                for method in ["get", "post", "put", "patch", "delete", "options"]:
                    if not hasattr(route.endpoint, method):
                        continue
                    func = getattr(route.endpoint, method)
                    endpoints_info.append(
                        EndpointInfo(route.path, method.lower(), func)
                    )

        return endpoints_info
def get_endpoints ( self , routes : typing . List [ BaseRoute ] ) -> typing . List [ EndpointInfo ] : endpoints_info : list = [ ] for route in routes : if isinstance ( route , Mount ) : routes = route . routes or [ ] sub_endpoints = [ EndpointInfo ( path = "" . join ( ( route . path , sub_endpoint . path ) ) , http_method = sub_endpoint . http_method , func = sub_endpoint . func , ) for sub_endpoint in self . get_endpoints ( routes ) ] endpoints_info . extend ( sub_endpoints ) elif not isinstance ( route , Route ) or not route . include_in_schema : continue elif inspect . isfunction ( route . endpoint ) or inspect . ismethod ( route . endpoint ) : for method in route . methods or [ "GET" ] : if method == "HEAD" : continue endpoints_info . append ( EndpointInfo ( route . path , method . lower ( ) , route . endpoint ) ) else : for method in [ "get" , "post" , "put" , "patch" , "delete" , "options" ] : if not hasattr ( route . endpoint , method ) : continue func = getattr ( route . endpoint , method ) endpoints_info . append ( EndpointInfo ( route . path , method . lower ( ) , func ) ) return endpoints_info
Given the routes, yields the following information:

        - path
            eg: /users/
        - http_method
            one of 'get', 'post', 'put', 'patch', 'delete', 'options'
        - func
            method ready to extract the docstring
Given the routes yields the following information :