Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions litestar/openapi/spec/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,24 @@ class Schema(BaseSchemaObject):
discouraged, and later versions of this specification may remove it.
"""

dynamic_ref: str | None = field(default=None, metadata={"alias": "$dynamicRef"})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has nothing to do with headers

"""The value of ``$dynamicRef`` MUST be a string, in the form of a URI-reference.

This keyword is used to reference a dynamically-anchored schema. At runtime, the URI reference is resolved against
the base URI of the current schema, and the resolved URI is used to locate the schema to be applied.

See `JSON Schema 2020-12 §7.7.1 <https://json-schema.org/draft/2020-12/json-schema-core#section-7.7.1>`_.
"""

dynamic_anchor: str | None = field(default=None, metadata={"alias": "$dynamicAnchor"})
"""The value of ``$dynamicAnchor`` MUST be a string.

This keyword is used to create a dynamic anchor in the schema. A dynamic anchor can be referenced by a
``$dynamicRef`` in another schema, allowing for dynamic schema composition.

See `JSON Schema 2020-12 §7.7.2 <https://json-schema.org/draft/2020-12/json-schema-core#section-7.7.2>`_.
"""

def __hash__(self) -> int:
return _recursive_hash(self)

Expand Down
14 changes: 10 additions & 4 deletions litestar/response/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
content_length: int | None = None,
cookies: Iterable[Cookie] | None = None,
encoding: str = "utf-8",
headers: dict[str, Any] | None = None,
headers: dict[str, Any] | Iterable[tuple[str, str]] | None = None,
is_head_response: bool = False,
media_type: MediaType | str | None = None,
status_code: int | None = None,
Expand All @@ -53,7 +53,7 @@ def __init__(
content_length: The response content length.
cookies: The response cookies.
encoding: The response encoding.
headers: The response headers.
headers: The response headers. Accepts a dict or an iterable of ``(name, value)`` tuples to allow repeated headers.
is_head_response: A boolean indicating if the response is a HEAD response.
iterator: An async iterator or iterable.
media_type: The response media type.
Expand Down Expand Up @@ -175,7 +175,7 @@ def to_asgi_response(
*,
background: BackgroundTask | BackgroundTasks | None = None,
cookies: Iterable[Cookie] | None = None,
headers: dict[str, str] | None = None,
headers: dict[str, Any] | Iterable[tuple[str, str]] | None = None,
is_head_response: bool = False,
media_type: MediaType | str | None = None,
status_code: int | None = None,
Expand All @@ -197,7 +197,13 @@ def to_asgi_response(
An ASGIStreamingResponse instance.
"""

headers = {**headers, **self.headers} if headers is not None else self.headers
if headers is not None:
headers = {
**dict(headers if isinstance(headers, dict) else headers),
**self.headers,
}
else:
headers = self.headers
cookies = self.cookies if cookies is None else itertools.chain(self.cookies, cookies)

media_type = get_enum_string_value(media_type or self.media_type or MediaType.JSON)
Expand Down
Loading