Skip to content

Commit 52995d1

Browse files
authored
Merge pull request #69 from dlt-hub/feat/allow_filetype_in_url_with_var
add support for paths with vars and file-ending (hacker news)
2 parents 1c827e8 + 17262c0 commit 52995d1

File tree

4 files changed

+203
-0
lines changed

4 files changed

+203
-0
lines changed

dlt_openapi/utils/paths.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def get_path_parts(path: str) -> List[str]:
8888
"""convert path into parts"""
8989
if not path:
9090
return []
91+
path = path.split(".")[0]
9192
return path.strip("/").split("/")
9293

9394

tests/cases/artificial_specs/params.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,15 @@ paths:
138138
application/json:
139139
schema:
140140
type: object
141+
142+
143+
/path_param_file_ending/{path_param}/{path_param_2}.json:
144+
get:
145+
operationId: path_param_file_ending
146+
responses:
147+
'200':
148+
description: "OK"
149+
content:
150+
application/json:
151+
schema:
152+
type: object
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Hacker News
4+
description: |
5+
<p>Hacker News API</p>
6+
version: 1.0.1
7+
servers:
8+
- url: https://hacker-news.firebaseio.com/v0
9+
tags:
10+
- name: Item
11+
description: Operations about Item
12+
- name: Maxitem
13+
description: Operations about Maxitem
14+
- name: Topstories
15+
description: Operations about Topstories
16+
- name: Updates
17+
description: Operations about Updates
18+
- name: User
19+
description: Operations about User
20+
paths:
21+
/updates.json:
22+
get:
23+
tags:
24+
- HackerNews
25+
summary: Get the changed items and profiles
26+
description: Get the changed items and profiles
27+
operationId: get
28+
responses:
29+
"200":
30+
description: OK
31+
content:
32+
application/json:
33+
schema:
34+
$ref: '#/components/schemas/Updates'
35+
security: []
36+
/topstories.json:
37+
get:
38+
tags:
39+
- HackerNews
40+
summary: Returns the current top 100 stories.
41+
description: Returns the current top 100 stories.
42+
operationId: get_top_stories
43+
responses:
44+
"200":
45+
description: OK
46+
content:
47+
application/json:
48+
schema:
49+
type: array
50+
items:
51+
type: integer
52+
format: int32
53+
security: []
54+
/user/{id}.json:
55+
get:
56+
tags:
57+
- HackerNews
58+
summary: Users are identified by case-sensitive ids
59+
description: Users are identified by case-sensitive ids
60+
operationId: get_user
61+
parameters:
62+
- name: id
63+
in: path
64+
description: User ID
65+
required: true
66+
schema:
67+
type: string
68+
example: wing328hk
69+
responses:
70+
"200":
71+
description: OK
72+
content:
73+
application/json:
74+
schema:
75+
$ref: '#/components/schemas/User'
76+
security: []
77+
/maxitem.json:
78+
get:
79+
tags:
80+
- HackerNews
81+
summary: Get the current largest item id
82+
description: Get the current largest item id
83+
operationId: get_max_item
84+
responses:
85+
"200":
86+
description: OK
87+
content:
88+
application/json:
89+
schema:
90+
type: integer
91+
format: int32
92+
security: []
93+
/item/{id}.json:
94+
get:
95+
tags:
96+
- HackerNews
97+
summary: "Get the Item (story, comment, jobs, Ask HN, etc)"
98+
description: "Stories, comments, jobs, Ask HNs and even polls are just items.\
99+
\ They're identified by their ids, which are unique integers."
100+
operationId: get_item
101+
parameters:
102+
- name: id
103+
in: path
104+
description: Item ID
105+
required: true
106+
schema:
107+
type: string
108+
example: "10000"
109+
responses:
110+
"200":
111+
description: OK
112+
content:
113+
application/json:
114+
schema:
115+
$ref: '#/components/schemas/Item'
116+
security: []
117+
components:
118+
schemas:
119+
Updates:
120+
required:
121+
- items
122+
type: object
123+
properties:
124+
items:
125+
type: array
126+
items:
127+
type: integer
128+
profiles:
129+
type: array
130+
items:
131+
type: string
132+
Item:
133+
required:
134+
- by
135+
type: object
136+
properties:
137+
by:
138+
type: string
139+
id:
140+
type: integer
141+
format: int32
142+
kids:
143+
type: integer
144+
format: int32
145+
parent:
146+
type: integer
147+
format: int32
148+
parts:
149+
type: integer
150+
format: int32
151+
score:
152+
type: integer
153+
format: int32
154+
text:
155+
type: string
156+
time:
157+
type: integer
158+
format: int32
159+
title:
160+
type: string
161+
type:
162+
type: string
163+
url:
164+
type: string
165+
User:
166+
required:
167+
- about
168+
type: object
169+
properties:
170+
about:
171+
type: string
172+
created:
173+
type: integer
174+
delay:
175+
type: integer
176+
id:
177+
type: string
178+
karma:
179+
type: integer
180+
submitted:
181+
type: array
182+
items:
183+
type: integer

tests/integration/basics/test_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ def test_param_defaults(resources: Dict[str, Any]) -> None:
5454
"path_param": "path_param_default",
5555
"path_param_2": DEFAULT_VALUE,
5656
}
57+
58+
59+
def test_path_param_with_file_ending(resources: Dict[str, Any]) -> None:
60+
assert resources["path_param_file_ending"]["endpoint"]["params"] == {
61+
"path_param": DEFAULT_VALUE,
62+
"path_param_2": DEFAULT_VALUE,
63+
}

0 commit comments

Comments
 (0)