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

Array merge by id schema generation #11

Merged

Conversation

birdsarah
Copy link
Contributor

Hi,

Schema generation on arrayMergeById wasn't quite right. The full problem I was trying to solve you can see here: open-contracting/standard@2104706 I think the tests captured it. Things seem to be working as I expect now although I have to confess I'm not entirely sure I understand why!

subschema = schema.get('items')

schema2 = walk.descend(subschema, meta)
return schema
Copy link
Owner

Choose a reason for hiding this comment

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

Ah, yes. There should indeed be a call to walk.descend() in get_schema() somewhere, because the merge() is also descending into subschemas. But this looks weird, since you're discarding schema2 here. I'll have to think about it.

@avian2 avian2 merged commit c282b65 into avian2:master Sep 16, 2014
@avian2
Copy link
Owner

avian2 commented Sep 16, 2014

The fact that it works this way is a bit of luck. walk.descend() was not meant to be used this way. But I can't find any example where it would break, so I'm merging this.

What you are trying to do here is have get_schema() not replace a $ref reference with a copy of the object it points to. I think you are correct in assuming there is no need for that. But the code in WalkSchema was designed to always do that on the first level (like objectMerge does). This is kind of a workaround that happens to work, but I'll see if WalkSchema.descend() can be improved to be smarter about references.

@jpmckinney jpmckinney deleted the arrayMergeById_schema_generation branch July 26, 2017 21:51
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