mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-09 04:19:32 +00:00
Connexion 2.0 (#619)
- App and Api options must be provided through the "options" argument (``old_style_options`` have been removed). - You must specify a form content-type in 'consumes' in order to consume form data. - The `Operation` interface has been formalized in the `AbstractOperation` class. - The `Operation` class has been renamed to `Swagger2Operation`. - Array parameter deserialization now follows the Swagger 2.0 spec more closely. In situations when a query parameter is passed multiple times, and the collectionFormat is either csv or pipes, the right-most value will be used. For example, `?q=1,2,3&q=4,5,6` will result in `q = [4, 5, 6]`. The old behavior is available by setting the collectionFormat to `multi`, or by importing `decorators.uri_parsing.AlwaysMultiURIParser` and passing `parser_class=AlwaysMultiURIParser` to your Api. - The spec validator library has changed from `swagger-spec-validator` to `openapi-spec-validator`. - Errors that previously raised `SwaggerValidationError` now raise the `InvalidSpecification` exception. All spec validation errors should be wrapped with `InvalidSpecification`. - Support for nullable/x-nullable, readOnly and writeOnly/x-writeOnly has been added to the standard json schema validator. - Custom validators can now be specified on api level (instead of app level). - Added support for basic authentication and apikey authentication - If unsupported security requirements are defined or ``x-tokenInfoFunc``/``x-tokenInfoUrl`` is missing, connexion now denies requests instead of allowing access without security-check. - Accessing ``connexion.request.user`` / ``flask.request.user`` is no longer supported, use ``connexion.context['user']`` instead
This commit is contained in:
@@ -61,11 +61,15 @@ def test_array_query_param(simple_app):
|
||||
url = '/v1.0/test_array_csv_query_param?items=A&items=B&items=C&items=D,E,F'
|
||||
response = app_client.get(url, headers=headers)
|
||||
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str] multi array with csv format
|
||||
assert array_response == ['D', 'E', 'F']
|
||||
url = '/v1.0/test_array_multi_query_param?items=A&items=B&items=C&items=D,E,F'
|
||||
response = app_client.get(url, headers=headers)
|
||||
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str] multi array with csv format
|
||||
assert array_response == ['A', 'B', 'C', 'D', 'E', 'F']
|
||||
url = '/v1.0/test_array_pipes_query_param?items=4&items=5&items=6&items=7|8|9'
|
||||
response = app_client.get(url, headers=headers)
|
||||
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [int] multi array with pipes format
|
||||
assert array_response == [4, 5, 6, 7, 8, 9]
|
||||
assert array_response == [7, 8, 9]
|
||||
|
||||
|
||||
def test_array_form_param(simple_app):
|
||||
@@ -87,12 +91,12 @@ def test_array_form_param(simple_app):
|
||||
data = 'items=A&items=B&items=C&items=D,E,F'
|
||||
response = app_client.post(url, headers=headers, data=data)
|
||||
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str] multi array with csv format
|
||||
assert array_response == ['A', 'B', 'C', 'D', 'E', 'F']
|
||||
assert array_response == ['D', 'E', 'F']
|
||||
url = '/v1.0/test_array_pipes_form_param'
|
||||
data = 'items=4&items=5&items=6&items=7|8|9'
|
||||
response = app_client.post(url, headers=headers, data=data)
|
||||
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [int] multi array with pipes format
|
||||
assert array_response == [4, 5, 6, 7, 8, 9]
|
||||
assert array_response == [7, 8, 9]
|
||||
|
||||
|
||||
def test_extra_query_param(simple_app):
|
||||
@@ -168,7 +172,10 @@ def test_formdata_bad_request(simple_app):
|
||||
resp = app_client.post('/v1.0/test-formData-param')
|
||||
assert resp.status_code == 400
|
||||
response = json.loads(resp.data.decode('utf-8', 'replace'))
|
||||
assert response['detail'] == "Missing formdata parameter 'formData'"
|
||||
assert response['detail'] in [
|
||||
"Missing formdata parameter 'formData'",
|
||||
"'formData' is a required property" # OAS3
|
||||
]
|
||||
|
||||
|
||||
def test_formdata_missing_param(simple_app):
|
||||
@@ -210,7 +217,10 @@ def test_formdata_file_upload_bad_request(simple_app):
|
||||
resp = app_client.post('/v1.0/test-formData-file-upload')
|
||||
assert resp.status_code == 400
|
||||
response = json.loads(resp.data.decode('utf-8', 'replace'))
|
||||
assert response['detail'] == "Missing formdata parameter 'formData'"
|
||||
assert response['detail'] in [
|
||||
"Missing formdata parameter 'formData'",
|
||||
"'formData' is a required property" # OAS3
|
||||
]
|
||||
|
||||
|
||||
def test_formdata_file_upload_missing_param(simple_app):
|
||||
@@ -313,10 +323,11 @@ def test_nullable_parameter(simple_app):
|
||||
resp = app_client.post('/v1.0/nullable-parameters', data={"post_param": 'null'})
|
||||
assert json.loads(resp.data.decode('utf-8', 'replace')) == 'it was None'
|
||||
|
||||
resp = app_client.put('/v1.0/nullable-parameters', data="null")
|
||||
headers = {"Content-Type": "application/json"}
|
||||
resp = app_client.put('/v1.0/nullable-parameters', data="null", headers=headers)
|
||||
assert json.loads(resp.data.decode('utf-8', 'replace')) == 'it was None'
|
||||
|
||||
resp = app_client.put('/v1.0/nullable-parameters', data="None")
|
||||
resp = app_client.put('/v1.0/nullable-parameters', data="None", headers=headers)
|
||||
assert json.loads(resp.data.decode('utf-8', 'replace')) == 'it was None'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user