Skip to content
Snippets Groups Projects

F json schema datamodel

Merged Florian Spreckelsen requested to merge f-json-schema-datamodel into dev
2 files
+ 51
11
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -151,7 +151,25 @@ def parse_model_from_string(string):
@@ -151,7 +151,25 @@ def parse_model_from_string(string):
def parse_model_from_json_schema(filename: str):
def parse_model_from_json_schema(filename: str):
"""Return a datamodel parsed from a json schema definition."""
"""Return a datamodel parsed from a json schema definition.
 
 
Parameters
 
----------
 
filename : str
 
The path of the json schema file that is to be parsed
 
 
Returns
 
-------
 
out : Datamodel
 
The datamodel generated from the input schema which then can be used for
 
synchronizing with CaosDB.
 
 
Note
 
----
 
This is an experimental feature, see ``JsonSchemaParser`` for information
 
about the limitations of the current implementation.
 
 
"""
# @author Florian Spreckelsen
# @author Florian Spreckelsen
# @date 2022-02-17
# @date 2022-02-17
# @review Daniel Hornung 2022-02-18
# @review Daniel Hornung 2022-02-18
@@ -566,7 +584,27 @@ class Parser(object):
@@ -566,7 +584,27 @@ class Parser(object):
class JsonSchemaParser(Parser):
class JsonSchemaParser(Parser):
"""Extends the yaml parser to read in datamodels defined in a json schema."""
"""Extends the yaml parser to read in datamodels defined in a json schema.
 
 
**EXPERIMENTAL:** While this calss can already be used to create data models
 
from basic json schemas, there are the following limitations and missing
 
features:
 
 
* Due to limitations of json-schema itself, we currently do not support
 
inheritance in the imported data models
 
* The same goes for suggested properties of RecordTypes
 
* Currently, ``$defs`` and ``$ref`` in the input schema are not resolved.
 
* Already defined RecordTypes and (scalar) Properties can't be re-used as
 
list properties
 
* Reference properties that are different from the referenced RT. (Although
 
this is possible for list of references)
 
* Values
 
* Roles
 
* The extern keyword from the yaml parser
 
* Currently, a json-schema cannot be transformed into a data model if its
 
root element isn't a RecordType (or Property) with ``title`` and ``type``.
 
 
"""
# @author Florian Spreckelsen
# @author Florian Spreckelsen
# @date 2022-02-17
# @date 2022-02-17
# @review Timm Fitschen 2022-02-30
# @review Timm Fitschen 2022-02-30
Loading