Commit Graph

108 Commits

Author SHA1 Message Date
Henning Jacobs
f55cb1c923 Merge pull request #1075 from mblaettler/feat/enable-empty-security
enable empty security definition
2020-01-06 13:39:20 +01:00
Michael Blättler
b14e235108 enable empty security definition
This allows to use optional authentication and provide different
responses to authenticated users via the same API-Endpoint.

Co-Authored-By: Jacob Floyd <cognifloyd@gmail.com>
2019-12-18 08:15:09 +01:00
Daniel Grossmann-Kavanagh
d287fcc4bd Revert "Fixes #510 in upstream: multiple file uploads via POST now work correctly. (#1000)" (#1101)
This reverts commit 4a1c69e372.
2019-12-13 08:30:49 +01:00
svetlana-v
50f640a33a Pop apiKey from query parameters in security decorator to fix #470 (#1077) 2019-12-11 12:49:40 +01:00
Jyhess
db4459fa20 Datetime serialization (#851)
* Add datetime and uuid serialization for AioHttp

* Remove ujson dependency

* fix merge error

* Retry CI

* remove bad jsonifier import

* remove ujson import
2019-12-03 05:23:36 +01:00
Davy Durham
9925789820 [#935] supporting application/json within multipart/form-data request body (#980)
* [#935] adding support to automatically decode json when a multipart/form-data contains a field with an application/json content-type

* Update connexion/decorators/uri_parsing.py

Co-Authored-By: Tomasz Trębski <kornicameister@gmail.com>

* Update connexion/decorators/uri_parsing.py

accepting other non-standard json content types too

Co-Authored-By: Tomasz Trębski <kornicameister@gmail.com>

* Update uri_parsing.py

syntax fix

* syntax fix

* fixes

* Adding unit test to verify that multipart/form-data values which are json objects are decoded and validated as such
2019-12-03 05:12:49 +01:00
Peter Bašista
738f47ed50 Do not sanitize body keys in OpenAPI 3 (#1008)
* Remove the unused "query_sanitazion" fixture

* Test whether no sanitization is performed in the request body

* Do not perform sanitization on request body keys in OpenAPI v3

The deserialized JSON form of the request body
needs to be passed to the client applications
* without further modification *
so that they can work directly with objects
that have been received over the network.
The only names for which sanitization makes sense
are the ones which are used as Python identifiers.

Keys of the top-level JSON object within the request payload
are never used by Connexion as Python identifiers.

Also, no such sanitization of keys within request body
is performed in OpenAPI v2.

Closes issue #835.
2019-12-03 05:01:49 +01:00
simondrabble
4a1c69e372 Fixes #510 in upstream: multiple file uploads via POST now work correctly. (#1000) 2019-11-05 10:08:17 +01:00
Brian Price
b0b83c4879 Converting response to raise a ProblemException (#955)
* Converting response to raise a ProblemException

* Centralizing around ProblemException for errors in the app.

* Adding the ability to skip error handlers, allow for defining exception payload.

* Fixing flake8

* Fixed some bugs found through unit testing.

* Unit tests are now passing.

* Added problem back to __init__

* Updating based on the feedback from the PR.
2019-10-24 10:59:05 +02: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
panpann
089840b0a2 add path to API only for HTTP operations (#817)
* add path to API only for HTTP operations
2018-12-18 09:58:54 +01: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
krise3k
b6530d32aa Fix handling additionalProperties in body (#789)
Currently when object is send as body parameter only properties defined in `properties` in body schema are passed to handler function. Additional keys are filtered out, which is opposite to [spec](https://github.com/OAI/OpenAPI-Specification/blame/3.0.2/versions/3.0.2.md#L2305). For me specification is counter intuitive :(

Changes proposed in this pull request:
 - If `additionalProperties` is not set or is `True`, all properties not defined in `properties` are passed without type casting.
 - If `additionalProperties` declares value type,  unknown properties are cast according to https://github.com/zalando/connexion#type-casting.

The best explanation for `additionalProperties` I found in https://github.com/OAI/OpenAPI-Specification/issues/668#issuecomment-218829120
2018-11-28 13:32:34 +01:00
krise3k
6ec11825b8 Add support for JWT authentication (#732)
* Add support for JWT

* Add example for JWT

* Add minimal JWT documentation
2018-11-12 08:53:50 +01:00
Daniel Grossmann-Kavanagh
53dffc0b78 Only pass body on PATCH/POST/PUT request (#761)
Fixes #757
2018-11-09 08:27:08 +01:00
Daniel Grossmann-Kavanagh
0c5ddd67e5 Pass files to handler if filename in arguments _or_ has_kwargs (#753)
- pass file if filename in arguments _or_ has_kwargs (Fixes #750)
2018-11-07 08:09:17 +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
Daniel Grossmann-Kavanagh
212820bf35 add more test cases for form params 2018-07-25 08:50:30 +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
Ronaldo Ferreira
f2923148f8 Fix UnicodeEncodeError for query-strings on Python 2 (#507)
* Fix UnicodeEncodeError for query-strings on Python 2

* Fix test for Python 3.4 and 3.5
2017-08-28 18:52:10 +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
63abcad512 Connexion request user (#435)
* Add back connexion.request

* Refactor code to lifecycle module

* Test user from connexion.request instance
2017-04-07 16:15:09 +02:00
Rafael Carício
067ad1b55a Flask request user support (#432)
* ConnexionRequest.context proxied to flask.request instance

* Add type annotations for FlaskRequestContextProxy

* Sort imports

* Sort imports

* Remove unnecessary code
2017-04-05 19:04:48 +02:00
Henning Jacobs
d9edc36647 Ignore context args (#429)
* #428 add unit test

* #428 ignore context param if not in function args

* #428 update OAuth2 example app

* #428 update security docs
2017-04-05 14:32:40 +02:00
Rafael Carício
1858c9d4a0 Flask required only if necessary (#424)
* Example with Flask support

* Only show import error when trying to use Flask

* Re-organize imports

* Move flask_utils next to related module

* Code style

* Change back to incentivizes

* Includes Flask by default

* Project clean up

* Update Rafael Caricio's e-mail address

* Fix conflicts
2017-04-04 20:48:08 +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 Dutra
2ddebfdbe2 did changes requested by isort-check 2017-04-04 08:20:25 -03: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
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
bce907f724 Problem as exceptions should convert properly to problem responses 2017-01-11 12:16:08 +01:00
Rafael Caricio
9b036923ec Fix annoying typo 2016-12-10 22:37:40 +01:00
Rafael Caricio
3b5bb13276 Refactor code to fix confusion with returned values 2016-12-10 19:54:27 +01:00
Michael Wild
b638b1168e Adds parameter name sanitization in parameters_to_args()
Without sanitization e.g. OData query parameters, such as $skip, $top,
$filter cannot be passed to the controller (except by use of **kwargs).

Fixes: zalando/connexion#334
2016-10-31 15:16:03 +01:00
Yoan Blanc
be437a980b Fix isort checks 2016-10-16 11:32:11 +02:00
Elisey Zanko
1fb776ebbd Errors fixed 2016-09-29 11:15:25 +05:00
Elisey Zanko
91aeb691c7 Add a test 2016-09-29 10:25:05 +05:00
Jens Finkhaeuser
bf49118dce Remove unused import that trips up flake8 2016-09-13 14:25:14 +02:00
Henning Jacobs
b5cd358b4f #270 add test for kwargs 2016-09-01 12:06:04 +02:00
Rafael Caricio
654df09838 #256 🎯 identify the bug 2016-07-27 22:57:23 +02:00
Rafael Caricio
e2b2a7cb5d #239 Fix to support new version of Flask 0.11 2016-06-03 13:24:26 +02:00
Arjun Naik
dba916c354 Fix for when parameter spec is unordered. 2016-05-17 16:29:32 +02:00
Rafael Caricio
e37c994956 Test custom values in problem response 2016-04-08 15:12:54 +02:00
Rafael Caricio
e73a2194d3 Simple test the case of a problematic json 2016-04-08 14:39:06 +02:00
Rafael Caricio
6358c8c47d Adopt isort to ensure better code quality 2016-04-08 14:33:27 +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
João Santos
ddcb4ce4a5 Merge pull request #197 from rafaelcaricio/accept-nullable-values
Support nullable parameters
2016-03-31 14:10:17 +02:00