Commit Graph

33 Commits

Author SHA1 Message Date
Robbe Sneyders
600ed4ed94 Format files with black 2022-06-25 23:50:52 +02:00
jacobstanly89
b561ecfdaa Fix for bug of the function is_json_mimetype() (#1541)
* Fix for bug of the function is_json_mimetype() (#1114)

* Splitting the mimetype correctly

* Added a test for the json mimetype usecases

* Update connexion/utils.py

Co-authored-by: Ruwann <ruwan.lambrichts@ml6.eu>
2022-05-31 19:01:27 +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
Stephen Hurwitz
43003f8666 Fixes util.deep_get when obj is a list (#1055)
* Fixes util.deep_get when obj is a list

The example below will seem strange. It's the result of distilling a complex
API spec down to the root cause of the issue.

```yaml
---
openapi: 3.0.0
info:
  version: v0
  title: Repo an error
  description: Extremely contrived, but it illustrates the problem
paths:
  /:
    get:
      operationId: app.get
      responses:
        '200':
          description: Just for giggles
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SomeWeirdResource"
components:
  schemas:
    Resource:
      allOf:
        - type: object
          properties:
            id:
              type: string
    SomeWeirdResource:
      allOf:
        - type: object
          properties:
            id:
              $ref: '#/components/schemas/Resource/allOf/0/properties/id'
```

While convoluted, this is a valid OpenAPI 3 spec.

```sh
$ yarn swagger-cli validate openapi/my_api.yaml
yarn run v1.17.3
$ /[redacted]/node_modules/.bin/swagger-cli validate openapi/my_api.yaml
openapi/my_api.yaml is valid
  Done in 0.23s.
```

`utils.deep_get` assumes the obj to be a dictionary when it can also be a list.

* Updates docstring for utils.deep_get

Comment on the pull request was asking for an explanation to clarify the
code. The updated docstring aims to be clear on how exactly the object
can be a list.
2019-10-16 18:05:23 +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
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
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
7c87126fc8 uncouple flask utils functions from utils module 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
Patrick Williams
6eb5a6e969 Support the flask url variable converter "path" 2017-01-07 10:02:44 -05:00
Yoan Blanc
be437a980b Fix isort checks 2016-10-16 11:32:11 +02:00
Jens Finkhaeuser
e41f8c6d41 Add ability to add random string to endpoint names so that flask doesn't
complain about duplicate names.
2016-09-07 12:13:49 +02:00
David Hotham
851d04372e isort imports 2016-06-10 20:39:51 +01:00
João Santos
87afbfe6eb #218 Raise import errors on endpoint handling 2016-06-08 15:11:06 +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
Rafael Caricio
633dac8dd1 #127 handle boolean values 2016-02-01 17:11:37 +01:00
cyprien-g
41df524e61 Allow None value in boolean converter 2016-01-04 10:30:05 +01:00
cyprien-g
754c250f7e Case insensitive check for boolean validation 2015-12-28 16:18:49 +01:00
cyprien-g
811a226892 Allow True/False for query parameters 2015-12-28 14:02:02 +01:00
João Santos
6554de8dc3 #108 DRY and more cleanup 2015-12-10 16:01:15 +01:00
Henning Jacobs
0c56d1560b #104 support int/float path converter 2015-12-05 20:38:08 +01:00
Henning Jacobs
2c0c960a5d #101 add unit test to resolve static method 2015-12-05 19:06:48 +01:00
Henning Jacobs
f35dce3bd6 #48 validate integer, number and boolean query parameters 2015-08-26 18:35:57 +02:00
Henning Jacobs
5337df4601 add validation for "date" format 2015-07-31 19:52:28 +02:00
João Santos
69375f55cf Change datetime format validator to be compatible with python 2 2015-07-30 09:49:26 +02:00
Henning Jacobs
b0d481a7e8 fix missing time-secfrac 2015-07-23 18:42:09 +02:00
Henning Jacobs
99669024c5 fix date-time parsing for strings without milliseconds 2015-07-23 17:47:10 +02:00
Henning Jacobs
476cbe1a35 support paths with hyphen 2015-07-17 09:36:04 +02:00
João Santos
b40295aa48 https://github.com/zalando/connexion/issues/6 Test utils 2015-06-13 11:27:44 +02:00