.validate(schema) should not dereference the schema
See original GitHub issueValidator should only check if the schema is correct, but validate()
modified the input object.
(Oh my it spent my a whole hour to find validate()
mutate the object…)
Workaround: validate(_.cloneDeep(schema))
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Everit schema dereferencing - java - Stack Overflow
When I'm trying to validate some object with this schema, using everit I get the following exception: Exception in thread "main" java.io.
Read more >Validating Documents Against a JSON Schema with the JSON ...
The <json:validate-schema> operation validates that the input content is compliant with a given JSON schema.
Read more >Implementations - JSON Schema
If you have updates to this list, make a pull request on the GitHub repo. Listing does not signify a recommendation or endorsement...
Read more >JSON Schema Validation - Cloudant Blog -
It can be used to validate documents prior to being stored in the databases. If it doesn't match the specification, it's not allowed...
Read more >JSON Schema Validator - Newtonsoft
View source code. An online, interactive JSON Schema validator. Supports JSON Schema Draft 3, Draft 4, Draft 6, Draft 7 and Draft 2019-09....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re right, there are always something community will argue about I’ll wait for the isolated validator, thank you
On Tue, Jan 9, 2018, 22:31 James Messinger notifications@github.com wrote:
I agree that mutating the object is bad behavior. But here are the reasons that I chose to do it that way:
That said, there is a solution coming soon. In an upcoming release, I’ll be removing the
validate()
method altogether and moving it to a separate package. So theswagger-parser
will only contain logic for reading, parsing, resolving, and dereferencing. Theswagger-validator
package (or whatever I end up calling it) will contain the validation logic. There are several benefits to this:swagger-parser
package significantly, since its largest dependency is the JSON Schema validator. This is especially valuable for people who don’t need thevalidate()
method.swagger-parser
. So if want to use a different JSON Schema parser, or bundle-in a deep-cloning algorithm, you can do that.