Description
See example below - using the Scalar docs the schema for the get_items endpoint is blank (just says "No Body"). Ideally the schema would be populated exactly as if the response wasn't wrapped in a "Response" object, i.e. it should just use the type hinting info List[Item].
URL to code causing the issue
http://127.0.0.1:8000/schema
MCVE
from dataclasses import dataclass
from typing import List
from litestar import Litestar, get, Response
from litestar.openapi import OpenAPIConfig
from litestar.openapi.plugins import ScalarRenderPlugin
from litestar.dto import DataclassDTO, DTOConfig
@dataclass
class Item:
id: int
name: str
secret: str
class ItemReadDTO(DataclassDTO[Item]):
config = DTOConfig(exclude=["secret"])
@get("/get_items", return_dto=ItemReadDTO)
async def get_items() -> Response[List[Item]]:
return Response(
headers={"X-SomeParam": "SomeValue"},
content=[
Item(id=1, name="Item 1", secret='123'),
Item(id=2, name="Item 2", secret='456'),
]
)
@get("/get_items_raw", return_dto=ItemReadDTO)
async def get_items_raw() -> List[Item]:
return [
Item(id=1, name="Item 1", secret='123'),
Item(id=2, name="Item 2", secret='456'),
]
app = Litestar(
route_handlers=[get_items, get_items_raw],
openapi_config=OpenAPIConfig(
title="Scalar Issue",
version="0.1.0",
render_plugins=[ScalarRenderPlugin()],
),
debug=True,
)
Steps to reproduce
Screenshots
""
Logs
No response
Litestar Version
2.13.0
Platform
Description
See example below - using the Scalar docs the schema for the
get_itemsendpoint is blank (just says "No Body"). Ideally the schema would be populated exactly as if the response wasn't wrapped in a "Response" object, i.e. it should just use the type hinting infoList[Item].URL to code causing the issue
http://127.0.0.1:8000/schema
MCVE
Steps to reproduce
Screenshots
""Logs
No response
Litestar Version
2.13.0
Platform