-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
WIP: resolve refs in schemas in one extrapolated hash #222
base: master
Are you sure you want to change the base?
Conversation
@@ -137,6 +137,10 @@ def load_ref_schema(parent_schema, ref) | |||
build_schemas(schema) | |||
end | |||
|
|||
def base_schema |
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.
It's normal to use attr_accessor
for this kind of thing.
I've had a look at this because it's a feature that I'd like to see in the gem. I think the approach is sensible, but I don't know the library very well so there might be some edge cases I'm missing. I've made a handful of stylistic comments which I hope are helpful! |
Thanks for your feedback. I'll see what I can do about the names and particularly |
I tested this branch using the following test:
It generated a NestingError regardless of the depth I allowed in the call above - this is definitely a serialization issue where the object being serialized has infinite depth due to circular references in the way the hashes are related to each other.
It's not necessarily enough to create a hash in memory and reuse existing hash object references if they can be reused during buildout. In any sufficiently complex schema where objects are being reused in multiple places in the schema hierarchy you'll end up with circular references that can't then be serialized out. To get around this, you would need to basically collapse every schema you encounter into the 'new schema file's definitions block, possibly generating new definition entries for schemas that were the root schema in a file, and updating $ref statements to point to the new schema location within the single file schema instead of reaching out to other files. |
The suggestion above is basically the process I had to go through to manually create a single-file schema from the multi-file schema set as a manual workaround for my colleague. |
Alternately, you could monitor for circular references and only allow the method to resolve a schema if it was a directed acyclical graph |
I like your first idea better and will have a look at how to do this when I find time. |
this has been quiet for a while... any updates or chances it will be finished and merged? |
Has this been abandoned? |
Any progress on this? This is very trivial feature for a web application that I am working on right now. |
@DeltaRazero we need to rebase this to merge it. If you're interested you can checkout the branch, rebase against our master and submit it as new PR. |
This is a first shot at generating a fully resolved schema hash as requested in #32.
I commented very verbosely so you can directly follow my ideas. Any comments, improvements et al?
Notes:
test_linked_list_ref
using the file path instead of the URL does not work (see comment)Questions: