Commit Graph

27 Commits

Author SHA1 Message Date
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
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
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
Daniel Grossmann-Kavanagh
2f074998e3 URI parsing decorator (#613)
- array logic refactored into one place.
- validation.py and parameter.py no longer try to join the array, and the split it again.
- validation of defaults now works, because the validator is given the correct type.
- some additional classes that change the behavior of deduplicating query parameters that are defined multiple times
  - **AlwaysMultiURIParser** that is backwards compatible, warts and all (used by default)
  - **Swagger2URIParser** that adheres to the spec's definition of `collectionFormat: multi` and uses the last-defined query parameter value (ex. `query?a=1&a=2` => `a = 2`)
  - **FirstValueURIParser** that behaves like Swagger2URIParser, except that the first-defined value is used (ex. `query?a=1&a=2` => `a=1`)
2018-07-09 11:06:24 +02:00
Lance Hannestad
f36c24685b Preserving the multiplicity of array type query parameters (#500)
* Preserving the multiplicity of array type query parameters

* Resolved failing tests, and refactored code block into a method

* Added tests for multi array

* Refactored parameter.py and updated tests in test_parameters.py
2017-09-08 15:18:47 +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
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
Dan Ballance
702142ec48 Fixes #340 | Convert camelcased parameter names to Python style 2017-03-09 16:42:17 +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
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
Rafael Caricio
c02fad46f7 Fix import ordering 2016-09-13 11:12:45 +02:00
Henning Jacobs
b5cd358b4f #270 add test for kwargs 2016-09-01 12:06:04 +02:00
Dylan Semler
b7c6dede95 Add flag for strict_validation on extra parameters 2016-07-31 20:21:19 -04:00
Dylan Semler
f1d436c859 Validate that requests don't have extra parameters
Request validation is enhanced to verify requests only include query or
formData parameters that are specified in the spec.

This validation does not occur for header or path parameters.  This is
because most applications probably prefer to ignore extra headers and
a request with extra path parameters would point to a different
endpoint.
2016-07-31 20:17:30 -04:00
Greg Brockman
a6cc07cca8 Make JSON printing a bit nicer 2016-04-04 21:59:54 -07: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
David Hotham
75fe338937 Python3 compatibility 2016-03-29 12:21:31 +01:00
David Hotham
c3ced5fc2d Add validation of formData parameters 2016-03-29 11:58:33 +01:00
David Hotham
604e7274f1 Unit tests for file uploads 2016-03-29 10:09:56 +01:00
Rafael Caricio
75c94a428b Support x-nullable in body parameters 2016-03-25 19:31:33 +01:00
Rafael Caricio
7052ff3722 Support x-nullable parameters 2016-03-25 18:07:35 +01:00
João Santos
625c60beaa #173 Fix unpythonic function names 2016-03-08 08:33:46 +01:00
Rafael Caricio
2558a611f4 #104 typecasting in path parameters 2016-03-04 18:41:57 +01:00
Rafael Caricio
a7aec5d53c Split tests in isolated modules 2016-02-25 14:49:19 +01:00