Closed lloydmeta closed 4 years ago
A relatively easy solution would be to add the ability to hook into the generation and allow it to replace the type being generated for any given field. Then override the type of any fields holding a Schema and make it hold an Arc
which would give us cheap clones.
Can you give a concrete example of how to do what you’re suggesting? You say easy but it doesn’t sounds trivial given the bootstrapping of the structs.
I could just wrap all the Schemas in Expander in Arc (or even Rc since we’re not threaded?) quite easily though I think and get cheap clones.
I gave the reference-counted Schema
idea a shot: it turns out we also need to at least RefCell
the Schema
because merge_all_of
needs a mutable Schema
called from
Not sure at this point if I'm getting further and further away from what you're envisioning, so it's the last commit and can easily be reverted if you just want to drive bit that yourself.
I opened another PR that contains a commit (14aef62450e76f7bc60881faee6c5d5c0ae10ef7) that might be closer to what you envisioned wrt adding a trigger to wrap Schema in a reference counting type, please take a look.
@Marwes I'm closing this because I think #32 is the way forward with cheaper clones due to the wrapping.
Closes #3
tl;dr Add basic support for "external"
$ref
fields that point to files.When expanding fields, if field's ref is pointing to a
.json
file, resolve it, and merge all the types it references into the current parent Expander.The changes in this PR do this by:
clone(
)s...To be honest, I need this for another project I plan on working on, so mostly hacked around until the tests passed without paying too much attention to efficiency. Here to learn so suggestions are welcome :)
Things not handled thus far: