Skip to content

Commit 3f81f9a

Browse files
authored
Merge pull request #173 from AbdealiJK/ajk-code
apidoc: Add default_in=None by default
2 parents 129efdd + 5a1f1e7 commit 3f81f9a

File tree

2 files changed

+17
-32
lines changed

2 files changed

+17
-32
lines changed

flask_apispec/apidoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_parameters(self, rule, view, docs, parent=None):
9494
locations = options.pop('locations', None)
9595
if locations:
9696
options['default_in'] = locations[0]
97-
else:
97+
elif 'default_in' not in options:
9898
options['default_in'] = 'body'
9999
extra_params += converter(schema, **options) if args else []
100100

tests/test_openapi.py

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_params(self, app, path):
245245
assert params == expected
246246

247247

248-
class TestFiledsNoLocationProvided:
248+
class TestGetFieldsNoLocationProvided:
249249

250250
@pytest.fixture
251251
def function_view(self, app):
@@ -266,26 +266,19 @@ def path(self, app, spec, function_view):
266266

267267
def test_params(self, app, path):
268268
params = path['get']['parameters']
269-
rule = app.url_map._rules_by_endpoint['get_band'][0]
270-
expected = (
271-
[{
272-
'in': 'body',
273-
'name': 'body',
274-
'required': False,
275-
'schema': {
276-
'properties': {
277-
'address': {
278-
'type': 'string'
279-
},
280-
'name': {
281-
'type': 'string'
282-
}
283-
},
284-
'type': 'object'
285-
},
286-
}] + rule_to_params(rule)
287-
)
288-
assert params == expected
269+
assert {
270+
'in': 'body',
271+
'name': 'body',
272+
'required': False,
273+
'schema': {
274+
'properties': {
275+
'address': {'type': 'string'},
276+
'name': {'type': 'string'},
277+
},
278+
'type': 'object',
279+
},
280+
} in params
281+
289282

290283
class TestSchemaNoLocationProvided:
291284

@@ -310,13 +303,5 @@ def path(self, app, spec, function_view):
310303

311304
def test_params(self, app, path):
312305
params = path['get']['parameters']
313-
rule = app.url_map._rules_by_endpoint['get_band'][0]
314-
expected = (
315-
[{
316-
'in': 'body',
317-
'name': 'body',
318-
'required': False,
319-
'schema': {'$ref': '#/definitions/Body'}
320-
}] + rule_to_params(rule)
321-
)
322-
assert params == expected
306+
assert {'name': 'body', 'in': 'body', 'required': False,
307+
'schema': {'$ref': '#/definitions/Body'}} in params

0 commit comments

Comments
 (0)