Commit Graph

1288 Commits

Author SHA1 Message Date
Jonas Boecquaert
6cca316efd Fix deprecation warning for Validator.iter_errors (#1536)
* Fix deprecation warning for iter_errors
Bump jsonschema version to at least v4

* Bump jsonschema to v4.0.1

* Provide schema as keyword arg to evolve

* Fix evolve statement
2022-08-23 09:26:14 +02:00
Robbe Sneyders
620306a38c Fix tests for Flask 2.2 (#1572) 2022-08-23 08:58:12 +02:00
Motti Lanzkron
1ce3e2ed2d Only warn about the schema's x-body-name being deprecated if it's used. (#1554)
Co-authored-by: Motti Lanzkron <motti@microfocus.com>
2.14.0
2022-06-14 11:02:30 +02:00
Ricardo Piro-Rael
4dee7868be Fix OpenAPI parameters containing other parameters (#1523)
* Fix OpenAPI parameters containing other parameters

OpenAPI parameters can be unspecified and sometimes contain other
parameters. The current behavior is to assume it's a bracket parameter
and nest the containing parameter within the contained parameter, which
breaks the schema as the original parameter now seems to contain a
nested object.

We can avert this by checking for the presence of a '[' in the
parameter.

* Trigger Github workflow

Co-authored-by: Ricardo Piro-Rael <rpiro-rael@ironox.com>
2022-05-09 18:16:33 +02:00
Robbe Sneyders
cff03101e1 Only log x-body-name deprecation warning when used incorrectly (#1521) 2022-05-04 19:25:19 +02:00
Pavol Vargovčík
792bc4d552 openapi: remove JSON body second validation and type casting (#1170)
* openapi: remove body preprocessing

Body is already validated using jsonschema. There was also some type
casting but it was wrong: e.g. not recurring deeply into dicts and lists,
relying on existence of "type" in schema (which is not there e.g. if
oneOf is used). Anyway, the only reason why types should be casted is
converting integer values to float if the type is number. But this is in
most cases irrelevant.

Added an example, which did not work before this commit (echoed `{}`)
e.g. for
```
curl localhost:8080/api/foo -H 'content-type: application/json' -d
'{"foo": 1}'
```
but now the example works (echoes `{"foo": 1}`).

* test with oneOf in the requestBody

* remove oneof examples: superseded by tests

Co-authored-by: Pavol Vargovcik <pavol.vargovcik@kiwi.com>
2022-04-27 22:57:51 +02:00
Ruwann
c71b1169f6 Bugfix/async security check (#1512)
* Add failing tests

* Use for else construct
2.13.1
2022-04-16 09:54:25 +02:00
Robbe Sneyders
ea45242604 Update tests for changed werkzeug behavior in 2.1 (#1506)
https://github.com/pallets/werkzeug/issues/2352
2022-04-04 18:52:37 +02:00
Robbe Sneyders
0b509f29a0 Fix uri parsing for query parameter with empty brackets (#1501) 2022-04-04 18:51:31 +02:00
Ruwann
f236c6883d Drop pkg_resources (#1499)
* Use pkgutil instead of pkg_resources

* Use importlib.metadata and packaging for getting and parsing version number
2.13.0
2022-03-22 19:10:15 +01:00
Ruwann
85058ed3f1 Rework required_scopes checking (#1474)
* WIP: rework required_scopes checking

* Update tests for security scopes

* Add test for oauth security scheme with multiple possible scopes

* Update security tests

* Change optional auth test to correct behaviour

* Update security documentation

* Remove TODOs

* Catch possible exceptions from failed checks in async security factory

* Add .venv/ to gitignore

* Try to raise most specific exception

* Add test for raising most specific error

* Update async security handler factory

* Fix security handler error catching

* Fix imports order
2022-03-21 21:31:26 +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
Ruwann
3703a46d09 Add link to Flask JSONEncoder documentation (#1484) 2022-03-12 11:01:28 +01:00
Vadim Markovtsev
28c33d88ce Save memory on unused schema strings (#1482)
Nodoby needs the schema strings vs. the parsed contents, yet those strings consume quite some memory for big specs.
2022-03-10 17:43:18 +01:00
Robbe Sneyders
d335e01fd2 Move x-body-name to requestBody level (#1475)
* issue 1452 - placement of x-body-name isnt valid OAS3 location for an extension

* issue 1452 - placement of x-body-name isnt valid OAS3 location for an extension

* add vim temp files to ignore

* issue 1452 - placement of x-body-name isnt valid OAS3 location for an extension - now at requestBody after review comment

* issue 1452 - placement of x-body-name isnt valid OAS3 location for an extension - now at operation after review

* removed unused import

* Move x-body-name into requestBody

* Update tests/fixtures/simple/openapi.yaml

Co-authored-by: Ruwann <ruwanlambrichts@gmail.com>

* Update README.rst

Co-authored-by: Ruwann <ruwanlambrichts@gmail.com>

* Update docs/request.rst

Co-authored-by: Ruwann <ruwanlambrichts@gmail.com>

* Update README.rst

Co-authored-by: Ruwann <ruwanlambrichts@gmail.com>

* Add deprecationwarning for x-body-name position

Co-authored-by: John Lonergan <john.lonergan@gmail.com>
Co-authored-by: Ruwann <ruwanlambrichts@gmail.com>
2022-03-07 18:09:21 +01:00
Jonas Boecquaert
37f729ceb5 upgrade pyYAML supported versions in setup.py (#1478)
Fix test using pyYAML
2022-03-07 18:08:38 +01:00
Nicolas Noirbent
a1dddf62d4 lifecycle: add cookies attribute to ConnexionRequest (#1168) (#1209)
Co-authored-by: Robbe Sneyders <robbe.sneyders@ml6.eu>
2022-02-23 22:45:34 +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
James Kent
40d9dad984 [FIX] MethodViewResolver CamelCase Methods (#1467)
* ensure view_name is CamelCase

* update tests for MethodViewResolver for CamelCase

* use inflection package to camelize

Co-authored-by: Robbe Sneyders <robbe.sneyders@ml6.eu>
2022-02-22 19:34:16 +01:00
Robbe Sneyders
e163e9f321 Remove sanitization of body properties (#1469) 2.12.0 2022-02-21 19:57:46 +01:00
Robbe Sneyders
67d769d778 Drop openapi-spec-validator for custom ref handler (#1455) 2022-02-21 18:15:24 +01:00
Robbe Sneyders
4dcca7964c Move logging for skipping streaming response validation to right place (#1470) 2022-02-21 18:07:25 +01:00
Robbe Sneyders
e5c64bc96a Add lower bounds for itsdangerous and markupsafe (#1465)
This will enforce their lower versions to be installed in the *-min test
environments and prevent dependency conflicts with Flask and Jinja
2022-02-21 17:55:16 +01:00
Chris HORLER
d375ea8dac Don't validate streamed responses (#1259)
* rework PR #467 - don't attempt to validate streamed responses

* Add is_streamed property to ConnexionResponse

* Adhere to response.direct_passthrough

* Add test for file response validation

* Add warning about skipping validation for streamed response

Co-authored-by: Robbe Sneyders <robbe.sneyders@ml6.eu>
2022-02-19 17:18:45 +01:00
Davy Durham
eb97cf9f74 Fix for aiohttp and multipart/form-data uploads (#1222)
* Added unit tests to demonstrate the problems of https://github.com/zalando/connexion/issues/975
    - Taken mostly from existing PR: https://github.com/zalando/connexion/pull/987

* now splitting out multipart POSTs into files[] and form[], handling duplicate keys as the rest of connexion expects
    - Based parly on existing PR: https://github.com/zalando/connexion/pull/987

* rewrote how operations/openapi.py::_get_body_argument() works to better build the arguments[] list according to what the spec says and what the handler accepts.  This fixes a bug when requests contain mixed files and form values and the handler is expecting variable names matching the request property names.

* Adding unit tests to improve code converage test

* post merge fixes - using 'async' keyword now in new unit test file

* unit test improvements -- now testing the contents of the files we upload too

* making some code a bit clearer regarding duplicate names of file submissions

* fixing up unit tests since merging main

* fixing isort-check-tests and flake8

* clarified a comment

* comment correction

* after discussions with maintainer, reverted _get_body_argument back to the original where it does not attempt to break out the body into individual arguments for the handler.  But left in changes that make the normal behavior of not passing a body argument to a handler without one more consistent when the body itself is empty or not an object type.

* fixing unit tests after after reverting _get_body_argument behavior
2022-02-18 17:44:51 +01:00
Ruwann
166b3e1b8b Use NullableEnumValidator for enum (#1464) 2.11.2 2022-02-17 22:01:01 +01:00
Robbe Sneyders
089176fecd Take into account (x-)nullable when validating defaults (#1463) 2022-02-17 19:51:08 +01:00
c. b. osborn
6fb3ac3df9 Change aiohttp req.has_body to req.can_read_body. Resolves #1136. (#1296) 2022-02-09 20:13:32 +01:00
Robbe Sneyders
0b916e9877 Add Python 3.9 to supported versions in setup.py (#1459) 2.11.1 2022-02-09 10:09:41 +01:00
Robbe Sneyders
6e5fa10010 Only push to TestPyPi on tag trigger (#1457) 2.11.0 2022-02-08 14:09:14 +01:00
Robbe Sneyders
c36248953f Change test release trigger to tags (#1456) 2022-02-08 10:16:51 +01:00
LeComptoirDesPharmacies
afd0500479 fix-square bracket : V1 (#1408)
* fix-square bracket : V1

Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten

* Fix syntax

Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten

* Add OpenAPI test with square brackets

Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten

* Fix test

Fix alphabetic order in import
Fix test parametrization

Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten

* square bracket : Set collection format to None for OpenAPIURIParser

Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten

Co-authored-by: Géry THRASIBULE <g.thrasibule@lecomptoirdespharmacies.fr>
2022-02-08 09:19:08 +01:00
Robbe Sneyders
a8283bda9b Automate release process via github actions (#1454) 2022-02-07 22:54:42 +01:00
Ruwann
a67baa5be0 Use both class docstring and init docstring for autoapi (#1451) 2022-02-05 14:39:02 +01:00
Paul Spooren
6abcbf6ddc Reload Flask on API file changes (#1418)
* Reload Flask on API file changes

Flask can automatically reload in debug mode whenver specified files
change. By default that includes templates, however changes to the API
files (i.e. openapi.yml) should result in a reload as well.

This PR adds all added API files to be monitored automatically by Flask.

Signed-off-by: Paul Spooren <mail@aparcar.org>

* Take into account specification dir

* Add extra_files argument.

User can still specify custom extra_files in addition to the
swagger specification, so need to account for that in FlaskApp.run().

* Update docstring for flake8

* Add extra_files as explicit argument for FlaskApp

* Add extra_files docstring

Co-authored-by: Ruwan <ruwanlambrichts@gmail.com>
2022-02-02 00:34:40 +01:00
Ruwann
1f07bde2cb Fix sanitization of function arguments (#1442)
* Add test for incorrectly cased params with pythonic_params

* Fix 1307: only sanitize when checking view func arguments

* Don't sanitize original request form

* Fix OpenAPI3 test fixture for form data

* Fix view function for test
2022-02-01 23:20:40 +01:00
Robbe Sneyders
86af42d6b9 Bump upperbound version for jsonschema to 5.0.0 (#1447)
* Drop usage of private jsonschema modules

* Bump upper boundry for jsonschema version to 5.0.0

* Create validate_defaults function by passing in the instance_validator

The instance_validator was previously set as an attribute on the
OpenApiValidator. However with the jsonschema upgrade to 4.0.0, this
attribute is no longer maintained while descending into the spec.
Presumably because jsonschema now relies on attrs.resolve.
2022-01-29 20:30:56 +01:00
Robbe Sneyders
425d5d551b Update release tests to py39 (#1441) 2022-01-15 21:24:41 +01:00
Parth Shah
fc6803bc00 improved error 415 (#1185)
* improved error 415

* test added

* Fix tests for updated 415 error response

Co-authored-by: unknown <parthsujalshah@gmail.com.com>
Co-authored-by: Ruwan <ruwanlambrichts@gmail.com>
2.10.0
2021-11-04 20:51:16 +01:00
Roger Camargo
7aeb3bdfb7 #1436: [Documentation] Add a flask error handler complete example (#1437)
* #1436: [Documentation] Add a flask error handler complete example

* #1436: [Documentation] Change to use the add_error_handler function
2021-10-22 08:36:29 +02:00
Ruwann
7c862e1ba8 Feature/relative resolver (#1419)
* Add a relative resolver

* Fix super() usage

* Apply suggestions from code review

* Allow root_path to be a Python module

* Expand documentation for RelativeResolver

* Add tests for relative resolver
2021-10-06 11:34:07 +02:00
Daisie Huang
4fd5d63ce7 #1424: add keywords to the list of pythonic words (#1425)
* #1424: add keywords to the list of pythonic words

* reorder imports

* add test query parameter

* add test query parameter "class"

* add class query param to test

* add class query param to openapi spec

* Update connexion/decorators/parameter.py

Co-authored-by: Ruwann <ruwan.lambrichts@ml6.eu>

Co-authored-by: Ruwann <ruwan.lambrichts@ml6.eu>
2021-09-13 20:28:11 +02:00
soof-golan
2dfd57dafb Replace links of master in favor of main (#1421)
Replace links referring to the ``master`` branch in favor of ``main``
2021-09-02 10:46:43 +02:00
Christian Clauss
8c49a61156 Tox.ini: Run mypy in ignore_outcome mode (#1405)
* Tox.ini: Run mypy in allow errors mode

* py39: mypy

* touch .mypy_cache

* Make sure .mypy_cache exists

* Update tox.ini

* mkdir .mypy_cache

* mkdir .mypy_cache

* mkdir .mypy_cache

* mypy --install-types --non-interactive . || true

* mypy --exclude=/examples/ --install-types --non-interactive . || true

* mypy --exclude /examples/ --install-types --non-interactive .

* mypy --exclude /examples/* --install-types --non-interactive .

* mypy --exclude '/app\.py$' --install-types --non-interactive .

* mypy --exclude '/(app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(api|app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|api.pets|app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|api.pets|app|hello|resty)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|api.pets|app|hello|orm|resty)\.py$' --install-types --non-interactive .

* Update pipeline.yml

* Update tox.ini

* Update pipeline.yml

* Update tox.ini

* Update mypy invocation and fix typing errors

Make it such that mypy will not return an exit code 2, which
indicates a failure in running mypy itself.

Co-authored-by: Ruwan <ruwanlambrichts@gmail.com>
2021-08-23 14:20:05 +02:00
Qiang Huang
65c1fab68f #1256 AioHttpAPP.get_root_path return Path object (#1415)
* #1256 AioHttpAPP.get_root_path return Path object

* Apply suggestions from code review

Use pathlib for all path operations

Co-authored-by: Ruwann <ruwan.lambrichts@ml6.eu>
2021-08-23 13:49:15 +02:00
Amin Alaee
69e289bb77 Update basicauth example (#1411) 2021-08-11 09:30:43 +02:00
Patrick Wang
e3e851dd31 Use jsonschema for validation (#936)
* jsonschema validation

* doh, exceptions should be raised

* internalize OpenAPI specs

from 6d17b631ff

* enforce that each default value validates against the schema in which it resides

* Fix import order

* Remove unused imports

* Move _validate_spec() to Specification base class

Co-authored-by: Patrick Wang <patrickkwang@users.noreply.github.com>
2021-07-31 22:47:09 +02:00
Robbe Sneyders
2229831e80 Render correct template in API (#1404)
* Explicitly render templates of correct blueprint

* Remove unused constant
2021-07-24 21:34:45 +02:00
Ruwann
803cf63878 Remove reference to deleted vendor files (#1403) 2021-07-21 08:59:21 +02:00
Robbe Sneyders
f45ef0e5ae Bump Flask & Werkzeug major versions (#1402) 2021-07-19 18:27:18 +02:00