-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
Add component.example #515
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/apispec/core.py
Outdated
"""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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh-oh, looks like we let this slip through.
Should be "example fields".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it should be "Add example fields to the spec", right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Consistency first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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