Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding type_mappings to metamodel #196

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 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
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






Loading