34 Commits

Author SHA1 Message Date
Daniel Grossmann-Kavanagh
3fecd3e735 fix nested additionalProperties (#1138) 2020-01-29 09:24:48 +01:00
Fabian Wollert
e62ac5958c match all but whitespaces inside object keys (#1130)
* add a test

* match all but whitespaces inside object keys

* exclude square brackets

* make one char possible as key

* allow any character

* fix everything
2020-01-21 17:48:53 +01:00
Daniel Grossmann-Kavanagh
154d367a9e use yaml.BaseLoader in test to remove warning 2019-12-11 18:16:15 -08:00
Daniel Grossmann-Kavanagh
c672c85c00 add tests for reverse proxies 2019-12-11 17:58:15 -08:00
Jyhess
d18c387d94 Return tuple for aiohttp (#849)
* Support aiohttp handlers to return tuples

* Minor update from #828 review

* Factorize more code between Flask and AioHttp response

* Fix CI

* Drop six string types

* Standardize response logging

* Handle one-tuples that only contain data

* clean up a couple of type hint comments

* Add a few more get_response tests

* Adjust _prepare_body interface to simplify improving _serialize_data

Rename _jsonify_data to _serialize_data to make its purpose easier to
understand (this was also known as _cast_body in aiohttp_api).

In exploring how to harmonize json serialization between aiothttp and
flask, we needed to be able to adjust the mimetype from within
_serialize_data. Harmonizing the actual serialization has to wait until
backwards incompatible changes can be made, but we can keep the new
interface, as these functions were introduced in this PR (#849).

* Add deprecation warnings about implicit serialization
2019-12-11 12:54:44 +01:00
Fabian Wollert
54e50f2278 handle deepObject and explode: true (#971)
* first implementation draft

* gitignore virtualenv

* use isinstance instead of type function

* fix tests

* remove unused function

* move object parsing to uri_parsing.py

* remove not needed import

* only test for OpenAPI

* remove not needed import

* make it work for other cases again

* flake8 fixes

* python2.7 fixes

* isort fix

* address code review comments

* remove for loop and address other comments

* remove not needed abstract function

* move array unnesting into uri_parsing

* make nested arrays possible

* style fixes

* style fixes

* test other data types

* comment and simplify function

* WIP: start additionalProperties test

* test additionalProperties

* remove uneccessary exception

* set default values

* set default values also in response

* flake8 fixes

* fix test

* use suggestions from dtkav's branch

* fix tests partially

* fix tests partially

* fix tests

* fix tests

* add comments for clarity
2019-10-15 17:36:58 +02:00
João Santos
1bda0659d5 Fix broken tests (#933)
* Remove extra space in error.

* Fix tests due to new behaviour of external dependencies
2019-05-05 19:38:42 +02:00
Christoph Ziebuhr
cca92c0777 Fix passing empty object body (#815)
Having a json request with an empty object body `{}` resulted in having `None` passed as body argument.
2018-12-18 08:27:10 +01:00
João Santos
44ea9336fe 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
2018-11-05 14:50:42 +01:00
Pavel Melnikov
6675ccc800 Fix body validator different error codes for bad Content-Types. (#629)
Fixes #628 .

 - Added a test for this bug.
 - Fixed it by checking for non-empty HTTP POST payload by considering request.body, request.form and request.files (only request.body was checked)
2018-08-14 13:22:03 +02:00
Pavel Melnikov
0c352cd4da Correct validator response on bad JSON (#610)
* report 400 Bad Request if validation fails to parse JSON while Content-Type is json.
2018-07-10 09:43:44 +02:00
John Krukoff
94f64b80e1 Allow http.HTTPStatus enums as response status codes. (#504)
* Allow http.HTTPStatus enums as response status codes.

Python 3.5 introduced a new enumeration "http.HTTPStatus" for
representing HTTP response status codes. The default response validation
introduced in connexion 1.1.12 highlighted the fact that connexion does
not natively support this type and was previously silently ignoring
non-integer status code representations.

This modifies the response validation code to extract the value when
given an enum instead of an int. Somewhat hacky test code is added to
check for enum support on python versions that include
"http.HTTPStatus".

* [master]: Restructure tests from PR comments.

* [master]: Revert to exception based version checking.

This reverts to exception based python version checking for both tests,
due to the suggested unittest skipping alternative not being supported
in all python versions.

"unittest.case.SkipTest: Not supported in this version" is the error
reported.

* [master]: Move enum handling deeper into the stack.

* [master]: Respond to yet more PR comments.
2017-10-05 09:08:59 +02:00
Fiete Gruenter
07ce38b484 Move import to top level. 2017-08-15 09:09:12 +02:00
Fiete Gruenter
ee72325345 Implement hacky workaround for passing environ to test_client.open() for no-content-type-test since old flask<=0.12.2 does not support it. 2017-08-04 09:30:25 +02:00
Fiete Gruenter
bf66cc726d Add a test that posts a requests without sending Content-Type in the header. 2017-08-03 12:43:48 +02:00
Tony Tung
6668835420 Validate responses against the default response field if the code is not found. (#487) 2017-07-20 22:58:22 +02:00
Kyle Cacciatore
1f34e3565b 449 path format (#450)
* added test for path formatted parameters

* re-added removed test, as it would generate valid flask route
2017-05-10 22:04:48 +02:00
Rafael Carício
93c06711ed New style of passing options to Connexion (#436)
* Order classes by relevance in module

* Order definitions by relevance within module

* Swagger UI options extracted

* New style options

* Use new-style options

* Reuse code

* Sort imports

* Ignore typing imports

* Warn users about parameter name change

* Add back isort check

* Fix isort check
2017-04-11 16:47:21 +02:00
Landon
6f567ee4de Fix returning flask Response objects in a tuple (#425)
* Fix returning Response objects in tuple with status code and/or headers

* Use flasks code for dealing with tuples instead of my own

* Unit tests for returning flask reponse in tuple

* fix test, should be a dict, not a set

* Properly sort imports
2017-04-04 20:11:03 +02:00
Diogo
5857dd237f Uncouple all flask functions from base code.
removed test_decorators and test_parameter (this test is useless now);
removed the request/response containers and add new request response classes;
created a abstract api class and a api flask class;
derived classes will implements the get_response/get_request methods that will convert framework req/resp types to connexion req/resp types;
moved the jsonifier from produces to flask api;
created a abstract app class and a app flask class;
changed all validators to use the ConnexionRequest instead flask request;
changed the problem function to generate a ConnexionRequest;
created a new user variables container called context (this is a property of ConnexionRequest). this will be passed as kwargs to all operations functions;
this context is used on authentication;
fixed all tests to new API;
some changes that I did may not be documented in this commit.
2017-04-04 08:20:24 -03:00
Leena Bhegade
f12ff8e3f3 Add Test Cases for unicode string
Add test cases
2017-02-11 16:48:40 +00:00
Leena Bhegade
f7b3d9a0bb add parameter to decode 2017-02-08 23:48:04 +00:00
Leena Bhegade
c1020bf0f6 Fix tests 2017-02-08 21:31:35 +00:00
Jeffrey Slort
0e9a78ffb1 removed "weird+json" test case 2017-02-08 19:49:51 +01:00
Jeffrey Slort
03e1405db4 Improved error messages when using an Invalid Content-Type header for the posted data
Added tests for content-type check
2017-02-08 19:49:51 +01:00
Rafael Caricio
3b5bb13276 Refactor code to fix confusion with returned values 2016-12-10 19:54:27 +01:00
Elisey Zanko
1fb776ebbd Errors fixed 2016-09-29 11:15:25 +05:00
Elisey Zanko
58da2b308d Fix a string issue 2016-09-29 10:35:58 +05:00
Elisey Zanko
91aeb691c7 Add a test 2016-09-29 10:25:05 +05:00
Jens Finkhaeuser
3cd04f8b8d Add test cases for the resolver_error flag. That's what it should do,
next up: the implementation.
2016-09-09 11:52:05 +02:00
Rafael Caricio
a2fc4a8343 Validate accordingly with content-type defined in spec 2016-04-04 17:35:27 +02:00
Rafael Caricio
a68867be06 Support for custom JSON encoders as in any Flask app 2016-03-31 16:03:40 +02:00
Rafael Caricio
2fec6e9259 Leave body param validation to external lib 2016-02-25 14:49:19 +01:00
Rafael Caricio
b60646e047 Reorganizing tests 2016-02-25 14:49:19 +01:00