1010
1111
1212class WebArg (abc .ABC ):
13- pass
13+ """Base class for web-processed parameters."""
1414
1515
1616@dc .dataclass
1717class Body (WebArg ):
18+ """
19+ Link content type headers with a python type.
20+ When used with a method parameter, it tells lapidary what content-type header to send for a given body type.
21+ When used in return annotation, it tells lapidary the type to process the response body as.
22+
23+ Example use with parameter:
24+
25+ ```python
26+ body: Body({'application/json': BodyModel})
27+ ```
28+ """
29+
1830 content : Mapping [MimeType , type ]
1931
2032
2133class Metadata (WebArg ):
22- """Annotation for models that hold other WebArg fields"""
34+ """
35+ Annotation for models that hold other WebArg fields.
36+ Can be used to group request parameters as an alternative to passing parameters directly.
37+
38+ Example:
39+ ```python
40+ class RequestMetadata(pydantic.BaseModel):
41+ my_header: typing.Annotated[
42+ str,
43+ Header('my-header'),
44+ ]
45+
46+ class Client(ApiClient):
47+ @get(...)
48+ async def my_method(
49+ headers: Annotated[RequestMetadata, Metadata]
50+ ):
51+ ```
52+ """
2353
2454
2555class Param (WebArg , abc .ABC ):
56+ """Base class for web parameters (headers, query and path parameters, including cookies)"""
57+
2658 style : typing .Any
2759 alias : typing .Optional [str ]
2860
@@ -31,13 +63,19 @@ def __init__(self, alias: typing.Optional[str], /) -> None:
3163
3264
3365class Header (Param ):
66+ """Mark parameter as HTTP Header"""
67+
3468 def __init__ (
3569 self ,
3670 alias : typing .Optional [str ] = None ,
3771 / ,
3872 * ,
3973 style : type [MultimapSerializationStyle ] = SimpleMultimap ,
4074 ) -> None :
75+ """
76+ :param alias: Header name, if different than the name of the annotated parameter
77+ :param style: Serialization style
78+ """
4179 super ().__init__ (alias )
4280 self .style = style
4381
@@ -50,6 +88,10 @@ def __init__(
5088 * ,
5189 style : type [MultimapSerializationStyle ] = FormExplode ,
5290 ) -> None :
91+ """
92+ :param alias: Cookie name, if different than the name of the annotated parameter
93+ :param style: Serialization style
94+ """
5395 super ().__init__ (alias )
5496 self .style = style
5597
@@ -62,6 +104,10 @@ def __init__(
62104 * ,
63105 style : type [StringSerializationStyle ] = SimpleString ,
64106 ) -> None :
107+ """
108+ :param alias: Path parameter name, if different than the name of the annotated parameter
109+ :param style: Serialization style
110+ """
65111 super ().__init__ (alias )
66112 self .style = style
67113
@@ -74,6 +120,10 @@ def __init__(
74120 * ,
75121 style : type [MultimapSerializationStyle ] = FormExplode ,
76122 ) -> None :
123+ """
124+ :param alias: Query parameter name, if different than the name of the annotated parameter
125+ :param style: Serialization style
126+ """
77127 super ().__init__ (alias )
78128 self .style = style
79129
@@ -95,4 +145,28 @@ class Response:
95145
96146@dc .dataclass
97147class Responses (WebArg ):
148+ """
149+ Mapping between response code, headers, media type and body type.
150+ The simplified structure is:
151+
152+ response code => (
153+ body: content type => body model type
154+ headers model
155+ )
156+
157+ The structure follows OpenAPI 3.
158+ """
159+
98160 responses : Mapping [StatusCodeRange , Response ]
161+ """
162+ Map of status code match to Response.
163+ Key may be:
164+
165+ - any HTTP status code
166+ - HTTP status code range, i.e. 1XX, 2XX, etc
167+ - "default"
168+
169+ The most specific value takes precedence.
170+
171+ Value is [Body][lapidary.runtime.Body]
172+ """
0 commit comments