class_docstr: `APIRouter` class, used to group *path operations*, for example to structure
  an app in multiple files. It would then be included in the `FastAPI` app, or
  in another `APIRouter` (ultimately included in the app).
  
  Read more about it in the
  [FastAPI docs for Bigger Applications - Multiple Files](https://fastapi.tiangolo.com/tutorial/bigger-applications/).
  
  ## Example
  
  ```python
  from fastapi import APIRouter, FastAPI
  
  app = FastAPI()
  router = APIRouter()
  
  
  @router.get("/users/", tags=["users"])
  async def read_users():
      return [{"username": "Rick"}, {"username": "Morty"}]
  
  
  app.include_router(router)
  ```
code: def __init__(
      self,
      *,
      prefix: Annotated[
          str, Doc("An optional path prefix for the router.")
      ] = "",
      tags: Annotated[
          Optional[List[Union[str, Enum]]],
          Doc(
              """
                  A list of tags to be applied to all the *path operations* in this
                  router.
  
                  It will be added to the generated OpenAPI (e.g. visible at `/docs`).
  
                  Read more about it in the
                  [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
                  """
          ),
      ] = None,
      dependencies: Annotated[
          Optional[Sequence[params.Depends]],
          Doc(
              """
                  A list of dependencies (using `Depends()`) to be applied to all the
                  *path operations* in this router.
  
                  Read more about it in the
                  [FastAPI docs for Bigger Applications - Multiple Files](https://fastapi.tiangolo.com/tutorial/bigger-applications/#include-an-apirouter-with-a-custom-prefix-tags-responses-and-dependencies).
                  """
          ),
      ] = None,
      default_response_class: Annotated[
          Type[Response],
          Doc(
              """
                  The default response class to be used.
  
                  Read more in the
                  [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#default-response-class).
                  """
          ),
      ] = Default(JSONResponse),
      responses: Annotated[
          Optional[Dict[Union[int, str], Dict[str, Any]]],
          Doc(
              """
                  Additional responses to be shown in OpenAPI.
  
                  It will be added to the generated OpenAPI (e.g. visible at `/docs`).
  
                  Read more about it in the
                  [FastAPI docs for Additional Responses in OpenAPI](https://fastapi.tiangolo.com/advanced/additional-responses/).
  
                  And in the
                  [FastAPI docs for Bigger Applications](https://fastapi.tiangolo.com/tutorial/bigger-applications/#include-an-apirouter-with-a-custom-prefix-tags-responses-and-dependencies).
                  """
          ),
      ] = None,
      callbacks: Annotated[
          Optional[List[BaseRoute]],
          Doc(
              """
                  OpenAPI callbacks that should apply to all *path operations* in this
                  router.
  
                  It will be added to the generated OpenAPI (e.g. visible at `/docs`).
  
                  Read more about it in the
                  [FastAPI docs for OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/).
                  """
          ),
      ] = None,
      routes: Annotated[
          Optional[List[BaseRoute]],
          Doc(
              """
                  **Note**: you probably shouldn't use this parameter, it is inherited
                  from Starlette and supported for compatibility.
  
                  ---
  
                  A list of routes to serve incoming HTTP and WebSocket requests.
                  """
          ),
          deprecated(
              """
                  You normally wouldn't use this parameter with FastAPI, it is inherited
                  from Starlette and supported for compatibility.
  
                  In FastAPI, you normally would use the *path operation methods*,
                  like `router.get()`, `router.post()`, etc.
                  """
          ),
      ] = None,
      redirect_slashes: Annotated[
          bool,
          Doc(
              """
                  Whether to detect and redirect slashes in URLs when the client doesn't
                  use the same format.
                  """
          ),
      ] = True,
      default: Annotated[
          Optional[ASGIApp],
          Doc(
              """
                  Default function handler for this router. Used to handle
                  404 Not Found errors.
                  """
          ),
      ] = None,
      dependency_overrides_provider: Annotated[
          Optional[Any],
          Doc(
              """
                  Only used internally by FastAPI to handle dependency overrides.
  
                  You shouldn't need to use it. It normally points to the `FastAPI` app
                  object.
                  """
          ),
      ] = None,
      route_class: Annotated[
          Type[APIRoute],
          Doc(
              """
                  Custom route (*path operation*) class to be used by this router.
  
                  Read more about it in the
                  [FastAPI docs for Custom Request and APIRoute class](https://fastapi.tiangolo.com/how-to/custom-request-and-route/#custom-apiroute-class-in-a-router).
                  """
          ),
      ] = APIRoute,
      on_startup: Annotated[
          Optional[Sequence[Callable[[], Any]]],
          Doc(
              """
                  A list of startup event handler functions.
  
                  You should instead use the `lifespan` handlers.
  
                  Read more in the [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/).
                  """
          ),
      ] = None,
      on_shutdown: Annotated[
          Optional[Sequence[Callable[[], Any]]],
          Doc(
              """
                  A list of shutdown event handler functions.
  
                  You should instead use the `lifespan` handlers.
  
                  Read more in the
                  [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/).
                  """
          ),
      ] = None,
      # the generic to Lifespan[AppType] is the type of the top level application
      # which the router cannot know statically, so we use typing.Any
      lifespan: Annotated[
          Optional[Lifespan[Any]],
          Doc(
              """
                  A `Lifespan` context manager handler. This replaces `startup` and
                  `shutdown` functions with a single context manager.
  
                  Read more in the
                  [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/).
                  """
          ),
      ] = None,
      deprecated: Annotated[
          Optional[bool],
          Doc(
              """
                  Mark all *path operations* in this router as deprecated.
  
                  It will be added to the generated OpenAPI (e.g. visible at `/docs`).
  
                  Read more about it in the
                  [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
                  """
          ),
      ] = None,
      include_in_schema: Annotated[
          bool,
          Doc(
              """
                  To include (or not) all the *path operations* in this router in the
                  generated OpenAPI.
  
                  This affects the generated OpenAPI (e.g. visible at `/docs`).
  
                  Read more about it in the
                  [FastAPI docs for Query Parameters and String Validations](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-from-openapi).
                  """
          ),
      ] = True,
      generate_unique_id_function: Annotated[
          Callable[[APIRoute], str],
          Doc(
              """
                  Customize the function used to generate unique IDs for the *path
                  operations* shown in the generated OpenAPI.
  
                  This is particularly useful when automatically generating clients or
                  SDKs for your API.
  
                  Read more about it in the
                  [FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function).
                  """
          ),
      ] = Default(generate_unique_id),
  ) -> None:
      super().__init__(
          routes=routes,
          redirect_slashes=redirect_slashes,
          default=default,
          on_startup=on_startup,
          on_shutdown=on_shutdown,
          lifespan=lifespan,
      )
      if prefix:
          assert prefix.startswith(
              "/"
          ), "A path prefix must start with '/'"
          assert not prefix.endswith(
              "/"
          ), "A path prefix must not end with '/', as the routes will start with '/'"
      self.prefix = prefix
      self.tags: List[Union[str, Enum]] = tags or []
      self.dependencies = list(dependencies or [])
      self.deprecated = deprecated
      self.include_in_schema = include_in_schema
      self.responses = responses or {}
      self.callbacks = callbacks or []
      self.dependency_overrides_provider = dependency_overrides_provider
      self.route_class = route_class
      self.default_response_class = default_response_class
      self.generate_unique_id_function = generate_unique_id_function
  
imports: import asyncio
  import dataclasses
  import email.message
  import inspect
  import json
  from contextlib import AsyncExitStack
  from enum import Enum, IntEnum
  from typing import Any, Callable, Coroutine, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
  from fastapi import params
  from fastapi._compat import ModelField, Undefined, _get_model_config, _model_dump, _normalize_errors, lenient_issubclass
  from fastapi.datastructures import Default, DefaultPlaceholder
  from fastapi.dependencies.models import Dependant
  from fastapi.dependencies.utils import get_body_field, get_dependant, get_parameterless_sub_dependant, get_typed_return_annotation, solve_dependencies
  from fastapi.encoders import jsonable_encoder
  from fastapi.exceptions import FastAPIError, RequestValidationError, ResponseValidationError, WebSocketRequestValidationError
  from fastapi.types import DecoratedCallable, IncEx
  from fastapi.utils import create_cloned_field, create_response_field, generate_unique_id, get_value_or_default, is_body_allowed_for_status_code
  from pydantic import BaseModel
  from starlette import routing
  from starlette.concurrency import run_in_threadpool
  from starlette.exceptions import HTTPException
  from starlette.requests import Request
  from starlette.responses import JSONResponse, Response
  from starlette.routing import BaseRoute, Match, compile_path, get_name, request_response, websocket_session
  from starlette.routing import Mount
  from starlette.types import ASGIApp, Lifespan, Scope
  from starlette.websockets import WebSocket
  from typing_extensions import Annotated, Doc, deprecated
label_desc: Use image node_id 1 to create a new APIRouter object from inherited base classes: routing with example: obj = APIRouter()