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

Add component.example #515

Merged
merged 1 commit into from
Nov 4, 2019
Merged

Conversation

codeasashu
Copy link
Contributor

Added tests
Completes a #245 Todo

Copy link
Member

@lafrech lafrech left a 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.

tests/utils.py Outdated Show resolved Hide resolved
tests/test_core.py Outdated Show resolved Hide resolved
src/apispec/core.py Outdated Show resolved Hide resolved
"""Add a new example to the spec

:param str name: identifier by which example may be referenced.
:param dict component: schema definition.
Copy link
Member

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".

Copy link
Contributor Author

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?

Copy link
Contributor Author

@codeasashu codeasashu Nov 4, 2019

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Consistency first.

Copy link
Contributor Author

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

tests/test_core.py Outdated Show resolved Hide resolved
src/apispec/core.py Outdated Show resolved Hide resolved
Added tests
Completes a marshmallow-code#245 Todo
@lafrech lafrech changed the title Added example support Add Components.example Nov 4, 2019
@lafrech lafrech merged commit b7c2cc5 into marshmallow-code:dev Nov 4, 2019
@lafrech lafrech changed the title Add Components.example Added component.example Nov 4, 2019
@lafrech lafrech changed the title Added component.example Add component.example Nov 4, 2019
@codeasashu codeasashu deleted the component-example branch November 4, 2019 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants