Reputation: 11067
I have a situation where I want a series of modular components to express their parameter requirements via an inline jsonschema definition, held within the code as an attribute containing a dict in which a jsonschema definition is stored. This is used to validate inputs at runtime, but also is used to build a UI at design/specification time.
Most of the time, the parameter requirements fit neatly into the vanilla string
, number
, object
sub-categories as defined by normal jsonschema - but on occasion I want to specify that a particular property be a very particular python datatype - maybe pandas.DataFrame
, numpy.ndarray
, or MyClass
.
Clearly, I'm pushing what would normally be expected of a json schema document, but this feels as though it's something that might be useful, and I was wondering if and whether this extension of the core set of datatypes was possible - and if so, how to go about defining something along those lines.
{ "title" : "Named DataFrame",
"type" : "object",
"properties" : {
"name" : { "type" : "string",
"description" : "Name of a dataframe"},
"dataframe" : { "description" : "A pandas.DataFrame object",
"type" : pandas.DataFrame }
},
"additionalProperties" : "false"}
Upvotes: 1
Views: 102
Reputation: 3429
Yes, the object responsible for this extensibility is jsonschema.TypeChecker.
Upvotes: 1