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

update docs to use marshmallow v3 #108

Merged
merged 1 commit into from
Mar 2, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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('/')
Expand Down Expand Up @@ -193,5 +191,5 @@ class UserSchema(Schema):

schema = UserSchema()
json_schema = JSONSchema()
json_schema.dump(schema).data
json_schema.dump(schema)
```
2 changes: 1 addition & 1 deletion example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")
Expand Down
6 changes: 3 additions & 3 deletions example/requirements.txt
Original file line number Diff line number Diff line change
@@ -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