-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
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.
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): |
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.
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".
Good. Parameter renamed. Code blacked. And I did a bit of cleanup while I was at it. |
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.
Looks good. I'll fix up the docs and update the changelog.
ret["enum"] = enum | ||
if description: | ||
ret["description"] = description | ||
if extra_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.
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.
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.