Looks like we correctly load the local schema as a JsonNode and then pass that to our JsonSchemaValidator with redirects setup for just http://json-schema.org/draft-04. I think, when validating the local schema internal references are being found and translated into absolute references, but nothing in the underlying validation understands that this is the the local schema that the process is starting from, and loads over http instead. Consequently adding an extra redirect for the originally loaded schema seems to hack around the problem - although I still suspect it means we're unnecessarily loading the original schema multiple times.
Tronje Krop
@tkrop
Yes, unless a cache in the parser is active to prevent this.
damned, this schema is also missing.
Rob Oxspring
@roxspring
Take a look at zalando/zally#1120 - I think this might be a reasonable bandaid
draft-04 is already being redirected for openapi-3
Tronje Krop
@tkrop
true. should have looked closer.
Rob Oxspring
@roxspring
but we're only in this branch of code because we've failed to load from the specified location
Tronje Krop
@tkrop
yes. However, I think it should be best practice to redirect every resource load, that we want to pin to a certain default resource should be mapped by default.
seems a bit crazy that we're bundling local copies of hte relevant schemas, and falling back to using them - but our default configuration is to pull fresh copies down from the internet
I wonder how much we've benefited from being able to softcode those references?
np - was very concerned that i'd caused it with my recent refactoring so was extra motivated to understand - the fix/hack was a bonus
Vadim Shaigorodskiy
@vadeg
@tkrop sure
done
Tronje Krop
@tkrop
thanks. i role out as quick as possible.
loretop
@loretop
Hello everyone, I have a question regarding adding my own rule. I'm a little lost because I'm not really sure where I should be creating my own rules, and how to know if they are being implemented correctly. Should I just add them in a package on zally/server or is it different from the way zalando/zally rulset are implemented? Also do I have to create a rulset if I want to add a single rule? I'm sorry for all the questions but I can't find much info about it (besides the documentation) or even another project that uses zally (if anyone has an example it would be super useful). I'm checking different ways to validate an api and zally caught my attention. Any help is appreciated, thank you!
Rob Oxspring
@roxspring
Hi. Work to make developing custom rules easier is coming along but still not there yet, so the viable options for now are (1) contribute your new rule to Zally itself or (2) forking the repo and adding private rules to your own fork.
All rules need to be in a ruleset, but you can likely add to ZallyRuleSet unless you really have a bunch of related rules that would make better sense as a set.
Rob Oxspring
@roxspring
Hopefully some of that helps. If you're able to keep notes of progress and discoveries along the way then I suspect they could be an invaluable starting point for some sort of user/developer guide!
loretop
@loretop
Thank you! I'm keeping some notes, if they prove to be useful I'll send them
loretop
@loretop
Hi again, I have a question regarding creating my own set of rules. I tried to create a RuleSet in a similar way to ZallyRuleSet but it doesn's seem to be working because when I try to add a Rule to it (ruleSet = MyRuleSet::class) it doesn't work. Is there another thing I should be doing besides creating the MyRuleSet class and setting it?
Rob Oxspring
@roxspring
MyRuleSet needs to implement the RuleSet interface, and likely can extend AbstractRuleSet
I started on an example external ruleset in a separate project last night - it's still work in progress but I'll push it somewhere tonight and share it
loretop
@loretop
Thank you so much! That would be very helpful
Rob Oxspring
@roxspring
So, good news here's my example as promised: https://github.com/roxspring/zally-ruleset-example Bad news: It doesn't quite work as I haven't yet figured out a good way to get the rules onto the Zally server's class path.
Rob Oxspring
@roxspring
Actually, forget that bad news. I've updated the example to patch the new rules into zally.jar and it seems to work.
Once we have official published jars and docker images then I suspect this can serve as the basis for some official docs.
loretop
@loretop
Thanks!
Vadim Shaigorodskiy
@vadeg
Hi all, I wonder what is it purpose having zally-rule-api and zally-core separate? Do we have plans to support other rule implementation?
Rob Oxspring
@roxspring
Yes, the intention is to get to a point where people can plug in custom rulesets