Comments (4)
The term 'scope' comes from 'dynamic scope' described...
Thanks for linking. TIL.
the existence or otherwise of child property nodes for additionalProperties should impact your sort algorithm, as the schema wouldn't know about those properties anyway
The idea was a somewhat obscure ability for a schema to hint whether additional properties should be ordered before or after all other properties. Right now it's hardcoded to 'after'. Considering patternProperties
do work, I'll close this one.
from jschon.
Hi Ilya, glad to hear you are finding jschon useful. Could you perhaps provide an example to clarify the issue you are describing, and what your expectation would be?
The Scope.schema
attribute is there primarily to be able to generate absolute URIs for annotation and error output - though it's also used in $dynamicRef
resolution. So yours is an interesting use case because it's an 'unexpected' way of using Scope.schema
! It has been in the back of my mind to look more carefully at how boolean schemas are processed - there's an issue with poor error messaging for e.g. "additionalProperties": false
- and I have a very speculative hunch that these issues might be related.
from jschon.
My tool reorders properties to be in the same order as they're defined in the schema. It relies on mapping from the document to the schema that's in the evaluation results. (Welcome to see how it's implemented, there's not much to it.)
For additional properties, I would expect a mapping from each such otherwise unknown property to the additionalProperties that allows it, though I'm not sure if that's all that obvious for it to happen.
from jschon.
Okay, I see that you're using the instpath
and path
attributes of scope nodes to create a mapping from document nodes to schema 'sort keys', and I see how this enables you to sort document nodes that have been validated by properties
. (This is very cool, btw!)
So I've worked through your test case, adding an additional "foo" property to your test instance, and setting the inner additionalProperties
value to True
in the test schema. I understand that in your _traverse_scope
function, you might expect to visit a scope child node with instpath
pointing to /ranges/0/foo
, with a corresponding path
of /properties/ranges/items/additionalProperties
.
The difficulty here is that document evaluation is done from the perspective of the schema, and the resultant structure of the scope tree reflects the evaluation path taken through the schema and any referenced schemas. (The term 'scope' comes from 'dynamic scope' described here). So in the scope tree, under a properties
node, you'll have child nodes for each of the properties that appear in the schema (each of those child nodes being associated with a property subschema), but you won't have any such child nodes under an additionalProperties
node, because the value for additionalProperties
is just a single subschema, against which any additional properties are validated. The names of any properties validated by the additionalProperties
keyword are stored in the annotation
of the corresponding scope node.
Having said all that, unless I'm missing something, I don't think the existence or otherwise of child property nodes for additionalProperties
should impact your sort algorithm, as the schema wouldn't know about those properties anyway?
from jschon.
Related Issues (20)
- Configure annotations HOT 3
- Roadmap HOT 3
- Making oneOf/anyOf schema evaluation easier by discriminator value HOT 2
- Format validation HOT 1
- Modify error message for enum HOT 1
- Provide Error Code along with error messages in output format HOT 3
- Allow customization of error messages
- Loading a metaschema from disk doesn't load as a metaschema but instead as a JSONSchema HOT 3
- Inspecting the state of the catalog before calling `create_metaschema` corrupts the catalog. HOT 4
- Need support for error message while forming a `Node` class object in `Jsonpatch` HOT 1
- Validate Schema against meta Schema HOT 1
- Object properties are only evaluated against core vocabulary when `$dynamicAnchor` is in place HOT 2
- Transforming data to schema compatible json
- Test issue with hypothesis>=6.0.4 and python>=3.10 HOT 1
- Support for Python 3.11? HOT 1
- Tests for malformed [Relative] JSON Pointers
- Add support for "list" output HOT 2
- Document existing support for "hierarchical" output HOT 1
- Document how to pre-populate the catalog more clearly HOT 3
- Config to stop processing as soon as an error is encountered would be useful.
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 jschon.