32 Commits

Author SHA1 Message Date
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
Robbe Sneyders
fb44e6acb4 Fix import order for isort 2021-06-25 13:08:46 +02:00
jlaba
16a896cdbf Switched from mock to unittest.mock (#1218)
* Switched from mock to unittest.mock

* Update test_validation.py

Removed mock comment

* Update test_parameter.py

Removed comment for mock

Co-authored-by: Joachim Langenbach <joachim.langenbach@engsas.de>
2020-04-23 22:59:41 +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
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
Daniel Grossmann-Kavanagh
fdac62726d Use server_spec option in cli.py instead of swagger_ui (#745)
- gets rid of deprecation warning when using `connexion run ...` (Fixes #747)
2018-11-07 08:34:47 +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
Henning Jacobs
bbff57ca6e fix wording 2018-04-09 21:25:17 +02:00
Diogo Dutra
8f4ff0313d Changes for aiohttp support:
- Created a metaclass for AbstractAPI (it is used to set the jsonifier for the class);
 - Created a new class method AbstractAPI._set_jsonifier;
 - Changed the code to use the new jsonifier interface;
 - Create a new module called coroutines_wrapper to put the wrapper functions with the 'yield from' statement. It is used to enable frameworks with coroutine handlers;
 - Did the AioHttpApi.get_request coroutine and add req.read() to get the request body;
 - Moved the flask jsonifier to utils and did it a generic jsonifier;
 - Created a function called 'has_coroutine' on utils module;
 - Added aiohttp_jinja2 to requirements-aiohttp;
 - Added a new python3 coreragerc file to skip only python2 lines;
 - Fixed the set of validation_response on test_aiohttp_simple_api.py;
 - Added the test to check the aiohttp body request;
 - Fixed the response for 'aiohttp_bytes_response' and 'aiohttp_non_str_non_json_response' paths on aiohttp/swagger_simple.yml file.
2018-02-05 13:35:56 -02:00
Diogo Dutra
1408dbeb19 Added an aiohttp lib validation on cli 2018-01-18 14:27:08 -02:00
Diogo Dutra
09daab63ca Changed the cli script:
- created a new option called 'server'
 - did wsgi-server option deprecated
 - changed the app-cls option to app-framework
 - fixed the possible frameworks that will run the app
 - added a validation on framework/server selection
2018-01-18 14:27:08 -02:00
Diogo Dutra
f24ca441dc Changes did on the base code to support aiohttp
- Added the AioHttpApi and AioHttpApp on connexion __init__;
- Created an abstract method on AbstractApi to cast the framework response to connexion response;
- Implemented the get_connexion_response on FlaskApi;
- Changed the CLI to use any kind of App class;
- Changed the ResponseValidator to always convert the response to a connexion response;
- Changed the ResponseValidator to support coroutine responses;
- Added the aiohttp as optional dependency;
- Added ujson as optional dependency;
- Skipped the aiohttp tests run on python 2.7;
- Changed the tests configs to run aiohttp tests properly on python 3.4+.
2018-01-18 12:53:58 -02:00
Rafael Caricio
6746cb2be8 Fix mocking API partially 2017-06-30 16:46:26 +02: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
Yoan Blanc
be437a980b Fix isort checks 2016-10-16 11:32:11 +02:00
Victor Torres
90712d1f8c Receiving --host or -H option via CLI and writting test cases.
We’re using -H instead of -h in order not to be confused with help arguments.
Fabric also uses -H as host parameter.
2016-10-09 13:11:54 -03:00
Henning Jacobs
ff5596aab1 #292 fix comment 2016-09-30 11:48:23 +02:00
Henning Jacobs
1f25b0dc0c #292 test run with --mock 2016-09-30 11:48:02 +02:00
Havoc Pennington
8a67a3bf3f Add a --base-path option to the CLI
This allows deploying at different paths without
editing the API spec.
2016-09-22 16:48:07 -04:00
Rafael Caricio
871fd3ef6f Print version using the CLI 2016-09-17 15:03:11 +02:00
Rafael Caricio
d71674b35b Make sure very verbose is the same as debug 2016-09-15 10:29:00 +02:00
Rafael Caricio
c1d55c1116 Support different log levels in CLI 2016-09-15 10:25:22 +02:00
Rafael Caricio
9b7cb99318 Check that all options are passed correctly from the CLI module 2016-09-15 09:53:58 +02:00
Rafael Caricio
07c6eb7b8a Fix parameters in the CLI interface 2016-09-14 21:06:17 +02:00
Rafael Caricio
d9b59c65ac Fix imports 2016-09-13 22:44:15 +02:00
Rafael Caricio
8ef5794df8 Merge master into cli branch 2016-09-13 22:33:41 +02:00
Rafael Caricio
e7f96e4bd9 Sort imports 2016-09-13 00:11:43 +02:00
Rafael Caricio
82dcb617a9 Pass along all options available 2016-09-12 23:18:22 +02:00
Rafael Caricio
9c5f6bcd8a Refine stub option 2016-09-12 22:58:38 +02:00
Rafael Caricio
e9d5a61437 Run with specification stubs 2016-09-12 21:55:47 +02:00
Rafael Caricio
c74d8cdd3b Provide CLI support for runnning specifications 2016-09-12 18:28:14 +02:00