Comments (5)
Update. I had a slight problem in my code - now there are no perf regressions :) Will push the new version soon
from hypothesis-jsonschema.
Huh, I'm surprised this didn't come up earlier. Rather than threading the validator we need through everywhere, how about we rip off this trick:
and just define a get_validator_for(schema)
function which tries the upstream get_validator
, and falls back to the Draft4Validator
if .check_schema()
raises? This is might be conceptually pretty dodgy, but the code will look a lot nicer!
from hypothesis-jsonschema.
It seems like a feasible approach, at least short-term. But I am concerned that it might cause potential problems in the future - for example, when Draft 2019-09 will be more common, and it will be the default validator, then it might be ambiguous what fallback should be used. Luckily, there are no backward-incompatible changes between Draft 6 & 7, so using Draft 4 should be ok.
Another thing is that for recursive schemas, there could be some more pieces to pass along - e.g., ref resolver. I was wondering if it might make sense to create a "context" object that could contain everything needed instead of passing dependencies as separate arguments. In this case, there could be a resolver and a validator, and extending it might be easier than adding new args across the codebase.
However, I feel perfectly fine with fallback to Draft 4 now - it still can be redesigned later if needed.
from hypothesis-jsonschema.
From memory all draft7 schemas are also valid in draft 2019-09, so let's stick with the simple solution for now. As you say, we can always change it over later if it stops working!
from hypothesis-jsonschema.
I found another small issue - the test suite run becomes consistently ~25% slower :( I will push the new version in a separate commit - maybe there is something with the implementation itself
from hypothesis-jsonschema.
Related Issues (20)
- New arguments to `from_schema()` to constrain generated strings
- Address warning from `jsonschema` 4.18.x HOT 2
- Redesigning canonicalization: the fundamental (internal) overhaul we need
- New feature: command-line interface
- Negative filter on "format" HOT 2
- Emit a warning when a standard format is redefined in `custom_format` HOT 5
- Unstable canonicalisation HOT 2
- Use `greenery` and `regex_transformer` to merge `pattern` and `patternProperties` keywords HOT 3
- Allow formats for non-string types HOT 1
- from_schema mutates the passed-in schema HOT 1
- `from_schema` triggers `filter_too_much` on a simple schema HOT 5
- Use the `jsonschema==4.0` interface and test against new schema versions HOT 2
- Use `propertyNames` more in canonicalisation
- Idea: detailed version-specific type annotations for `Schema` HOT 1
- Improve canonicalisation when properties have no possible values
- Missed/wrong canonicalisation in `anyOf`+`not`
- Limited string size sample HOT 1
- Error resolving sub-schema property with type object or array HOT 3
- Upstreaming HOT 4
- Better testing based on paper: *Type Safety with JSON Subschema*
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hypothesis-jsonschema.