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

Rework components interface #381

Merged
merged 10 commits into from
Feb 5, 2019
Merged

Rework components interface #381

merged 10 commits into from
Feb 5, 2019

Conversation

lafrech
Copy link
Member

@lafrech lafrech commented Feb 4, 2019

This addresses my comment here: #375 (comment).

I find it awkward to pass dicts as kwargs, and I think it would be clearer and more future-proof to pass the component dict as positional parameter, keeping kwargs only for plugin-specific parameters.

This is a totally breaking change. Tell me what you think.

I can try to fix the black issues. It would be easier if the changes were printed in the Travis log, as I wouldn't have to run it locally.

Docs would need an update.

Copy link
Member

@sloria sloria left a comment

Choose a reason for hiding this comment

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

I support this change. Just a minor suggestion re: naming.

For black formatting, I suggest using a Docker image, marshmallow-code/marshmallow#1104 (comment).

I can also fix this up for you if you don't have time.

apispec/core.py Outdated
extra_fields=None,
**kwargs
):
def schema(self, name, definition=None, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

Rather than use an OAS 2 term, "definition", what if we use a consistent parameter name for all the component methods? "component", perhaps? "obj" could also work, since OAS calls these "Objects", but that could be conflated with Python's "object".

@lafrech
Copy link
Member Author

lafrech commented Feb 4, 2019

Good. Parameter renamed. Code blacked. And I did a bit of cleanup while I was at it.

Copy link
Member

@sloria sloria left a comment

Choose a reason for hiding this comment

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

Looks good. I'll fix up the docs and update the changelog.

ret["enum"] = enum
if description:
ret["description"] = description
if extra_fields:
Copy link
Member

@sloria sloria Feb 4, 2019

Choose a reason for hiding this comment

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

Ah, nice. This cleans things up quite a bit.

special_topics.rst will need to be updated--we can probably just get rid of the "Adding Additional Fields To Schema Objects" section altogether.

Update: ended up modifying the section to show how to add additional properties to auto-generated properties.

@sloria sloria merged commit 164c35c into dev Feb 5, 2019
@sloria sloria deleted the rework_components_interface branch February 5, 2019 00:55
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