Commit Graph

62 Commits

Author SHA1 Message Date
Mark Perryman
994f53fb04 Allow the specification to be specified as a URL. (#1871)
Changes proposed in this pull request:

- Allow a specification to be specified as a URL that is downloaded when
the App runs. In combination with the existing mock features, this makes
it a single command to run a mock server for any published API.

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@gmail.com>
2024-02-18 21:56:31 +01:00
Robbe Sneyders
0857710147 Only instantiate specification once (#1819)
Fixes #1801 

I had to make quite a few additional changes to satisfy mypy.
2023-11-30 23:59:26 +01:00
Robbe Sneyders
a210917b46 Drop Python 3.7 in favor of 3.11 and 3.12 (#1752)
Python 3.7 is end of life. We should support the newer versions instead.

I also changed tox to only run against the minimum dependency versions
on the lowest Python version, since this should lead to the lowest
versions over all Python versions, and hopefully helps speed up our
pipelines :)
2023-10-23 23:11:06 +02:00
Robbe Sneyders
69f117ce52 Drop extended ResolverError traceback 2023-02-23 00:13:13 +01:00
Robbe Sneyders
2f9a461981 Add support for relative refs in spec (#1648)
Fixes #254 
Fixes #967 

This PR fixes the very long-standing issue of being able to handle
relative references, which allows users to split their specification
into multiple files.
2023-02-22 23:43:27 +01:00
Robbe Sneyders
642a5f2dc3 Refactor tests (#1631)
This PR refactors our tests to prepare the activation of our tests for
our AsyncApp.

The separate commits are atomic, which can be useful for reviewing.

---------

Co-authored-by: Ruwann <ruwanlambrichts@gmail.com>
2023-02-12 22:25:08 +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
600ed4ed94 Format files with black 2022-06-25 23:50:52 +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
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
drewdogg
16ef766b89 Fix unit tests on Windows (#1071) 2019-12-03 00:05:45 +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
Daniel Grossmann-Kavanagh
72b16676cf simplify Operation class construction (#726)
* simplify *Operation creation

* move Specification classes to separate file
2018-11-15 07:45:59 +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
0b19ed489a Update to swagger-spec-validator 2.3.1 (fixes #612) (#611) 2018-07-03 08:21:43 +02:00
Mike Ralphson
d7cea4e1b3 Tests; remove duplicate test of missing_op_id in debug mode 2017-08-31 10:26:22 +01:00
Rafael Caricio
6746cb2be8 Fix mocking API partially 2017-06-30 16:46:26 +02:00
Rafael Carício
93c06711ed New style of passing options to Connexion (#436)
* Order classes by relevance in module

* Order definitions by relevance within module

* Swagger UI options extracted

* New style options

* Use new-style options

* Reuse code

* Sort imports

* Ignore typing imports

* Warn users about parameter name change

* Add back isort check

* Fix isort check
2017-04-11 16:47:21 +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
Diogo Dutra
3952ea2771 did changes requested by isort and flake8 2017-04-04 08:20:25 -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
Henning Jacobs
f289b40b99 #290 fix basePath with trailing slash 2016-10-04 10:57:49 +02:00
Jens Finkhaeuser
fa328f7709 Move bad_specs fixtures to its own fixtures folder 2016-09-13 16:53:00 +02:00
Jens Finkhaeuser
74cec244b4 Fixes after running & fixing TOXENV=isort-check tox 2016-09-13 16:24:28 +02:00
Jens Finkhaeuser
6476c033d2 Fix isort errors 2016-09-13 16:03:57 +02:00
Jens Finkhaeuser
ecd7d3ab6c Fix tests after merge 2016-09-13 15:52:02 +02:00
Jens Finkhaeuser
9d4a40ee38 Merge branch 'fix-missing-operation-id' into bad-operation-id-to-5xx
See #274 for discussion.
2016-09-13 15:37:23 +02:00
Jens Finkhaeuser
62f29c6256 Fix tests: in non-debug mode, original errors will be raised, which is
an ImportError in this case.
2016-09-13 15:27:23 +02:00
Rafael Caricio
0bebd0e643 Split swagger spec for consistent testing 2016-09-13 15:03:40 +02:00
Rafael Caricio
ccce2f85fe Pass along exceptions related to user mistakes 2016-09-13 12:00:41 +02:00
Rafael Caricio
3f33a54ec3 Fix tests path from fixtures 2016-09-13 11:46:59 +02:00
Jens Finkhaeuser
328aa51f6c Fix isort errors. Some of these look like they're not from my branch to
begin with.
2016-09-12 13:56:29 +02:00
Jens Finkhaeuser
37154d3b9a Makes sure #250 is still working. This explicitly handles ImportError
and re-raises its exception information if exceptions relating to
name resolution are raised at all.
It still converts the meaningless ValueError and AttributeError into a
ResolverError.
2016-09-09 11:53:16 +02:00
Jens Finkhaeuser
1e786d9538 If a ResolverError is raised during the addition of operations, and a
resolver_error_handler is provided, try to add that as an operation with
a randomized endpoint name. Otherwise, behave as before.
2016-09-09 11:52:05 +02:00
Jens Finkhaeuser
8c556543a9 Move ResolverError over to exceptions where it seems to be long. 2016-09-09 11:52:05 +02:00
Jens Finkhaeuser
92f51eab2a Improve Api test cases 2016-09-09 11:52:05 +02:00
Jens Finkhaeuser
875efbf258 Obviously, ImportError no longer falls through. That should have been
part of the PR earlier.
2016-09-09 11:52:05 +02:00
Jens Finkhaeuser
ad0a908691 Add test cases for missing and bad operationIds - slightly different from
the module with error case, but the result should be the same.
2016-09-09 11:52:05 +02:00
Jens Finkhaeuser
6697dc334f Makes sure #250 is still working. This explicitly handles ImportError
and re-raises its exception information if exceptions relating to
name resolution are raised at all.
It still converts the meaningless ValueError and AttributeError into a
ResolverError.
2016-09-07 15:16:59 +02:00
Jens Finkhaeuser
255e419572 Move ResolverError over to exceptions where it seems to be long. 2016-09-07 13:08:04 +02:00
Jens Finkhaeuser
c6cc024b1e Improve Api test cases 2016-09-07 12:41:59 +02:00
Jens Finkhaeuser
b321626c4c Obviously, ImportError no longer falls through. That should have been
part of the PR earlier.
2016-09-07 10:47:32 +02:00
Jens Finkhaeuser
ee86744046 Add test cases for missing and bad operationIds - slightly different from
the module with error case, but the result should be the same.
2016-09-07 10:07:46 +02:00
Rafael Caricio
0ac6721f4e Comprehensive error on invalid Swagger Spec 2016-06-28 10:47:39 +02:00
Rafael Caricio
cfcdfa72a4 Use safe_load to avoid code invocation from YAML files 2016-06-28 10:43:02 +02:00
Rafael Caricio
d7a8880378 Sort imports 2016-06-25 21:32:57 +02:00
Rafael Caricio
98e99ed9e3 Opens spec file as binary and then handle problems with encoding.
Should fix issue #249.
2016-06-25 20:32:43 +02:00