Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
67909c92
Commit
67909c92
authored
2 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Add some user documentation on pattern properties
parent
d3e493ae
No related branches found
No related tags found
2 merge requests
!73
MAINT: change wording of TableImporter argument and allow converters and...
,
!72
Extend json-schema model parser
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/doc/index.rst
+1
-0
1 addition, 0 deletions
src/doc/index.rst
src/doc/json_schema_interface.rst
+75
-0
75 additions, 0 deletions
src/doc/json_schema_interface.rst
with
76 additions
and
0 deletions
src/doc/index.rst
+
1
−
0
View file @
67909c92
...
...
@@ -15,6 +15,7 @@ This documentation helps you to :doc:`get started<getting_started>`, explains th
Concepts <concepts>
The Caosdb Crawler <crawler>
YAML data model specification <yaml_interface>
Specifying a datamodel with JSON schema <json_schema_interface>
_apidoc/modules
...
...
This diff is collapsed.
Click to expand it.
src/doc/json_schema_interface.rst
0 → 100644
+
75
−
0
View file @
67909c92
Defining datamodels with a JSON schema specification
====================================================
TODO, see https://gitlab.com/caosdb/caosdb-advanced-user-tools/-/issues/42
Further information
###################
Pattern Properties
%%%%%%%%%%%%%%%%%%
The JSON-schema parser has rudimentary support for ``patternProperties``. Since
their names (only the pattern that their names will suffice) are not known a
priori, we create RecordTypes for all pattern properties. The names of these
RecordTypes are created from their parent element's name by appending the string
``"Entry"`` and possibly a number if there are more than one pattern properties
for one parent.
All the RecordTypes created for pattern properties have at least an boligatory
``__matched_pattern`` property which will -- as the name suggests -- store the
matched pattern of an actual data entry.
.. note::
The ``__matched_pattern`` property is added automatically to your datamodel
as soon as there is at least one pattern property in your JSON schema. So be
sure that you don't happen to have an entity with exactly this name in your
database.
E.g., a json schema with
.. code-block:: json
"dataset": {
"patternProperties": {
"^[0-9]{4,4}": {
"type": "boolean"
},
"^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}": {
"type": "object",
"properties": {
"date_id": {
"$ref": "#/definitions/uuid"
}
}
}
}
}
Would result in a ``Dataset`` RecordType that has the two properties
``DatasetEntry_1`` and ``DatasetEntry_2`` (as always, name can be overwritten
explicitly by specifying the ``title`` property), referencing corresponding
``DatasetEntry_1`` and ``DatasetEntry_2`` Records.
Apart from the aforementioned ``__matched_pattern`` property, ``DatasetEntry_1``
also has the ``DatasetEntry_1_value`` property with datatype ``BOOLEAN``, that
stores the actual value. In turn, ``DatasetEntry_2`` is of ``type: object`` and
is treated like any other RecordType. Consequently, it has, appart from the
``__matched_pattern`` property, a ``date_id`` property as specified in its
``properties``.
Array entries without ``items`` specification
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JSON schema allows for properties of ``type: array`` without the ``items``
specification that consequently can be arrays of any (and of mixed) types. While
this is in general problematic when specifying a data model, sometimes these
properties cannot be specified further, e.g., when you're using an external
schema that you cannot change.
These properties can still be added to your datamodel by specifying their types
explicitly in a dictionary or, alternatively, they can be ignored. See the
``types_for_missing_array_items`` and ``ignore_unspecified_array_items``
parameters of ``models.parser.JsonSchemaParser``, respectively, for more
information.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment