Skip to content

Commit

Permalink
Adding type_mappings to metamodel
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Jun 11, 2024
1 parent 52dd79e commit dec3d4a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
46 changes: 46 additions & 0 deletions linkml_model/model/schema/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@ slots:
description: >-
The relationship between an element and its alias.
alias_contexts:
alias: contexts
domain: structured_alias
range: uri
multivalued: true
description: >-
The context in which an alias should be applied
in_language:
slot_uri: schema:inLanguage
range: string
Expand Down Expand Up @@ -2131,6 +2139,27 @@ slots:
in_subset:
- SpecificationSubset

type_mappings:
range: type_mapping
description: >-
A collection of type mappings that specify how a slot's range should be mapped or
serialized in different frameworks
multivalued: true

framework_key:
range: string
alias: framework
key: true
description: >-
The name of a format that can be used to serialize LinkML data.
The string value should be a code from the LinkML frameworks vocabulary,
but this is not strictly enforced
mapped_type:
range: type_definition
alias: type
description: >-
type to coerce to
# -----------------------------------
# Slots for type definition
Expand Down Expand Up @@ -2763,6 +2792,7 @@ classes:
- literal_form
- alias_predicate
- categories
- alias_contexts
slot_usage:
categories:
description: >-
Expand Down Expand Up @@ -2919,6 +2949,7 @@ classes:
- disjoint_with
- children_are_mutually_disjoint
- union_of
- type_mappings
slot_usage:
is_a:
range: slot_definition
Expand Down Expand Up @@ -3181,6 +3212,20 @@ classes:
- BasicSubset
- RelationalModelProfile

type_mapping:
rank: 21
description: Represents how a slot or type can be serialized to a format.
mixins:
- extensible
- annotatable
- common_metadata
slots:
- framework_key
- mapped_type
- string_serialization
in_subset:
- SpecificationSubset

# ==================================
# Enumerations #
# ==================================
Expand Down Expand Up @@ -3274,3 +3319,4 @@ enums:
The metadata element is allowed but discouraged to be present in the model
in_subset:
- SpecificationSubset

Check failure on line 3322 in linkml_model/model/schema/meta.yaml

View workflow job for this annotation

GitHub Actions / validate-yaml

3322:1 [empty-lines] too many blank lines (1 > 0)
43 changes: 43 additions & 0 deletions tests/input/examples/schema_definition-type_mappings-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
id: https://example.org/serializations
name: serializations_example
title: Serializaations Example
description: |-
Example LinkML schema to demonstrate serialization exceptions.
prefixes:
linkml: https://w3id.org/linkml/
example: https://example.org/

default_prefix: example

imports:
- linkml:types

classes:

A:
attributes:
my_big_integer:
range: integer
type_mappings:
JSON:
type: string
description: we serialize this as a string because some json implementations may implement as doubles
PROTOBUF:
type: int64
my_date:
range: date
type_mappings:
PYTHON:
type: string
examples:
- object:
my_big_integer: 12345678901234567890
my_date: 2021-01-01






0 comments on commit dec3d4a

Please sign in to comment.