Skip to content

Commit e332665

Browse files
committed
Add super basic PATCH/POST/PUT support
Closes #8.
1 parent 4c6c87e commit e332665

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

openapi_python_client/models/openapi.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class Endpoint:
5050
@staticmethod
5151
def get_by_tags_from_dict(d: Dict[str, Dict[str, Dict]], /) -> Dict[str, List[Endpoint]]:
5252
""" Parse the openapi paths data to get a list of endpoints """
53-
# TODO: handle requestBody
5453
endpoints_by_tag: Dict[str, List[Endpoint]] = defaultdict(list)
5554
for path, path_data in d.items():
5655
for method, method_data in path_data.items():

openapi_python_client/templates/endpoint_module.pyi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ import requests
22

33
from ..client import Client
44

5+
56
{% for endpoint in endpoints %}
67
def {{ endpoint.name }}(client: Client):
78
""" {{ endpoint.description }} """
89
url = client.base_url + "{{ endpoint.path }}"
910

1011
{% if endpoint.method == "get" %}
11-
return requests.get(url)
12+
return requests.get(url=url)
13+
{% elif endpoint.method == "post" %}
14+
return requests.post(url=url)
15+
{% elif endpoint.method == "patch" %}
16+
return requests.patch(url=url)
17+
{% elif endpoint.method == "put" %}
18+
return requests.put(url=url)
1219
{% endif %}
1320

1421

0 commit comments

Comments
 (0)