| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import TYPE_CHECKING |
| 4 |
|
| 5 |
from litestar import get |
| 6 |
from litestar.enums import MediaType |
| 7 |
from litestar.openapi.plugins import OpenAPIRenderPlugin |
| 8 |
|
| 9 |
if TYPE_CHECKING: |
| 10 |
from litestar.connection import Request |
| 11 |
from litestar.router import Router |
| 12 |
|
| 13 |
|
| 14 |
class MyOpenAPIPlugin(OpenAPIRenderPlugin): |
| 15 |
def render(self, request: Request, openapi_schema: dict[str, str]) -> bytes: |
| 16 |
return b"<html>My UI of Choice!</html>" |
| 17 |
|
| 18 |
def receive_router(self, router: Router) -> None: |
| 19 |
@get("/something", media_type=MediaType.TEXT) |
| 20 |
def something() -> str: |
| 21 |
return "Something" |
| 22 |
|
| 23 |
router.register(something) |