mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-09 20:37:46 +00:00
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
This commit is contained in:
@@ -10,6 +10,7 @@ logging.basicConfig(level=logging.DEBUG)
|
||||
TEST_FOLDER = pathlib.Path(__file__).parent
|
||||
FIXTURES_FOLDER = TEST_FOLDER / 'fixtures'
|
||||
SPEC_FOLDER = TEST_FOLDER / "fakeapi"
|
||||
SPECS = ["swagger.yaml", "openapi.yaml"]
|
||||
|
||||
|
||||
class FakeResponse(object):
|
||||
@@ -87,7 +88,12 @@ def default_param_error_spec_dir():
|
||||
return FIXTURES_FOLDER / 'default_param_error'
|
||||
|
||||
|
||||
def build_app_from_fixture(api_spec_folder, **kwargs):
|
||||
@pytest.fixture
|
||||
def json_validation_spec_dir():
|
||||
return FIXTURES_FOLDER / 'json_validation'
|
||||
|
||||
|
||||
def build_app_from_fixture(api_spec_folder, spec_file='openapi.yaml', **kwargs):
|
||||
debug = True
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
@@ -97,60 +103,73 @@ def build_app_from_fixture(api_spec_folder, **kwargs):
|
||||
port=5001,
|
||||
specification_dir=FIXTURES_FOLDER / api_spec_folder,
|
||||
debug=debug)
|
||||
cnx_app.add_api('swagger.yaml', **kwargs)
|
||||
|
||||
cnx_app.add_api(spec_file, **kwargs)
|
||||
cnx_app._spec_file = spec_file
|
||||
return cnx_app
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def simple_app():
|
||||
return build_app_from_fixture('simple', validate_responses=True)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def simple_app(request):
|
||||
return build_app_from_fixture('simple', request.param, validate_responses=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def snake_case_app():
|
||||
return build_app_from_fixture('snake_case', validate_responses=True, pythonic_params=True)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def snake_case_app(request):
|
||||
return build_app_from_fixture('snake_case', request.param,
|
||||
validate_responses=True,
|
||||
pythonic_params=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def invalid_resp_allowed_app():
|
||||
return build_app_from_fixture('simple', validate_responses=False)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def invalid_resp_allowed_app(request):
|
||||
return build_app_from_fixture('simple', request.param,
|
||||
validate_responses=False)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def strict_app():
|
||||
return build_app_from_fixture('simple', validate_responses=True, strict_validation=True)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def strict_app(request):
|
||||
return build_app_from_fixture('simple', request.param,
|
||||
validate_responses=True,
|
||||
strict_validation=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def problem_app():
|
||||
return build_app_from_fixture('problem', validate_responses=True)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def problem_app(request):
|
||||
return build_app_from_fixture('problem', request.param,
|
||||
validate_responses=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def schema_app():
|
||||
return build_app_from_fixture('different_schemas', validate_responses=True)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def schema_app(request):
|
||||
return build_app_from_fixture('different_schemas', request.param,
|
||||
validate_responses=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def secure_endpoint_app():
|
||||
return build_app_from_fixture('secure_endpoint', validate_responses=True)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def secure_endpoint_app(request):
|
||||
return build_app_from_fixture('secure_endpoint', request.param,
|
||||
validate_responses=True, pass_context_arg_name='req_context')
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def secure_api_app():
|
||||
return build_app_from_fixture('secure_api')
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def secure_api_app(request):
|
||||
options = {"swagger_ui": False}
|
||||
return build_app_from_fixture('secure_api', request.param,
|
||||
options=options, auth_all_paths=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def unordered_definition_app():
|
||||
return build_app_from_fixture('unordered_definition')
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def unordered_definition_app(request):
|
||||
return build_app_from_fixture('unordered_definition', request.param)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def bad_operations_app():
|
||||
return build_app_from_fixture('bad_operations', resolver_error=501)
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def bad_operations_app(request):
|
||||
return build_app_from_fixture('bad_operations', request.param,
|
||||
resolver_error=501)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def query_sanitazion():
|
||||
return build_app_from_fixture('query_sanitazion')
|
||||
@pytest.fixture(scope="session", params=SPECS)
|
||||
def query_sanitazion(request):
|
||||
return build_app_from_fixture('query_sanitazion', request.param)
|
||||
|
||||
Reference in New Issue
Block a user