| 1 |
from typing import Dict |
| 2 |
|
| 3 |
from litestar import Litestar, get |
| 4 |
from litestar.openapi.config import OpenAPIConfig |
| 5 |
from litestar.openapi.plugins import SwaggerRenderPlugin |
| 6 |
|
| 7 |
|
| 8 |
@get("/", sync_to_thread=False) |
| 9 |
def hello_world() -> Dict[str, str]: |
| 10 |
return {"message": "Hello World"} |
| 11 |
|
| 12 |
|
| 13 |
app = Litestar( |
| 14 |
route_handlers=[hello_world], |
| 15 |
openapi_config=OpenAPIConfig( |
| 16 |
title="Litestar Example", |
| 17 |
description="Example of litestar", |
| 18 |
version="0.0.1", |
| 19 |
render_plugins=[ |
| 20 |
SwaggerRenderPlugin( |
| 21 |
init_oauth={ |
| 22 |
"clientId": "your-client-id", |
| 23 |
"appName": "your-app-name", |
| 24 |
"scopeSeparator": " ", |
| 25 |
"scopes": "openid profile", |
| 26 |
"useBasicAuthenticationWithAccessCodeGrant": True, |
| 27 |
"usePkceWithAuthorizationCodeGrant": True, |
| 28 |
} |
| 29 |
) |
| 30 |
], |
| 31 |
), |
| 32 |
) |