Coverage for faststream / specification / asyncapi / v2_6_0 / schema / servers.py: 77%
22 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.tag import Tag
7from faststream.specification.asyncapi.v2_6_0.schema.utils import Reference
9SecurityRequirement = list[dict[str, list[str]]]
12class ServerVariable(BaseModel):
13 """A class to represent a server variable.
15 Attributes:
16 enum : list of possible values for the server variable (optional)
17 default : default value for the server variable (optional)
18 description : description of the server variable (optional)
19 examples : list of example values for the server variable (optional)
20 """
22 enum: list[str] | None = None
23 default: str | None = None
24 description: str | None = None
25 examples: list[str] | None = None
27 if PYDANTIC_V2: 27 ↛ 32line 27 didn't jump to line 32 because the condition on line 27 was always true
28 model_config = {"extra": "allow"}
30 else:
32 class Config:
33 extra = "allow"
36class Server(BaseModel):
37 """A class to represent a server.
39 Attributes:
40 url : URL of the server
41 protocol : protocol used by the server
42 description : optional description of the server
43 protocolVersion : optional version of the protocol used by the server
44 tags : optional list of tags associated with the server
45 security : optional security requirement for the server
46 variables : optional dictionary of server variables
47 bindings : optional server binding
49 Note:
50 The attributes `description`, `protocolVersion`, `tags`, `security`, `variables`, and `bindings` are all optional.
51 """
53 url: str
54 protocol: str
55 protocolVersion: str | None
56 description: str | None = None
57 tags: list[Tag | dict[str, Any]] | None = None
58 security: SecurityRequirement | None = None
60 variables: dict[str, ServerVariable | Reference] | None = None
62 if PYDANTIC_V2: 62 ↛ 67line 62 didn't jump to line 67 because the condition on line 62 was always true
63 model_config = {"extra": "allow"}
65 else:
67 class Config:
68 extra = "allow"