Invenio data model for OARepo
Project description
OARepo Invenio data model
Invenio base record model.
Instalation
pip install oarepo-invenio-model
Usage
The library provides extensible Invenio base record model.
JSON Schema
Add this package to your dependencies and use it via $ref in json schema.
Usage example
{
"type": "object",
"allOf": [
{
"properties": {
"title": {
"type": "string"
}
}
},
{
"$ref": "/schemas/invenio-v1.0.0.json#/definitions/InvenioRecord"
}
],
"additionalProperties": "false"
}
Elastic Search Mapping
Use oarepo-mapping-includes
library for extanding invenio base record model mapping.
Usage example
{
"mappings": {
"dynamic": "strict",
"oarepo:extends": "invenio-v1.0.0.json#/InvenioRecord",
"properties": {
"title": {
"type": "text"
}
}
}
}
Marshmallow
You can extense your schema with Invenio base model schema by inheriting from InvenioRecordMetadataSchemaV1Mixin
.
Usage example
class SampleSchemaV1(InvenioRecordMetadataSchemaV1Mixin):
title = fields.String(validate=validate.Length(min=5), required=True)
Schema inheritance
JSON Schema provides allOf
construct to join multiple schemas. The current
implementation of python's schema validator can not handle allOf
in top-level
element.
To enable composition of schemas in the form of top-level "includes":
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allOf": [
{
"$ref": "/schemas/dcterms-v2.0.0.json#/definitions/DCObject"
},
{
"$ref": "/schemas/invenio-v1.0.0.json#/definitions/InvenioRecord"
},
{
"properties": {
"category": {
"type": "string",
"enum": ["kovy", "sklo", "keramika", "textil"]
}
}
}
]
}
inherit your record class from InheritedSchemaRecordMixin
:
from oarepo_invenio_model import InheritedSchemaRecordMixin
from invenio_records.api import Record
class MyRecord(InheritedSchemaRecordMixin, Record):
pass
Changes
[Version 2.0.0]
- Update schemas, mappings and marshmallow to latest records rest schemas
- Switch record id type from string to PersistentIdentifier
[Version 1.1.0]
- Export Invenio ES mappings
Invenio base record model.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for oarepo_invenio_model-2.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18200846eb2cade80b78a1331274e9196d101ae0fe1146f0c9d5973cc41666f0 |
|
MD5 | d79d6eab75b13ce6ba4c7f7d7df62f40 |
|
BLAKE2b-256 | e9ea85e8e63a7a471bf268b24648d6ae0eedf43981488567c621b0827c108a92 |
Hashes for oarepo_invenio_model-2.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0a4b041962a6c2f46606633081c0221b787c51027ec9c61b5ef4c164dd94616 |
|
MD5 | 4afbf6df275b32b60caee5af820396c1 |
|
BLAKE2b-256 | 6acaec79965032e7a18385ab1e678f14ed88d140f180c10dddd5e05d77d797a7 |