35 Commits

Author SHA1 Message Date
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
Christian Siegel
67f48ae24d Add swagger_ui_config option to pass config to the Swagger UI (#948)
* Add swagger_ui_config option to configure the Swagger UI

There was no possibility to configure the Swagger UI. Through
this new option a config object can be passed to the UI via
a `swagger-ui-config.json` file.

* Add tests for swagger_ui_config option
2019-11-05 10:12:59 +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
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
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
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
Diogo Dutra
e326711aa4 Increase the code coverage (#631)
removed the validate_defaults method from Operation because the new swagger_spec_validation version do this validation
    added tests for AbstractApi._handle_add_operation_error
2018-07-21 13:15:55 +02:00
Daniel Grossmann-Kavanagh
2f074998e3 URI parsing decorator (#613)
- array logic refactored into one place.
- validation.py and parameter.py no longer try to join the array, and the split it again.
- validation of defaults now works, because the validator is given the correct type.
- some additional classes that change the behavior of deduplicating query parameters that are defined multiple times
  - **AlwaysMultiURIParser** that is backwards compatible, warts and all (used by default)
  - **Swagger2URIParser** that adheres to the spec's definition of `collectionFormat: multi` and uses the last-defined query parameter value (ex. `query?a=1&a=2` => `a = 2`)
  - **FirstValueURIParser** that behaves like Swagger2URIParser, except that the first-defined value is used (ex. `query?a=1&a=2` => `a=1`)
2018-07-09 11:06:24 +02:00
Daniel Grossmann-Kavanagh
0b19ed489a Update to swagger-spec-validator 2.3.1 (fixes #612) (#611) 2018-07-03 08:21:43 +02:00
Rodrigo di Lorenzo Lopes
9a8bddf509 solving fixed argument (server) for FlaskApp (backward incompatible and undesired change) 2017-06-06 14:44:17 +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
2ddebfdbe2 did changes requested by isort-check 2017-04-04 08:20:25 -03:00
Diogo Dutra
3952ea2771 did changes requested by isort and flake8 2017-04-04 08:20:25 -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
Leena Bhegade
f7b3d9a0bb add parameter to decode 2017-02-08 23:48:04 +00:00
Leena Bhegade
c1020bf0f6 Fix tests 2017-02-08 21:31:35 +00:00
Rafael Caricio
108d0a6760 Fix imports ordering 2016-12-10 20:24:14 +01:00
Rafael Caricio
3b5bb13276 Refactor code to fix confusion with returned values 2016-12-10 19:54:27 +01:00
Daniel DeFisher
34adf1b18e Swap import statements 2016-11-05 18:28:48 -04:00
Daniel DeFisher
01315b5178 Fix import order 2016-11-05 14:59:15 -04:00
Daniel DeFisher
1e82c66f29 refactor param names 2016-10-18 09:22:45 -04:00
Daniel DeFisher
5a6cdb51a2 Support app.add_api() with API-dictionary as an alternative to file path 2016-10-12 23:12:44 -04:00
Jens Finkhaeuser
f804a96a45 It's bad practice to derive custom exception classes from BaseException.
See https://www.python.org/dev/peps/pep-0352/
2016-09-07 13:36:36 +02:00
Dylan Semler
b7c6dede95 Add flag for strict_validation on extra parameters 2016-07-31 20:21:19 -04:00
jkozlowicz
bfc68da1ec Fixed the coding style errors 2016-06-06 15:03:23 +02:00
jkozlowicz
bd25c5ca74 Corrected the Content-Type header for /basePath/swagger.json to return application/json and added a test for that 2016-06-06 14:21:15 +02:00
Rafael Caricio
c30bdbb324 Fix import sorting in examples and tests 2016-04-08 14:33:27 +02:00
Rafael Caricio
a86b96c5e2 Sort imports in tests and examples 2016-04-08 14:33:27 +02:00
Rafael Caricio
6358c8c47d Adopt isort to ensure better code quality 2016-04-08 14:33:27 +02:00
Greg Brockman
a6cc07cca8 Make JSON printing a bit nicer 2016-04-04 21:59:54 -07:00
David Feinzeig
0c177c7539 make swagger_json optional when adding an api 2016-03-29 00:00:27 -04:00
Rafael Caricio
d6aac92eee Increase coverage 2016-02-25 15:41:11 +01:00
Rafael Caricio
a7aec5d53c Split tests in isolated modules 2016-02-25 14:49:19 +01:00