Skip to content

Commit

Permalink
Merge branch 'master' into update-pypa/gh-action-pypi-release-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
VerinaG authored Mar 27, 2024
2 parents a99039d + 964057b commit baaa7a7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/why.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ There are number of packages out there that solve a similar problem. Here are ju
* `flask-apispec <https://github.com/jmcarp/flask-apispec>`_
* `Flasgger <https://github.com/rochacbruno/flasgger>`_

These are all great projects, and one might work better for your use case. Flask-Rebar solves a similar problem with its own its own twist on the approach:
These are all great projects, and one might work better for your use case. Flask-Rebar solves a similar problem with its own twist on the approach:

Marshmallow for validation *and* marshaling
-------------------------------------------
Expand All @@ -23,7 +23,7 @@ Swagger as a side effect

Some approaches generate code *from* a Swagger specification, or generate Swagger from docstrings. Flask-Rebar aims to make Swagger (a.k.a. OpenAPI) a byproduct of writing application code with Marshmallow and Flask.

This is really nice if you prefer the rich validation/transformation functionality of Marshmallow over Swagger's limited.
This is really nice if you prefer the rich validation/transformation functionality of Marshmallow over Swagger's more limited set.

It also alleviates the need to manually keep an API's documentation in sync with the actual application code - the schemas used by the application are the same schemas used to generate Swagger.

Expand Down
7 changes: 6 additions & 1 deletion flask_rebar/rebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
TypeVar,
Union,
)
from typing_extensions import ParamSpec

if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec

from werkzeug.datastructures import Headers
from werkzeug.exceptions import HTTPException
from werkzeug.routing import RequestRedirect
Expand Down
7 changes: 6 additions & 1 deletion flask_rebar/swagger_generation/marshmallow_to_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
TypeVar,
Union,
)
from typing_extensions import ParamSpec

if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec

import marshmallow as m
from marshmallow import Schema
from marshmallow.validate import Range
Expand Down
7 changes: 6 additions & 1 deletion flask_rebar/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
"""
from __future__ import annotations
import functools
import sys
import warnings
from typing import Any, Callable, Dict, NamedTuple, Optional, Tuple, TypeVar, Union
from typing_extensions import ParamSpec

if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec

from werkzeug.local import LocalProxy as module_property # noqa

Expand Down
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"types-setuptools==68.0.0.3",
]

install_requires = [
"Flask>=1.0,<4",
"marshmallow>=3.0,<4",
"typing-extensions>=4.8,<5;python_version<'3.10'",
"Werkzeug>=2.2,<4",
]

if __name__ == "__main__":
setup(
name="flask-rebar",
Expand All @@ -36,7 +43,7 @@
package_data={"flask_rebar": ["py.typed"]},
include_package_data=True,
extras_require={"dev": development, "enum": ["marshmallow-enum~=1.5"]},
install_requires=["Flask>=1.0,<4", "marshmallow>=3.0,<4"],
install_requires=install_requires,
url="https://github.com/plangrid/flask-rebar",
classifiers=[
"Environment :: Web Environment",
Expand Down
4 changes: 3 additions & 1 deletion tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
:license: MIT, see LICENSE for details.
"""
from datetime import datetime
from importlib.metadata import version
from unittest import TestCase
from pytest import mark

from marshmallow import __version_info__ as MARSHMALLOW_VERSION
from marshmallow import Schema
from marshmallow import ValidationError
from marshmallow import fields
Expand All @@ -26,6 +26,8 @@
from flask_rebar.validation import QueryParamList
from tests.test_rebar import create_rebar_app

MARSHMALLOW_VERSION = tuple(int(x) for x in version("marshmallow").split("."))


class NoRequireOnDumpMixinSchema(Schema):
optional = fields.Str()
Expand Down

0 comments on commit baaa7a7

Please sign in to comment.