Coverage for faststream / specification / asyncapi / v3_0_0 / schema / servers.py: 82%
15 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-08 01:48 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-08 01:48 +0000
1from typing import Any
3from pydantic import BaseModel
5from faststream._internal._compat import PYDANTIC_V2
6from faststream.specification.asyncapi.v2_6_0.schema import ServerVariable, Tag
7from faststream.specification.asyncapi.v2_6_0.schema.utils import Reference
9SecurityRequirement = list[Reference]
12__all__ = (
13 "Server",
14 "ServerVariable",
15)
18class Server(BaseModel):
19 """A class to represent a server.
21 Attributes:
22 host : host of the server
23 pathname : pathname of the server
24 protocol : protocol used by the server
25 description : optional description of the server
26 protocolVersion : optional version of the protocol used by the server
27 tags : optional list of tags associated with the server
28 security : optional security requirement for the server
29 variables : optional dictionary of server variables
31 Note:
32 The attributes `description`, `protocolVersion`, `tags`, `security`, `variables`, and `bindings` are all optional.
34 Configurations:
35 If `PYDANTIC_V2` is True, the model configuration is set to allow extra attributes.
36 Otherwise, the `Config` class is defined with the `extra` attribute set to "allow".
38 """
40 host: str
41 pathname: str
42 protocol: str
43 description: str | None = None
44 protocolVersion: str | None = None
45 tags: list[Tag | dict[str, Any]] | None = None
46 security: SecurityRequirement | None = None
47 variables: dict[str, ServerVariable | Reference] | None = None
49 if PYDANTIC_V2: 49 ↛ 54line 49 didn't jump to line 54 because the condition on line 49 was always true
50 model_config = {"extra": "allow"}
52 else:
54 class Config:
55 extra = "allow"