rapid-api-client 0.3.3__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rapid-api-client
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Rapidly develop your API clients using decorators and annotations
5
5
  Author: Sébastien MB
6
6
  Author-email: seb@essembeh.org
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "rapid-api-client"
3
- version = "0.3.3"
3
+ version = "0.3.4"
4
4
  description = "Rapidly develop your API clients using decorators and annotations"
5
5
  authors = ["Sébastien MB <seb@essembeh.org>"]
6
6
  readme = "README.md"
@@ -3,7 +3,7 @@ Model classes
3
3
  """
4
4
 
5
5
  from dataclasses import dataclass
6
- from typing import Any
6
+ from typing import Any, Literal
7
7
 
8
8
  from pydantic import BaseModel
9
9
 
@@ -43,11 +43,14 @@ class Header(BaseAnnotation):
43
43
  alias: str | None = None
44
44
 
45
45
 
46
+ @dataclass
46
47
  class Body(BaseAnnotation):
47
48
  """
48
49
  Annotation to declare an argument used as http content for post/put/...
49
50
  """
50
51
 
52
+ target: Literal["content", "data", "files"] = "content"
53
+
51
54
  def serialize(self, body: Any) -> str | bytes:
52
55
  """
53
56
  Serialize the annotated parameter value
@@ -61,14 +64,9 @@ class FileBody(Body):
61
64
  Annotation to declare an argument used as file to be uploaded
62
65
  """
63
66
 
67
+ target: Literal["content", "data", "files"] = "files"
64
68
  alias: str | None = None
65
69
 
66
- def serialize(self, body: Any) -> str | bytes:
67
- """
68
- Serialize the annotated parameter value
69
- """
70
- return body
71
-
72
70
 
73
71
  @dataclass
74
72
  class PydanticBody(Body):
@@ -104,7 +104,7 @@ class RapidApi:
104
104
  files = build_kwargs.setdefault("files", {})
105
105
  files[annot.alias or param] = annot.serialize(value)
106
106
  else:
107
- build_kwargs["content"] = annot.serialize(value)
107
+ build_kwargs[annot.target] = annot.serialize(value)
108
108
 
109
109
  # handle extra optional kwargs
110
110
  if timeout is not None: