75 Commits

Author SHA1 Message Date
Robbe Sneyders
3e64fe46e9 Fix ReverseProxied middleware and add docs (#1873)
Starlette introduced some new changes to how the `root_path` is handled,
which broke our `ReverseProxied` example and test.

This PR fixes both and adds documentation on how to run behind a proxy.
2024-02-11 22:19:37 +01:00
Robbe Sneyders
cbeac6f2c1 Update security docs (#1764)
Contributes to #1531
2023-10-31 20:08:04 +01:00
Robbe Sneyders
3ef9a76590 Remove debug argument from example (#1749)
Small fix
2023-10-22 22:41:21 +02:00
Robbe Sneyders
5ecbf00f29 Add test for multiple float path parameters 2023-02-18 01:15:24 +01:00
Robbe Sneyders
1211d1b655 Enable enforcing defaults (#1616)
This PR is a proposal to enforce defaults in json bodies.

The standard JsonRequestBodyValidator does not adapt the body. Instead, I added a DefaultsJsonRequestBodyValidator which does. The user can easily activate enforcing default by passing this Validator in a validator_map.

I would have liked connexion to have an enforce_defaults flag, but it would be hard to make this compatible with the validator_map argument.
2023-01-26 15:08:27 +01:00
Robbe Sneyders
edb0381af3 Implement user facing interface for ConnexionMiddleware (#1621)
This PR adds an interface for the ConnexionMiddleware, similar to the
interface of the Connexion Apps.

The Connexion Apps are now a simple wrapper around the
ConnexionMiddleware and framework app, delegating the work to the
middleware. This enables a similar interface and behavior for users when
using either the middleware or apps.

The arguments are repeated everywhere there is a user interface, but are
parsed in a central place. Repeating the arguments is not DRY, but
needed to provide users with IDE autocomplete, typing, etc. They are
parsed in a single `_Options` class, which also provides a mechanism to
set default options on an App level, and override them on the more
granular API level.

This makes the long list of provided parameters a lot more manageable,
so I would like to use it for the `Jsonifier` as well, and re-add the
`debug` and `extra_files` arguments which I have dropped in previous
PRs. I'll submit a separate PR for this.

I renamed the `options` parameter to `swagger_ui_options` since it only
contains swagger UI options. This is a breaking change though, and we'll
need to highlight this upon release.

We still have quite a lot of `App`, `MiddlewareApp`, and abstract
classes. It would be great if we could find a way to reduce those
further, or at least find better naming to make it more clear what each
one does 🙂 .

Finally, I added examples on how the middleware can be used with third
party frameworks under `examples/frameworks`. Currently there's an
example for Starlette and Quart, but this should be easy to extend. They
also show how the `ASGIDecorator` and `StarletteDecorator` from my
previous PR can be used.
2023-01-26 14:40:29 +01:00
Robbe Sneyders
073f0d446e Update examples for Connexion 3.0 (#1615)
This PR updates the examples for Connexion 3.0 and merges them for
OpenAPI and Swagger.

2 examples required some changes to make them work:
- The reverse proxy example required some fixes to the
SwaggerUIMiddleware to leverage the `root_path` correctly. This is
included in the PR.
- The enforced defaults example requires the json validator to adapt the
body and pass it on. We currently pass on the original body after
validation, and I'm not sure if we should change this. I'll submit a
separate PR to discuss this.
2022-12-30 20:34:19 +01:00
Robbe Sneyders
5a0c292b44 Add async app 2022-12-26 20:51:46 +01:00
Leonardo Festa
fc003ca140 Removed internal variable pass_context_arg_name (#1568)
* Removed internal variable pass_context_arg_name

* fixed issue with personalized context name in tests

* restored code from pr suggestion

* restore decorator functionality

now the function accept a pass_context_arg boolean parameter,
instead of the pass_context_arg_name value

* Fixed security test checks, now passes tests

* Removed pass_context_arg, fixed security handler

fixed security handler as suggested
removed pass_context_arg as before

* Fix context injection test

Co-authored-by: Niels Dewulf <87133686+nielsbox@users.noreply.github.com>
Co-authored-by: Robbe Sneyders <robbe.sneyders@ml6.eu>
2022-09-22 22:53:25 +02:00
Robbe Sneyders
600ed4ed94 Format files with black 2022-06-25 23:50:52 +02:00
Nico Braun
3c6e13c1c1 call as_view in methodresolver (#1552)
* call as_view in methodresolver

Signed-off-by: Nico Braun <rainbowstack@gmail.com>

* allow to use deprecated method view resolver

Signed-off-by: Nico Braun <rainbowstack@gmail.com>

* update method view example

Signed-off-by: Nico Braun <rainbowstack@gmail.com>

* update method view docs

Signed-off-by: Nico Braun <rainbowstack@gmail.com>

* fix pre-commit issues

Signed-off-by: Nico Braun <rainbowstack@gmail.com>
2022-06-24 17:55:11 +02:00
Robbe Sneyders
ca70b16ff5 Drop aiohttp support (#1491) 2022-03-22 22:26:41 +01:00
Andrey Abramov
87a0fed4dc Remove obsolete code from basicauth example (#1486)
* Remove obsolete code

* Remove scopes completely

* Add hinting

* Remove outdated function from docs/security

* Revert "Add hinting"

This reverts commit faeea24c28bf88eead4015feea8f4dbd750cec1c.

* Change README for examples and other review fixes
2022-03-16 20:20:44 +01:00
Pavol Vargovčík
a6717c3bbf Enforcedefaults aiohttp (#1163)
* cache ConnexionRequest.json

* add openapi3 enforcedefaults_aiohttp example

Co-authored-by: Robbe Sneyders <robbe.sneyders@ml6.eu>
2022-02-23 22:31:41 +01:00
Amin Alaee
69e289bb77 Update basicauth example (#1411) 2021-08-11 09:30:43 +02:00
Christian Clauss
1012721d2d Upgrade isort==5.9.1 (#1388)
* Upgrade isort==5.9.1

* isort --thirdparty connexion,aiohttp ./tests

* isort --thirdparty aiohttp,connexion --check-only --diff .

* cd tests before running isort
2021-07-07 12:43:36 +02:00
Robbe Sneyders
41cc0cb73e Merge pull request #1303 from cuongqn/bugfix/reverseproxy-example
Fix reverseproxy example for OpenAPI 3
2021-07-05 19:30:24 +02:00
Christian Clauss
6c4f99051d Upgrade syntax for Python >= 3.6 (#1383)
* pyupgrade --py36-plus **/*.py

* Fix indentation

* Fix indentation
2021-07-04 20:04:22 +02:00
Christian Clauss
a46b66abcb Fix typos discovered by codespell (#1385)
* codespell --ignore-words-list="connexion"

* Update exceptions.py
2021-07-04 19:28:37 +02:00
Christian Clauss
ee38dbffa8 Deep six the six module 2021-07-04 12:33:58 +02:00
Robbe Sneyders
fb44e6acb4 Fix import order for isort 2021-06-25 13:08:46 +02:00
Cuong Nguyen
aa716ebbfe Update variable name in during .run() call 2020-10-12 14:14:41 -07:00
Jiehong
a21dd62b82 doc: improve documentation for Basic Auth 2020-07-20 07:20:37 +02:00
Sławomir Zborowski
bed4b95205 #1182 get rid of @asyncio.coroutine (deprecated in Python 3.8) (#1186)
Signed-off-by: Sławomir Zborowski <slawomir.zborowski@nokia.com>
2020-04-25 16:30:21 +02:00
Daniel Grossmann-Kavanagh
e85960947f Merge branch 'master' into dynamic_ui_path 2019-12-17 11:42:35 +11:00
Roberto Polli
9fdd9587e6 Fix: #910. Add swagger-ui to requirements. Update connexion version. (#911) 2019-12-12 18:29:09 +01:00
Daniel Grossmann-Kavanagh
d0efe57433 fix deprecated logging.warn calls in reverse proxy examples 2019-12-11 18:23:08 -08:00
Julien Sagnard
a6496975de Improve with PR comments 2019-12-11 17:59:43 -08:00
Daniel Grossmann-Kavanagh
c672c85c00 add tests for reverse proxies 2019-12-11 17:58:15 -08:00
Daniel Grossmann-Kavanagh
2b23b75ce0 add aiohttp reverse proxy example 2019-12-11 17:58:15 -08:00
Daniel Grossmann-Kavanagh
93fe858922 add reverseproxy example 2019-12-11 17:58:15 -08: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
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
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
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
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
08faf2aa86 disable threading in sqlalchemy demo (in-memory db) (#709)
- disable threading in sqlalchemy demo
2018-10-04 14:55:30 +02:00
Daniel Grossmann-Kavanagh
5bc8a788aa fix 500 in sqlalchemy example (#581) 2018-04-27 08:13:30 +02:00
Henning Jacobs
a64884075e README for local validation 2018-01-13 18:28:27 +01:00
Maico Timmerman
a17caefd8e Added option for local function token lookup. 2018-01-10 22:59:06 +01:00
Mohab Usama
a275f7b0e2 Use Authorization headers for verifying token info (#542)
* Use Authorization headers for retrieving token info

* Fix flake8

* Adjust token info example

* Only accept Authorization headers in test
2017-11-14 18:13:41 +01:00
Mikko Valkonen
dedc5d1450 fix the enforcedefaults example
The enforcedefaults example did not run as the port (9090) was passed as
the server parameter.
2017-08-16 11:38:42 +03:00
Mikko Valkonen
3833cb10e7 fix the helloworld example
The helloworld example did not run as the port (9090) was passed as the
server parameter.
2017-08-16 11:38:37 +03: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
Diogo Dutra
5cc848f3e3 fixed missing method parameters and trailling spaces 2017-04-04 08:20:24 -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
Diogo Dutra
a7af62fbf0 Uncouple flask from App and Api. Created Abstract classes for theses modules. Fixed the tests 2017-04-04 08:20:23 -03:00
Petr Horáček
e166d0fea5 add documentation for custom validators 2016-12-04 13:07:21 +01:00
Henning Jacobs
da30971792 #292 add example mock Swagger YAML (without any operation IDs) 2016-09-29 11:43:23 +02:00
Henning Jacobs
2b5f857e51 #292 add --mock option to return example data 2016-09-29 11:14:36 +02:00