Commit Graph

1169 Commits

Author SHA1 Message Date
Jan Sochor
0e54dcacd0 Import from collections.abc to support Python 3.8 (#1059) 2019-10-27 23:01:57 +01:00
Tomasz Trębski
ec37d03902 Drop Python 2.7 support (#1058)
* Drop 2.7

* fixup! Drop 2.7

* fixup! Drop 2.7
2019-10-27 23:01:23 +01:00
Svendegroote91
e06ec6da82 #594 & #816 - Add error path to schema validation error in RequestBodyValidator (#1063)
* Add error path to schema validation error in RequestBodyValidator

* Add unit test for error path in schema validation
2019-10-27 12:07:12 +01:00
Henning Jacobs
26843462d9 add SECURITY.md (#1060) 2019-10-24 10:59:29 +02: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
Henning Jacobs
c8d8973c7e drop Python 3.5, add 3.8 (#1056)
* drop Python 3.5, add 3.8

* remove old pypy 2.7 (no longer available on 18.04)
2.4.0
2019-10-18 13:32:43 +02:00
rgmerk
c94fa6127a Instructions for deploying on modwsgi (#1018) 2019-10-18 12:41:39 +02:00
Clemens Lang
7a1ce8d41a Support jsonschema >= 3.0.0 (#1050)
* setup.py: Support jsonschema >= 3.0.0

Other projects have started using jsonschema >= 3.0.0, and modern python
packaging tools such as poetry now fail to install projects using both
connexion and a different dependency if they depend on different
versions of jsonschema.

Allow jsonschema versions >= 3.0.0 to avoid this problem.

See: https://github.com/sdispater/poetry/issues/697

* Avoid warning when using jsonschema >= 3.0

jsonschema 3.0.0 changed the API to deprecate the types parameter of the
jsonschema.IValidator constructor and now raises a warning when using
it.

Avoid the warning by checking the jsonschema version and switching to
the new way to implement this when it is >= 3.0. Note that while
jsonschema 2.x did have jsonschema.validators.extend, it did not support
the type_checker argument, so the same code cannot be used with
jsonschema 2.x.
2019-10-18 12:38:09 +02:00
Stephen Hurwitz
43003f8666 Fixes util.deep_get when obj is a list (#1055)
* Fixes util.deep_get when obj is a list

The example below will seem strange. It's the result of distilling a complex
API spec down to the root cause of the issue.

```yaml
---
openapi: 3.0.0
info:
  version: v0
  title: Repo an error
  description: Extremely contrived, but it illustrates the problem
paths:
  /:
    get:
      operationId: app.get
      responses:
        '200':
          description: Just for giggles
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SomeWeirdResource"
components:
  schemas:
    Resource:
      allOf:
        - type: object
          properties:
            id:
              type: string
    SomeWeirdResource:
      allOf:
        - type: object
          properties:
            id:
              $ref: '#/components/schemas/Resource/allOf/0/properties/id'
```

While convoluted, this is a valid OpenAPI 3 spec.

```sh
$ yarn swagger-cli validate openapi/my_api.yaml
yarn run v1.17.3
$ /[redacted]/node_modules/.bin/swagger-cli validate openapi/my_api.yaml
openapi/my_api.yaml is valid
  Done in 0.23s.
```

`utils.deep_get` assumes the obj to be a dictionary when it can also be a list.

* Updates docstring for utils.deep_get

Comment on the pull request was asking for an explanation to clarify the
code. The updated docstring aims to be clear on how exactly the object
can be a list.
2019-10-16 18:05:23 +02:00
Jacob Floyd
bd2552c313 Fix aiohttp upgrade (#951)
* Revert "set max aiohttp version to 3.5.1 (until build is fixed) (#844)"

This reverts commit b2a4287405.

* Fix test_run_with_aiohttp_not_installed

Somewhere between 3.5.1 and 3.5.2, the aiohttp reimport started
succeeding (in connexion.connexion.cli.run()). It's not clear which
change caused the issue, but it's probably one of:

- aio-libs/aiohttp#3469 (Remove wildcard imports)
- aio-libs/aiohttp#3464 (Don't suppress gunicorn cleanup errors)
- aio-libs/aiohttp#3471 (Refactor workers)
- aio-libs/aiohttp#3500 (Ignore done tasks)

In any case, setting sys.modules['aiohttp'] = None should prevent
reimporting it. See: https://stackoverflow.com/a/1350574

I successfully tested locally on py37 with aiohttp 3.5.1 and 3.5.2.
2019-10-15 18:42:28 +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
Asbjørn Apeland
485380d54f Document how to set Swagger UI path (#1051) 2019-10-09 18:28:14 +02:00
Albert Suarez
1a9db69583 Fixed [connextion] typo in documentation page (#1049) 2019-10-08 14:00:16 +02:00
Cole Sutera
2c810748c0 Updated readme (#1009)
A few typos uri_parsing_class instead of uri_parser_class in options example.
2019-09-25 19:21:09 +02:00
Patrick Wang
7111bc91ee fix deprecated import (#1044) 2019-09-20 08:41:42 +02:00
Mariusz Kupidura
b05bf6e292 Add validation of cookie parameters. (#997)
Validate parameters stored in cookies in similar manner that we validate
parameters passed in headers.
2019-07-13 11:28:50 +02:00
Tomasz Trębski
042174a585 Fix travis deprecation (#988) 2019-07-13 11:27:34 +02:00
Christian Siegel
d5699cc897 Mention pythonic_params in request docs (#947) 2019-07-11 13:12:33 +02:00
Tomasz Trębski
123c5c9fbd Remove Python 3.4 (#990)
* EOL Python 3.4

* fixup! EOL Python 3.4

* fixup! EOL Python 3.4

* fixup! EOL Python 3.4
2019-07-09 13:53:44 +02:00
Tomasz Trębski
f99e39b780 Bump flask to be at least 1.0.4 (#995)
* Bump flask to be at least 1.0.4

Reasons:
- `flask==0.10.1` was released in 2013, which makes it quite old thus unsupported.
- On Flask webpage you can find an information pointing to `1.x` branch as latest stable
- different tools, including these used in `connexion` progressed leaving Python versions, for which `flask<1.0` has been developed.

* match instead of message
2019-07-09 13:17:48 +02:00
Jacob Floyd
890fe9a171 Respond with problems by default in aiohttp. (#952)
* Respond with problems by default in aiohttp.
2.3.0
2019-06-14 09:07:07 +02:00
Pavel Zalunin
d31cb55abf Fix uwsgi metric collection (#972) 2019-06-12 09:58:59 +02:00
Dan Walker
d24a8e2579 Update request.rst (#953)
Fix duplication
2019-06-07 12:01:51 +02:00
Paweł Wamej
0a05243c6e fix typo in README (#959)
- fix import typo in code sample to reduce confusion
2019-05-25 13:16:32 +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
Daniel Grossmann-Kavanagh
1e6aead70a Fix swagger console backslash redirect for aiohttp (thanks @pando85) (#843)
Fixes #831 

Changes proposed in this pull request:
 - redirect ui -> ui/ for aiohttp
2019-03-25 12:29:55 +01:00
Spencer Herzberg
10839dfca8 fix strict_validation debug log variable (#881)
The log message for `strict_validation` uses the incorrect variable in the log format. This PR fixes that.
2019-03-17 16:00:50 +01:00
Daniel Grossmann-Kavanagh
d3d1836c82 bump PyYAML to 5.1 for CVE-2017-18342 (#902) 2019-03-15 13:24:04 +01:00
Daniel Grossmann-Kavanagh
08e4536e5e bump and pin isort, apply all automatic fixes (#903)
Fixes the build.

Changes proposed in this pull request:
 - apply all of the isort changes that resulted from the latest version
 - pin to the latest version (4.3.15) so this doesn't happen again, unless we bump the version on purpose
2019-03-15 13:04:33 +01:00
Spencer Herzberg
0989a93df5 fixes basic auth example doc; adds apikey example (#894)
* fixes basic auth example doc; adds apikey example

* remove required_scopes references that dont pertain to apikey
2019-03-11 08:22:37 +01:00
Jyhess
34c7cb160f Remove AioHttp deprecation warning (#856)
[debug argument is deprecated](https://github.com/aio-libs/aiohttp/issues/2859) for AioHttp.
Remove it to remove deprecation warnings in logs.
2019-02-04 13:56:55 +01:00
Daniel Grossmann-Kavanagh
f32c8444a1 Pin flake8 to avoid needing to import any types mentioned in type hints (#867)
Flake8 now requires you to import anything mentioned in a type hint comment. This is extra annoying to reconcile across python versions.
2019-02-04 13:03:19 +01:00
Simon
92867452a2 Added MethodViewResolver (#847)
* Added MethodViewResolver

By subclassing RestyResolver and modifying its `resolve_function_from_operation_id` method, it is now possible to use automatic routing functionality with Flask's MethodView together with MethodViewResolver.

* Add MethodView example

* Add tests for methodview

* add documentation on how to use MethodViewResolver
2019-02-04 08:25:27 +01:00
Roberto Polli
b18d8b9528 Serve yaml spec. (#842)
* Fix: #772. Serving yaml spec.

Serve yaml spec with a yaml prettifier. Uses a separate method for
doing the job and does not modify the openapi_json one.
2019-01-24 08:31:02 +01:00
jbskytap
a5dfbb8984 Fix typo (#845) 2019-01-14 08:45:32 +01:00
lynxknight
fda2b18b38 AioHttpApi oauth middleware should catch all OAuth problems (#830)
Fixes #829

* aiohttp openapi basic auth testing

* let oauth_problem_middleware recognize all OAuth exceptions

* scope problem should return 403

* excepting two classes makes more sense than subclassing hacks
2019-01-14 08:44:54 +01:00
Daniel Grossmann-Kavanagh
b2a4287405 set max aiohttp version to 3.5.1 (until build is fixed) (#844) 2019-01-10 08:51:27 +01:00
Dmitriy
a0ac0fd13f Added OpenAPI 3 getting API Key from cookie support. (#794)
* Added OpenAPI 3 getting API Key from cookie support.
2.2.0
2018-12-18 11:13:11 +01: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
Daniel Grossmann-Kavanagh
9b76bbc8fc fix openapi3 path and query validation and tests (#821) 2018-12-18 09:15:33 +01:00
Daniel Grossmann-Kavanagh
d8cd116154 fix docs on adding error handler (#818) 2018-12-18 08:28:06 +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
Jyhess
78bea62279 Fix case sensitive headers (#825) 2018-12-18 08:24:59 +01:00
Daniel Grossmann-Kavanagh
1afdc77219 fix up array style defaults (#803)
Fixes #801 

 - include the default array parsing styles from the openapi 3.0.2 spec
2.1.0
2018-12-11 09:13:10 +01:00
Diogo Dutra
03a0febbf9 Fixed aiohttp test client deprecation messages. (#810) 2018-12-11 08:50:46 +01:00
Phil Sturgeon
fc8e018a8b Swagger -> OpenAPI (#813) 2018-12-11 08:30:15 +01:00
Diogo Dutra
9bef8c46a6 Removed duplicated calls of get_response method of the Api classes (#809)
On Operation decorators lifecycle the api.get_response method were always called twice.
Because the response validation, we need to cast the response to the ConnexionResponse type.
But the response casting could be made on the response validation decorator, not always. So, changes were made to cast the response correctly.
The BeginOfRequestLifecycleDecorator class was removed because it only do the second call of api.get_response method. This second call only occurs if the response validation is needed.
For a more logical naming, the EndOfRequestLifecycleDecorator class was renamed to RequestResponseDecorator.
Fixes #664
2018-12-11 08:28:58 +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
Chris Kyrouac
cfae46fb22 Change can_read_body to body_exists in AioHttpApi.get_request (#738) 2018-11-28 11:54:00 +01:00
Daniel Grossmann-Kavanagh
f6dfeefbc6 fix cli --stub (#800)
Fixes #796
2018-11-28 11:30:58 +01:00