Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate all the things #246

Merged
merged 4 commits into from Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions flask_rebar/rebar.py
Expand Up @@ -95,7 +95,6 @@ def _unpack_view_func_return_value(rv):
return data, int(status), headers


@deprecated_parameters(marshal_schema=("response_body_schema", "2.0"))
def _wrap_handler(
f,
authenticators=None,
Expand Down Expand Up @@ -251,7 +250,6 @@ class PathDefinition(
):
__slots__ = ()

@deprecated_parameters(marshal_schema=("response_body_schema", "2.0"))
@deprecated_parameters(
authenticator=(
"authenticators",
Expand All @@ -262,11 +260,6 @@ class PathDefinition(
def __new__(cls, *args, **kwargs):
return super(PathDefinition, cls).__new__(cls, *args, **kwargs)

@property
@deprecated("response_body_schema", "2.0")
def marshal_schema(self):
return self.response_body_schema

@property
@deprecated("authenticator", "3.0")
def authenticator(self):
Expand Down Expand Up @@ -315,7 +308,7 @@ class HandlerRegistry(object):
"3.0",
_convert_authenticator_to_authenticators,
),
swagger_path="spec_path",
swagger_path="spec_path", # we didn't specify an EOL for these two, maybe they just live forever (fine imho)
swagger_ui_path="spec_ui_path",
)
def __init__(
Expand Down Expand Up @@ -425,12 +418,11 @@ def paths(self):
return paths

@deprecated_parameters(
marshal_schema=("response_body_schema", "2.0"),
authenticator=(
"authenticators",
"3.0",
_convert_authenticator_to_authenticators,
),
)
)
def add_handler(
self,
Expand Down Expand Up @@ -514,12 +506,11 @@ def add_handler(
)

@deprecated_parameters(
marshal_schema=("response_body_schema", "2.0"),
authenticator=(
"authenticators",
"3.0",
_convert_authenticator_to_authenticators,
),
)
)
def handles(
self,
Expand Down
8 changes: 0 additions & 8 deletions flask_rebar/swagger_generation/authenticator_to_swagger.py
@@ -1,6 +1,5 @@
from collections import namedtuple

from flask_rebar.utils.deprecation import deprecated_parameters
from flask_rebar.authenticators import HeaderApiKeyAuthenticator, Authenticator
from .marshmallow_to_swagger import ConverterRegistry
from . import swagger_words as sw
Expand Down Expand Up @@ -183,13 +182,6 @@ def get_security_requirements(self, authenticator, openapi_version=2):
authenticator, _Context(openapi_version=openapi_version)
)

@deprecated_parameters(converters=("", "2.0"))
def __init__(self, *args, **kwargs):
super(AuthenticatorConverterRegistry, self).__init__()
deprecated_converts = args[0] if args else kwargs.get("", {})
for authenticator, method in deprecated_converts.items():
self.register(authenticator, method)


authenticator_converter_registry = AuthenticatorConverterRegistry()
authenticator_converter_registry.register_types((HeaderApiKeyConverter(),))
23 changes: 0 additions & 23 deletions flask_rebar/swagger_generation/generator_utils.py
Expand Up @@ -11,7 +11,6 @@
import re
from collections import namedtuple, OrderedDict

from flask_rebar.utils.deprecation import deprecated
from flask_rebar.utils.defaults import USE_DEFAULT
from flask_rebar.swagger_generation import swagger_words as sw
from flask_rebar.swagger_generation.marshmallow_to_swagger import get_swagger_title
Expand Down Expand Up @@ -183,25 +182,6 @@ def format_path_for_swagger(path):
return subbed_path, args


@deprecated(eol_version="2.0")
def convert_header_api_key_authenticator(authenticator):
"""
Converts a HeaderApiKeyAuthenticator object to a Swagger definition.

:param flask_rebar.authenticators.HeaderApiKeyAuthenticator authenticator:
:rtype: tuple(str, dict)
:returns: Tuple where the first item is a name for the authenticator, and
the second item is a Swagger definition for it.
"""
key = authenticator.name
definition = {
sw.name: authenticator.header,
sw.in_: sw.header,
sw.type_: sw.api_key,
}
return key, definition


def verify_parameters_are_the_same(a, b):
def get_sort_key(parameter):
return parameter[sw.name]
Expand Down Expand Up @@ -302,6 +282,3 @@ def recursively_convert_dict_to_ordered_dict(obj):
return [recursively_convert_dict_to_ordered_dict(item) for item in obj]
else:
return obj


AuthenticatorConverter = AuthenticatorConverterRegistry # deprecated alias
8 changes: 4 additions & 4 deletions tests/swagger_generation/registries/hidden_api.py
Expand Up @@ -45,7 +45,7 @@ class NameAndOtherSchema(m.Schema):
@registry.handles(
rule="/foos/<uuid_string:foo_uid>",
method="GET",
marshal_schema={200: FooSchema()},
response_body_schema={200: FooSchema()},
headers_schema=HeaderSchema(),
)
def get_foo(foo_uid):
Expand All @@ -56,7 +56,7 @@ def get_foo(foo_uid):
@registry.handles(
rule="/foos/<foo_uid>",
method="PATCH",
marshal_schema={200: FooSchema()},
response_body_schema={200: FooSchema()},
request_body_schema=FooUpdateSchema(),
authenticator=authenticator,
)
Expand All @@ -69,7 +69,7 @@ def update_foo(foo_uid):
@registry.handles(
rule="/foo_list",
method="GET",
marshal_schema={200: FooSchema(many=True)},
response_body_schema={200: FooSchema(many=True)},
authenticator=None, # Override the default!
hidden=True,
)
Expand All @@ -80,7 +80,7 @@ def list_foos():
@registry.handles(
rule="/foos",
method="GET",
marshal_schema={200: NestedFoosSchema()},
response_body_schema={200: NestedFoosSchema()},
query_string_schema=NameAndOtherSchema(),
authenticator=None, # Override the default!
)
Expand Down
8 changes: 4 additions & 4 deletions tests/swagger_generation/registries/legacy.py
Expand Up @@ -44,7 +44,7 @@ class NameAndOtherSchema(m.Schema):
@registry.handles(
rule="/foos/<uuid_string:foo_uid>",
method="GET",
marshal_schema={200: FooSchema()},
response_body_schema={200: FooSchema()},
headers_schema=HeaderSchema(),
)
def get_foo(foo_uid):
Expand All @@ -55,7 +55,7 @@ def get_foo(foo_uid):
@registry.handles(
rule="/foos/<foo_uid>",
method="PATCH",
marshal_schema={200: FooSchema()},
response_body_schema={200: FooSchema()},
request_body_schema=FooUpdateSchema(),
authenticator=authenticator,
)
Expand All @@ -68,7 +68,7 @@ def update_foo(foo_uid):
@registry.handles(
rule="/foo_list",
method="GET",
marshal_schema={200: FooSchema(many=True)},
response_body_schema={200: FooSchema(many=True)},
authenticator=None, # Override the default!
)
def list_foos():
Expand All @@ -78,7 +78,7 @@ def list_foos():
@registry.handles(
rule="/foos",
method="GET",
marshal_schema={200: NestedFoosSchema()},
response_body_schema={200: NestedFoosSchema()},
query_string_schema=NameAndOtherSchema(),
authenticator=None, # Override the default!
)
Expand Down
6 changes: 3 additions & 3 deletions tests/swagger_generation/registries/marshmallow_objects.py
Expand Up @@ -46,7 +46,7 @@ class NameAndOtherModel(mo.Model):
@registry.handles(
rule="/foos/<uuid_string:foo_uid>",
method="GET",
marshal_schema={200: FooModel},
response_body_schema={200: FooModel},
headers_schema=HeaderModel,
)
def get_foo(foo_uid):
Expand All @@ -57,7 +57,7 @@ def get_foo(foo_uid):
@registry.handles(
rule="/foos/<foo_uid>",
method="PATCH",
marshal_schema={200: FooModel},
response_body_schema={200: FooModel},
request_body_schema=FooUpdateModel,
authenticator=authenticator,
)
Expand All @@ -68,7 +68,7 @@ def update_foo(foo_uid):
@registry.handles(
rule="/foos",
method="GET",
marshal_schema={200: NestedFoosModel},
response_body_schema={200: NestedFoosModel},
query_string_schema=NameAndOtherModel,
authenticator=None, # Override the default!
)
Expand Down
Expand Up @@ -216,7 +216,7 @@ class NameAndOtherSchema(m.Schema):
@registry.handles(
rule="/foos/<uuid_string:foo_uid>",
method="GET",
marshal_schema={200: FooSchema()},
response_body_schema={200: FooSchema()},
headers_schema=HeaderSchema(),
)
def get_foo(foo_uid):
Expand All @@ -227,7 +227,7 @@ def get_foo(foo_uid):
@registry.handles(
rule="/foos/<foo_uid>",
method="PATCH",
marshal_schema={200: FooSchema()},
response_body_schema={200: FooSchema()},
request_body_schema=FooUpdateSchema(),
authenticators=authenticator,
)
Expand All @@ -240,7 +240,7 @@ def update_foo(foo_uid):
@registry.handles(
rule="/foo_list",
method="GET",
marshal_schema={200: FooSchema(many=True)},
response_body_schema={200: FooSchema(many=True)},
authenticators=[USE_DEFAULT, alternative_authenticator], # Extend the default!
)
def list_foos():
Expand All @@ -250,7 +250,7 @@ def list_foos():
@registry.handles(
rule="/foos",
method="GET",
marshal_schema={200: NestedFoosSchema()},
response_body_schema={200: NestedFoosSchema()},
query_string_schema=NameAndOtherSchema(),
authenticator=None, # Override the default!
)
Expand Down