From ac79c0043b0bc8c094e05d00e962660d5eb02b39 Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Mon, 2 Mar 2020 20:55:57 +0000 Subject: [PATCH] update docs to use marshmallow v3 --- README.md | 14 ++++++-------- example/example.py | 2 +- example/requirements.txt | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d59520f..1dce08e 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,8 @@ pip install marshmallow-jsonschema ### Examples -Word of caution: starting with marshmallow 3.0.0b7, `.dump()` now directly returns -`data` instead of `(error, data)`, as noted in [marshmallow's changelog](https://github.com/marshmallow-code/marshmallow/blob/8cf1fb8d95f287d626ed0f38967c90198e28b476/CHANGELOG.rst#300b7-2018-02-03). -marshmallow-jsonschema is directly affected by this and the examples below are -for marshmallow<=3.0.0b7. To upgrade to >=3.0.0b7, remove the `.data` from the code. +Note that while these examples are using marshmallow v3 API, marshmallow v2 is +also still supported and part of the build. Support will be dropped for v2 in a future release. #### Simple Example @@ -48,7 +46,7 @@ class UserSchema(Schema): user_schema = UserSchema() json_schema = JSONSchema() -json_schema.dump(user_schema).data +json_schema.dump(user_schema) ``` Yields: ```python @@ -86,7 +84,7 @@ class AthleteSchema(Schema): athlete = Athlete() athlete_schema = AthleteSchema() -athlete_schema.dump(athlete).data +athlete_schema.dump(athlete) ``` #### Complete example Flask application using brutisin/json-forms @@ -115,7 +113,7 @@ class UserSchema(Schema): @app.route('/schema') def schema(): schema = UserSchema() - return jsonify(JSONSchema().dump(schema).data) + return jsonify(JSONSchema().dump(schema)) @app.route('/') @@ -193,5 +191,5 @@ class UserSchema(Schema): schema = UserSchema() json_schema = JSONSchema() -json_schema.dump(schema).data +json_schema.dump(schema) ``` diff --git a/example/example.py b/example/example.py index 90e2e2b..741648c 100644 --- a/example/example.py +++ b/example/example.py @@ -13,7 +13,7 @@ class UserSchema(Schema): @app.route("/schema") def schema(): schema = UserSchema() - return jsonify(JSONSchema().dump(schema).data) + return jsonify(JSONSchema().dump(schema)) @app.route("/") diff --git a/example/requirements.txt b/example/requirements.txt index b125d94..9814899 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1,3 +1,3 @@ -Flask>=0.10.1 -marshmallow>=2.6.0 -marshmallow-jsonschema>=0.1.6 +Flask>=1.1.1 +marshmallow>=3 +marshmallow-jsonschema>=0.9.0