* 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.
* 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.
* 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.
* 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.
* 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
* 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
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
* 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
* 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.
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
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