Add component.example#515
Conversation
lafrech
left a comment
There was a problem hiding this comment.
Thanks for this complete PR.
Just a few nitpicks and it's good to go.
I've been wondering if it would make sense to add example_helper to plugins. I guess a user could pass a schema and we could grab the example metadata from each field to build the complete example. Currently, when a user passes example as field metaclass, the value appears in the spec close to the field but not in a global response. Let's not complicate things. If someone ever needs to parse schemas to build examples, it can be done in another PR.
| """Add a new example to the spec | ||
|
|
||
| :param str name: identifier by which example may be referenced. | ||
| :param dict component: schema definition. |
There was a problem hiding this comment.
Uh-oh, looks like we let this slip through.
Should be "example fields".
There was a problem hiding this comment.
So, it should be "Add example fields to the spec", right?
There was a problem hiding this comment.
or maybe: "Add an example which can be referenced", just like we have it in parameter's docstring?
Also, I forgot to mention, :param dict component: schema definition is actually wrong, and it should be :param dict component: example object since examples are not actually definitions of anything but contains raw data?
There was a problem hiding this comment.
I've added the changes. Thanks for the reviews
dc1760d to
2ee9068
Compare
Added tests Completes a marshmallow-code#245 Todo
2ee9068 to
167a73e
Compare
Added tests
Completes a #245 Todo