-
Notifications
You must be signed in to change notification settings - Fork 65
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
Schema#ref does not apply custom configuration options #198
Comments
Ha! I've found a solution. configuration = JSONSchemer::Configuration.new(insert_property_defaults: true)
doc = JSONSchemer.openapi(resolved, configuration:)
content_schema = doc.ref('/components/schemas/MySchema')
content_schema.validate(data) # Succeeds! Thanks! 🦆 |
Hi @ahx, sorry for the delay here. I'm going to reopen this because I think it's an issue that subschemas don't inherit some options. It seems like we need to merge (some of?) the json_schemer/lib/json_schemer/schema.rb Line 78 in 2a239b6
so that they get passed to the ref schema: json_schemer/lib/json_schemer/schema.rb Line 191 in 2a239b6
Let me know if you want to work on a fix! |
Hey David, I agree and I would like to work on a fix. I'll try to work on this. If I don't get back here until the new year, feel free to poke me. |
Yep, also hit this case. The library defaults get inherited.
it took me a moment to figure out that “root” is not “root”, but in the “parsed” loop below it saw the properties, then I came up with the issue. |
Hi. What I would like to do is to use
insert_property_defaults: true
for subschemas that are adressed viaSchema#ref
without globally changingJSONSchemer.configuration
.But currently that does not seem to be possible, because
Schema#ref
does not apply the custom local options, but only uses the global configuration and passinginsert_property_defaults: true
toSchema#validate
is not supported.Here is an example:
If you have a suggestion for an API to solve this, I'd be happy to try to create a PR for that.
The text was updated successfully, but these errors were encountered: