130 tests run, 122 passed, 0 skipped, 8 failed.
Annotations
Check failure on line 1 in RebarTest
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
RebarTest.test_swagger_can_be_set_to_v3
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
self = <tests.test_rebar.RebarTest testMethod=test_swagger_can_be_set_to_v3>
def test_swagger_can_be_set_to_v3(self):
rebar = Rebar()
rebar.create_handler_registry(swagger_generator=SwaggerV3Generator())
app = create_rebar_app(rebar)
resp = app.test_client().get("/swagger")
self.assertEqual(resp.status_code, 200)
> validate_swagger(resp.json, SWAGGER_V3_JSONSCHEMA)
tests/test_rebar.py:567:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning
Check failure on line 198 in tests/swagger_generation/test_swagger_generator.py
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
test_swagger_generator.test_swagger_v3_generator_non_registry_parameters
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
def test_swagger_v3_generator_non_registry_parameters():
title = "Test API"
version = "3.1.0"
description = "testing testing 123"
class Error(m.Schema):
message = m.fields.String()
details = m.fields.Dict()
generator = SwaggerV3Generator(
version=version,
title=title,
description=description,
default_response_schema=Error(),
tags=[
Tag(
name="bar",
description="baz",
external_docs=ExternalDocumentation(
url="http://bardocs.com", description="qux"
),
)
],
servers=[
Server(
url="https://{username}.gigantic-server.com:{port}/{basePath}",
description="The production API server",
variables={
"username": ServerVariable(
default="demo",
description="this value is assigned by the service provider: `gigantic-server.com`",
),
"port": ServerVariable(default="8443", enum=["8443", "443"]),
"basePath": ServerVariable(default="v2"),
},
)
],
)
rebar = Rebar()
registry = rebar.create_handler_registry()
swagger = generator.generate(registry)
expected_swagger = {
"openapi": "3.1.0",
"info": {"title": title, "version": version, "description": description},
"tags": [
{
"name": "bar",
"description": "baz",
"externalDocs": {"url": "http://bardocs.com", "description": "qux"},
}
],
"servers": [
{
"url": "https://{username}.gigantic-server.com:{port}/{basePath}",
"description": "The production API server",
"variables": {
"username": {
"default": "demo",
"description": "this value is assigned by the service provider: `gigantic-server.com`",
},
"port": {"enum": ["8443", "443"], "default": "8443"},
"basePath": {"default": "v2"},
},
}
],
"paths": {},
"components": {
"schemas": {
"Error": {
"additionalProperties": False,
"type": "object",
"title": "Error",
"properties": {
"message": {"type": "string"},
"details": {"type": "object"},
},
}
}
},
}
> validate_swagger(expected_swagger, SWAGGER_V3_JSONSCHEMA)
tests/swagger_generation/test_swagger_generator.py:198:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning
Check failure on line 265 in tests/swagger_generation/test_swagger_generator.py
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
test_swagger_generator.test_swagger_generators[registry1-swagger_generator1-expected_swagger1]
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
registry = <flask_rebar.rebar.HandlerRegistry object at 0x7f32f6696ad0>
swagger_generator = <flask_rebar.swagger_generation.swagger_generator_v3.SwaggerV3Generator object at 0x7f32f6697070>
expected_swagger = {'components': {'schemas': {'Error': {'additionalProperties': False, 'properties': {'errors': {'type': 'object'}, 'mes...': 'tagged_foos', 'responses': {'default': {'content': {...}, 'description': 'Error'}}, 'tags': ['bar', 'baz']}}}, ...}
@pytest.mark.parametrize(
"registry, swagger_generator, expected_swagger",
[
(legacy.registry, legacy.swagger_v2_generator, legacy.EXPECTED_SWAGGER_V2),
(legacy.registry, legacy.swagger_v3_generator, legacy.EXPECTED_SWAGGER_V3),
(
exploded_query_string.registry,
exploded_query_string.swagger_v2_generator,
exploded_query_string.EXPECTED_SWAGGER_V2,
),
(
exploded_query_string.registry,
exploded_query_string.swagger_v3_generator,
exploded_query_string.EXPECTED_SWAGGER_V3,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v2_generator,
multiple_authenticators.EXPECTED_SWAGGER_V2,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v3_generator,
multiple_authenticators.EXPECTED_SWAGGER_V3,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v2_generator,
marshmallow_objects.EXPECTED_SWAGGER_V2,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v3_generator,
marshmallow_objects.EXPECTED_SWAGGER_V3,
),
],
)
def test_swagger_generators(registry, swagger_generator, expected_swagger):
open_api_version = swagger_generator.get_open_api_version()
if open_api_version == "2.0":
swagger_jsonschema = SWAGGER_V2_JSONSCHEMA
elif open_api_version == "3.1.0":
swagger_jsonschema = SWAGGER_V3_JSONSCHEMA
else:
raise ValueError("Unknown swagger_version: {}".format(open_api_version))
> validate_swagger(expected_swagger, schema=swagger_jsonschema)
tests/swagger_generation/test_swagger_generator.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning
Check failure on line 265 in tests/swagger_generation/test_swagger_generator.py
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
test_swagger_generator.test_swagger_generators[registry3-swagger_generator3-expected_swagger3]
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
registry = <flask_rebar.rebar.HandlerRegistry object at 0x7f32f6612740>
swagger_generator = <flask_rebar.swagger_generation.swagger_generator_v3.SwaggerV3Generator object at 0x7f32f6610fd0>
expected_swagger = {'components': {'schemas': {'Error': {'additionalProperties': False, 'properties': {'errors': {'type': 'object'}, 'mes...': True, 'in': 'query', 'name': 'foos', ...}], 'responses': {'default': {'content': {...}, 'description': 'Error'}}}}}}
@pytest.mark.parametrize(
"registry, swagger_generator, expected_swagger",
[
(legacy.registry, legacy.swagger_v2_generator, legacy.EXPECTED_SWAGGER_V2),
(legacy.registry, legacy.swagger_v3_generator, legacy.EXPECTED_SWAGGER_V3),
(
exploded_query_string.registry,
exploded_query_string.swagger_v2_generator,
exploded_query_string.EXPECTED_SWAGGER_V2,
),
(
exploded_query_string.registry,
exploded_query_string.swagger_v3_generator,
exploded_query_string.EXPECTED_SWAGGER_V3,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v2_generator,
multiple_authenticators.EXPECTED_SWAGGER_V2,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v3_generator,
multiple_authenticators.EXPECTED_SWAGGER_V3,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v2_generator,
marshmallow_objects.EXPECTED_SWAGGER_V2,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v3_generator,
marshmallow_objects.EXPECTED_SWAGGER_V3,
),
],
)
def test_swagger_generators(registry, swagger_generator, expected_swagger):
open_api_version = swagger_generator.get_open_api_version()
if open_api_version == "2.0":
swagger_jsonschema = SWAGGER_V2_JSONSCHEMA
elif open_api_version == "3.1.0":
swagger_jsonschema = SWAGGER_V3_JSONSCHEMA
else:
raise ValueError("Unknown swagger_version: {}".format(open_api_version))
> validate_swagger(expected_swagger, schema=swagger_jsonschema)
tests/swagger_generation/test_swagger_generator.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning
Check failure on line 265 in tests/swagger_generation/test_swagger_generator.py
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
test_swagger_generator.test_swagger_generators[registry5-swagger_generator5-expected_swagger5]
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
registry = <flask_rebar.rebar.HandlerRegistry object at 0x7f32f6612ad0>
swagger_generator = <flask_rebar.swagger_generation.swagger_generator_v3.SwaggerV3Generator object at 0x7f32f6610c70>
expected_swagger = {'components': {'schemas': {'Error': {'additionalProperties': False, 'properties': {'errors': {'type': 'object'}, 'mes...': 'tagged_foos', 'responses': {'default': {'content': {...}, 'description': 'Error'}}, 'tags': ['bar', 'baz']}}}, ...}
@pytest.mark.parametrize(
"registry, swagger_generator, expected_swagger",
[
(legacy.registry, legacy.swagger_v2_generator, legacy.EXPECTED_SWAGGER_V2),
(legacy.registry, legacy.swagger_v3_generator, legacy.EXPECTED_SWAGGER_V3),
(
exploded_query_string.registry,
exploded_query_string.swagger_v2_generator,
exploded_query_string.EXPECTED_SWAGGER_V2,
),
(
exploded_query_string.registry,
exploded_query_string.swagger_v3_generator,
exploded_query_string.EXPECTED_SWAGGER_V3,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v2_generator,
multiple_authenticators.EXPECTED_SWAGGER_V2,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v3_generator,
multiple_authenticators.EXPECTED_SWAGGER_V3,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v2_generator,
marshmallow_objects.EXPECTED_SWAGGER_V2,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v3_generator,
marshmallow_objects.EXPECTED_SWAGGER_V3,
),
],
)
def test_swagger_generators(registry, swagger_generator, expected_swagger):
open_api_version = swagger_generator.get_open_api_version()
if open_api_version == "2.0":
swagger_jsonschema = SWAGGER_V2_JSONSCHEMA
elif open_api_version == "3.1.0":
swagger_jsonschema = SWAGGER_V3_JSONSCHEMA
else:
raise ValueError("Unknown swagger_version: {}".format(open_api_version))
> validate_swagger(expected_swagger, schema=swagger_jsonschema)
tests/swagger_generation/test_swagger_generator.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning
Check failure on line 265 in tests/swagger_generation/test_swagger_generator.py
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
test_swagger_generator.test_swagger_generators[registry7-swagger_generator7-expected_swagger7]
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
registry = <flask_rebar.rebar.HandlerRegistry object at 0x7f32f623a320>
swagger_generator = <flask_rebar.swagger_generation.swagger_generator_v3.SwaggerV3Generator object at 0x7f32f623a3b0>
expected_swagger = {'components': {'schemas': {'Error': {'additionalProperties': False, 'properties': {'errors': {'type': 'object'}, 'mes...': 'tagged_foos', 'responses': {'default': {'content': {...}, 'description': 'Error'}}, 'tags': ['bar', 'baz']}}}, ...}
@pytest.mark.parametrize(
"registry, swagger_generator, expected_swagger",
[
(legacy.registry, legacy.swagger_v2_generator, legacy.EXPECTED_SWAGGER_V2),
(legacy.registry, legacy.swagger_v3_generator, legacy.EXPECTED_SWAGGER_V3),
(
exploded_query_string.registry,
exploded_query_string.swagger_v2_generator,
exploded_query_string.EXPECTED_SWAGGER_V2,
),
(
exploded_query_string.registry,
exploded_query_string.swagger_v3_generator,
exploded_query_string.EXPECTED_SWAGGER_V3,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v2_generator,
multiple_authenticators.EXPECTED_SWAGGER_V2,
),
(
multiple_authenticators.registry,
multiple_authenticators.swagger_v3_generator,
multiple_authenticators.EXPECTED_SWAGGER_V3,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v2_generator,
marshmallow_objects.EXPECTED_SWAGGER_V2,
),
(
marshmallow_objects.registry,
marshmallow_objects.swagger_v3_generator,
marshmallow_objects.EXPECTED_SWAGGER_V3,
),
],
)
def test_swagger_generators(registry, swagger_generator, expected_swagger):
open_api_version = swagger_generator.get_open_api_version()
if open_api_version == "2.0":
swagger_jsonschema = SWAGGER_V2_JSONSCHEMA
elif open_api_version == "3.1.0":
swagger_jsonschema = SWAGGER_V3_JSONSCHEMA
else:
raise ValueError("Unknown swagger_version: {}".format(open_api_version))
> validate_swagger(expected_swagger, schema=swagger_jsonschema)
tests/swagger_generation/test_swagger_generator.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning
Check failure on line 57 in tests/swagger_generation/test_swagger_generator_hidden_api.py
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
test_swagger_generator_hidden_api.test_swagger_generators[registry1-swagger_generator1-expected_swagger1]
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
registry = <flask_rebar.rebar.HandlerRegistry object at 0x7f32f6697eb0>
swagger_generator = <flask_rebar.swagger_generation.swagger_generator_v3.SwaggerV3Generator object at 0x7f32f6695db0>
expected_swagger = {'components': {'schemas': {'Error': {'additionalProperties': False, 'properties': {'errors': {'type': 'object'}, 'mes...': 'tagged_foos', 'responses': {'default': {'content': {...}, 'description': 'Error'}}, 'tags': ['bar', 'baz']}}}, ...}
@pytest.mark.parametrize(
"registry, swagger_generator, expected_swagger",
[
(
hidden_api.registry,
hidden_api.swagger_v2_generator,
hidden_api.EXPECTED_SWAGGER_V2,
),
(
hidden_api.registry,
hidden_api.normal_swagger_v3_generator,
hidden_api.SWAGGER_V3_WITHOUT_HIDDEN,
),
(
hidden_api.registry,
hidden_api.swagger_v3_generator_with_hidden,
hidden_api.SWAGGER_V3_WITH_HIDDEN,
),
],
)
def test_swagger_generators(registry, swagger_generator, expected_swagger):
open_api_version = swagger_generator.get_open_api_version()
if open_api_version == "2.0":
swagger_jsonschema = SWAGGER_V2_JSONSCHEMA
elif open_api_version == "3.1.0":
swagger_jsonschema = SWAGGER_V3_JSONSCHEMA
else:
raise ValueError("Unknown swagger_version: {}".format(open_api_version))
> validate_swagger(expected_swagger, schema=swagger_jsonschema)
tests/swagger_generation/test_swagger_generator_hidden_api.py:57:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning
Check failure on line 57 in tests/swagger_generation/test_swagger_generator_hidden_api.py
github-actions / JUnit Report python3.10 marshmallow>3.18.0 flask=='2.2.*' werkzeug=='2.2.*'
test_swagger_generator_hidden_api.test_swagger_generators[registry2-swagger_generator2-expected_swagger2]
DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
Raw output
registry = <flask_rebar.rebar.HandlerRegistry object at 0x7f32f6697eb0>
swagger_generator = <flask_rebar.swagger_generation.swagger_generator_v3.SwaggerV3Generator object at 0x7f32f6697e20>
expected_swagger = {'components': {'schemas': {'Error': {'additionalProperties': False, 'properties': {'errors': {'type': 'object'}, 'mes...': 'tagged_foos', 'responses': {'default': {'content': {...}, 'description': 'Error'}}, 'tags': ['bar', 'baz']}}}, ...}
@pytest.mark.parametrize(
"registry, swagger_generator, expected_swagger",
[
(
hidden_api.registry,
hidden_api.swagger_v2_generator,
hidden_api.EXPECTED_SWAGGER_V2,
),
(
hidden_api.registry,
hidden_api.normal_swagger_v3_generator,
hidden_api.SWAGGER_V3_WITHOUT_HIDDEN,
),
(
hidden_api.registry,
hidden_api.swagger_v3_generator_with_hidden,
hidden_api.SWAGGER_V3_WITH_HIDDEN,
),
],
)
def test_swagger_generators(registry, swagger_generator, expected_swagger):
open_api_version = swagger_generator.get_open_api_version()
if open_api_version == "2.0":
swagger_jsonschema = SWAGGER_V2_JSONSCHEMA
elif open_api_version == "3.1.0":
swagger_jsonschema = SWAGGER_V3_JSONSCHEMA
else:
raise ValueError("Unknown swagger_version: {}".format(open_api_version))
> validate_swagger(expected_swagger, schema=swagger_jsonschema)
tests/swagger_generation/test_swagger_generator_hidden_api.py:57:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
flask_rebar/testing/__init__.py:14: in validate_swagger
jsonschema.validate(instance=swagger, schema=schema)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:893: in validate
cls = validator_for(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
schema = {'$defs': {'callbacks': {'$comment': 'https://spec.openapis.org/oas/v3.1.0#callback-object', '$ref': '#/$defs/specific...022-10-07', '$ref': '#/$defs/specification-extensions', '$schema': 'https://json-schema.org/draft/2020-12/schema', ...}
default = <class 'jsonschema.validators.create.<locals>.Validator'>
def validator_for(schema, default=_LATEST_VERSION):
"""
Retrieve the validator class appropriate for validating the given schema.
Uses the :validator:`$schema` property that should be present in the given
schema to look up the appropriate validator class.
Arguments:
schema (collections.Mapping or bool):
the schema to look at
default:
the default to return if the appropriate validator class cannot be
determined.
If unprovided, the default is to return
the latest supported draft.
"""
if schema is True or schema is False or u"$schema" not in schema:
return default
if schema[u"$schema"] not in meta_schemas:
> warn(
(
"The metaschema specified by $schema was not found. "
"Using the latest draft to validate, but this will raise "
"an error in the future."
),
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/jsonschema/validators.py:926: DeprecationWarning