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

Apiobject subclass mapping #756

Merged
merged 5 commits into from
May 3, 2018
Merged

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented May 2, 2018

Convert the APIObject into a Mapping subclass instead of a dict subclass. The idea here is that we will be able to separate out the underlying dictionary and its schema validation from the use of the APIObject subclasses in the code. I didn't go and convert existing uses and instead tossed in a getattr implementation and a comment, as I didn't want to go too far. However, I think this will make the conversion from voluptuous models to json-schema models a lot nicer, as some of the existing ones are pretty complex and tied to Python data types in a way that json-schema makes it tricky to support. Existing well-behaved code should see no impact, anything relying on writeability of APIObject and its subclasses is probably going to break. Also anything relying on the *args is going to break - I can put that back in but it makes things a tiny bit uglier.

As a bonus, I think this fixes the subclassing / init issue as long as users are careful.

This PR also includes two things we discussed on our call - cleaning up the validation error message and having deep_merge do a deep copy on all its arguments (which in turn makes the rest of APIObject a bit more pleasant).

@beckjake beckjake requested a review from cmcarthur May 2, 2018 19:55
@beckjake beckjake merged commit 2730414 into dev/betsy-ross May 3, 2018
@beckjake beckjake deleted the apiobject-subclass-mapping branch May 3, 2018 21:08
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.

3 participants