Bug fixes:
- Add missing commas in error message for
validate.FileType(:pr:`374`).
Support:
- Support Python 3.10-3.14 (:pr:`376`).
Support:
Bug fixes:
- Fix File field when it receives an empty value (:pr:`301`, :issue:`apiflask/apiflask#551`). Thanks :user:`uncle-lv`.
- Fix validate.FileSize to handle SpooledTemporaryFile (:pr:`300`). Thanks again :user:`uncle-lv`.
Features:
- Performance improvement to validate.FileSize (:pr:`293`). Thanks :user:`uncle-lv`.
Features:
- Add type coverage (:pr:`290`).
Features:
- Add field
fields.File,validate.FileType, andvalidate.FileSizefor deserializing uploaded files (:issue:`280`, :pr:`282`). Thanks :user:`uncle-lv` for the PR - Add field
Configfor serializing Flask configuration values (:issue:`280`, :pr:`281`). Thanks :user:`greyli` for the PR.
Support:
- Support marshmallow-sqlalchemy>=0.29.0.
- Test against Python 3.12.
- Drop support for Python 3.7.
Other changes:
- Backwards-incompatible: Remove
`flask_marshmallow.__version__andflask_marshmallow.__version_info__attributes (:pr:`284`). Use feature detection orimportlib.metadata.version("flask-marshmallow")instead.
- Changes to supported software versions.
- python3.6 or later and marshmallow>=3.0.0 are now required
- Add support for python3.11
- For
sqlalchemyintegration, marshmallow-sqlalchemy>=0.28.2 and flask-sqlalchemy>=3.0.0 are now required
- Backwards-incompatible:
URLForandAbsoluteURLFornow do not accept parameters forflask.url_foras top-level parameters. They must always be passed in thevaluesdictionary, as explained in the v0.14.0 changelog.
Bug fixes:
- Address distutils deprecation warning in Python 3.10 (:pr:`242`). Thanks :user:`GabrielLins64` for the PR.
- Add
valuesargument toURLForandAbsoluteURLForfor passing values toflask.url_for. This prevents unrelated parameters from getting passed (:issue:`52`, :issue:`67`). Thanks :user:`AlrasheedA` for the PR.
Deprecation:
- Passing params to
flask.url_forviaURLFor's andAbsoluteURLFor's constructor params is deprecated. Passvaluesinstead.
# flask-marshmallow<0.14.0
class UserSchema(ma.Schema):
_links = ma.Hyperlinks(
{
"self": ma.URLFor("user_detail", id="<id>"),
}
)
# flask-marshmallow>=0.14.0
class UserSchema(ma.Schema):
_links = ma.Hyperlinks(
{
"self": ma.URLFor("user_detail", values=dict(id="<id>")),
}
)Bug fixes:
- Fix compatibility with marshmallow-sqlalchemy<0.22.0 (:issue:`189`). Thanks :user:`PatrickRic` for reporting.
Other changes:
- Remove unused
flask_marshmallow.sqla.SchemaOpts.
- Breaking change:
ma.ModelSchemaandma.TableSchemaare removed, since these are deprecated upstream.
Warning
It is highly recommended that you use the newer ma.SQLAlchemySchema and ma.SQLAlchemyAutoSchema classes
instead of ModelSchema and TableSchema. See the release notes for marshmallow-sqlalchemy 0.22.0
for instructions on how to migrate.
If you need to use ModelSchema and TableSchema for the time being, you'll need to import these directly from marshmallow_sqlalchemy.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/test.db"
db = SQLAlchemy(app)
ma = Marshmallow(app)
# flask-marshmallow<0.12.0
class AuthorSchema(ma.ModelSchema):
class Meta:
model = Author
# flask-marshmallow>=0.12.0 (recommended)
class AuthorSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Author
load_instance = True
# flask-marshmallow>=0.12.0 (not recommended)
from marshmallow_sqlalchemy import ModelSchema
class AuthorSchema(ModelSchema):
class Meta:
model = Author
sql_session = db.sessionBug fixes:
- Fix binding Flask-SQLAlchemy's scoped session to
ma.SQLAlchemySchemaandma.SQLAlchemyAutoSchema. (:issue:`180`). Thanks :user:`fnalonso` for reporting.
Features:
- Add support for
SQLAlchemySchema,SQLAlchemyAutoSchema, andauto_fieldfrom marshmallow-sqlalchemy>=0.22.0 (:pr:`166`).
Bug fixes:
- Properly restrict marshmallow-sqlalchemy version based on Python version (:pr:`158`).
Other changes:
- Test against Python 3.8.
Bug fixes:
- marshmallow 3.0.0rc6 compatibility (:pr:`134`).
Features:
- Add ma.TableSchema (:pr:`124`).
- SQLAlchemy requirements can be installed with
pip install 'flask-marshmallow[sqlalchemy]'.
Bug fixes:
URLFor,AbsoluteURLFor, andHyperlinkRelatedserialize toNoneif a passed attribute value isNone(:issue:`18`, :issue:`68`, :pr:`72`). Thanks :user:`RobinRamuel`, :user:`ocervell`, and :user:`feigner` for reporting.
Support:
- Test against Python 3.7.
- Drop support for Python 3.4. Only Python 2.7 and >=3.5 are supported.
- Add support for marshmallow 3 beta. Thanks :user:`SBillion` for the PR.
- Drop support for Python 3.3. Only Python 2.7 and >=3.4 are supported.
- Updated documentation to fix example
ma.URLFortarget.
- Fix compatibility with marshmallow>=3.0.
Support:
- Backwards-incompatible: Drop support for marshmallow<=2.0.0.
- Test against Python 3.6.
manyargument toSchema.jsonifydefaults to value of theSchemainstance'smanyattribute (:issue:`42`). Thanks :user:`singingwolfboy`.- Attach HyperlinkRelated to Marshmallow instances. Thanks :user:`singingwolfboy` for reporting.
Support:
- Upgrade to invoke>=0.13.0.
- Updated documentation to reference HyperlinkRelated instead of HyperlinkModelSchema. Thanks :user:`singingwolfboy`.
- Updated documentation links to readthedocs.io subdomain. Thanks :user:`adamchainz`.
- Fix compatibility with marshmallow>=2.0.0rc2.
Support:
- Tested against Python 3.5.
- Fix compatibility with marshmallow-sqlalchemy>=0.4.0 (:issue:`25`). Thanks :user:`svenstaro` for reporting.
Support:
- Include docs in release tarballs.
Features:
- Add Flask-SQLAlchemy/marshmallow-sqlalchemy support via the
ModelSchemaandHyperlinkModelSchemaclasses. Schema.jsonifynow takes the same arguments asmarshmallow.Schema.dump. Additional keyword arguments are passed toflask.jsonify.Hyperlinksfield supports serializing a list of hyperlinks (:issue:`11`). Thanks :user:`royrusso` for the suggestion.
Deprecation/Removal:
- Remove support for
MARSHMALLOW_DATEFORMATandMARSHMALLOW_STRICTconfig options.
Other changes:
- Drop support for marshmallow<1.2.0.
- Fix compatibility with marshmallow>=2.0.0.
- Backwards-incompatible: Remove
flask_marshmallow.SchemaOptsclass and remove support forMARSHMALLOW_DATEFORMATandMARSHMALLOW_STRICT(:issue:`8`). Prevents aRuntimeErrorwhen instantiating aSchemaoutside of a request context.
- Backwards-incompatible: Rename
URLandAbsoluteURLtoURLForandAbsoluteURLFor, respectively, to prevent overriding marshmallow'sURLfield (:issue:`6`). Thanks :user:`svenstaro` for the suggestion. - Fix bug that raised an error when deserializing
HyperlinksandURLfields (:issue:`9`). Thanks :user:`raj-kesavan` for reporting.
Deprecation:
Schema.jsonifyis deprecated. Useflask.jsonifyon the result ofSchema.dumpinstead.- The
MARSHMALLOW_DATEFORMATandMARSHMALLOW_STRICTconfig values are deprecated. Use a baseSchemaclass instead (:issue:`8`).
- Supports marshmallow >= 1.0.0-a.
- Implementation as a proper class-based Flask extension.
- Serializer and fields classes are available from the
Marshmallowobject.
- First release.
Hyperlinks,URL, andAbsoluteURLfields implemented.Serializer#jsonifyimplemented.