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

Using $ref resolver outside validation #422

Open
jpmckinney opened this issue Mar 22, 2023 · 1 comment
Open

Using $ref resolver outside validation #422

jpmckinney opened this issue Mar 22, 2023 · 1 comment

Comments

@jpmckinney
Copy link
Contributor

Is there currently functionality to transform a JSON Schema with $ref properties into a dereferenced JSON Schema (with sub-schema containing $ref properties replaced by the referenced schema)? e.g.

let mut schema = json!({
    "properties": {
        "foo": {"title": "Foo"},
        "bar": {"$ref": "#/properties/foo"}
    }
});

JSONSchema::dereference(&mut schema);

assert_eq!(schema, json!({
    "properties": {
        "foo": {"title": "Foo"},
        "bar": {"title": "Foo"}
    }
}))
@Stranger6667
Copy link
Owner

This would be useful indeed!

Here are a few things to think about:

  • Behavior for recursive references. I have a use case when it will be useful to inline all non-recursive references and leave recursive ones as they are. But I guess there could be other strategies too - return an error, cut at some recursion level if possible (e.g. if there is a place where the recursive branch is optional). Or maybe even a custom callback.
  • I am not 100% sure about the behavior on $dynamicRef, but it should probably work in a similar way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants