Skip to content

Commit 8045063

Browse files
committed
bug chaotic: fix 'explode: true' handling
commit_hash:0f918d8f39278fdd7a01ef5a96fe7a92eccf421c
1 parent 02377be commit 8045063

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

chaotic-openapi/chaotic_openapi/front/parser.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,15 @@ def _convert_openapi_parameter(
114114
) -> model.Parameter:
115115
if isinstance(parameter, openapi.Ref):
116116
return self._state.service.parameters[self._locate_ref(parameter.ref)]
117+
118+
if parameter.explode and parameter.in_ == openapi.In.query:
119+
in_ = model.In.queryExplode
120+
else:
121+
in_ = model.In(parameter.in_)
122+
117123
p = model.Parameter(
118124
name=parameter.name,
119-
in_=model.In(parameter.in_),
125+
in_=in_,
120126
description=parameter.description or '',
121127
examples=parameter.examples,
122128
deprecated=parameter.deprecated,

chaotic-openapi/integration_tests/clients/parameters/openapi.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ paths:
2121
required: false
2222
schema:
2323
type: string
24+
- name: multiple
25+
explode: true
26+
in: query
27+
required: false
28+
schema:
29+
type: array
30+
items:
31+
type: string
2432
requestBody:
2533
content:
2634
application/json:

chaotic-openapi/integration_tests/src/parameters_test.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <userver/utest/utest.hpp>
22

33
#include <clients/parameters/requests.hpp>
4+
#include <userver/clients/http/client.hpp>
5+
#include <userver/utest/http_client.hpp>
46

57
USERVER_NAMESPACE_BEGIN
68

@@ -15,6 +17,17 @@ UTEST(Parameters, CppName) {
1517
request.myclass = "123";
1618
}
1719

20+
UTEST(Parameters, Explode) {
21+
client::Request request;
22+
auto http_client_ptr = utest::CreateHttpClient();
23+
auto http_request = http_client_ptr->CreateRequest();
24+
25+
request.multiple = {"1", "2", "3"};
26+
client::SerializeRequest(request, "http://base", http_request);
27+
28+
EXPECT_EQ(http_request.GetUrl(), "http://base/test1?multiple=1&multiple=2&multiple=3");
29+
}
30+
1831
} // namespace
1932

2033
USERVER_NAMESPACE_END

chaotic-openapi/tests/front/test_openapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def test_openapi_parameters(simple_parser):
364364
),
365365
model.Parameter(
366366
name='pamparam2',
367-
in_=model.In.query,
367+
in_=model.In.queryExplode,
368368
description='override',
369369
required=False,
370370
schema=types.Array(items=types.Number()),

0 commit comments

Comments
 (0)