Skip to content

Create URIs (w3id.org PURLs) for Enums in same style as for classes & slots #393

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions linkml_runtime/utils/schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,9 @@ def get_uri(
elif isinstance(e, SlotDefinition):
uri = e.slot_uri
e_name = underscore(e.name)
elif isinstance(e, EnumDefinition):
uri = e.enum_uri
e_name = e.name
elif isinstance(e, TypeDefinition):
uri = e.uri
e_name = underscore(e.name)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_utils/test_schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from linkml_runtime.linkml_model.meta import (
ClassDefinition,
ClassDefinitionName,
EnumDefinition,
Example,
Prefix,
SchemaDefinition,
Expand Down Expand Up @@ -517,6 +518,9 @@ def test_imports(schema_view_with_imports: SchemaView) -> None:
assert view.get_uri("TestClass", use_element_type=True) == "core:class/TestClass"
assert view.get_uri("name", use_element_type=True) == "core:slot/name"

assert view.get_uri("OrganismType") == "ks:OrganismType"
assert view.get_uri("OrganismType", use_element_type=True) == "ks:enum/OrganismType"

assert view.get_uri("string") == "xsd:string"

# dynamic enums
Expand Down Expand Up @@ -988,6 +992,8 @@ def test_uris_without_default_prefix() -> None:
view = SchemaView(schema_definition)
view.add_class(ClassDefinition(name="TestClass", from_schema="https://example.org/another#"))
view.add_slot(SlotDefinition(name="test_slot", from_schema="https://example.org/another#"))
view.add_enum(EnumDefinition(name="tEsT_enum", from_schema="https://example.org/another#"))

assert view.get_uri("TestClass", imports=True) == "https://example.org/test#TestClass"
assert view.get_uri("test_slot", imports=True) == "https://example.org/test#test_slot"
assert view.get_uri("tEsT_enum", imports=True) == "https://example.org/test#tEsT_enum"
Loading