diff --git a/src/pydantic2linkml/gen_linkml.py b/src/pydantic2linkml/gen_linkml.py index d6865094..a650d51f 100644 --- a/src/pydantic2linkml/gen_linkml.py +++ b/src/pydantic2linkml/gen_linkml.py @@ -358,6 +358,9 @@ def attach_note(note: str) -> None: slots.sort(key=str.casefold) slot_usage.sort(key=lambda s: s.name.casefold()) + # Ensure notes are sorted in a consistent order + notes.sort() + return ClassDefinition( model.__name__, description=( @@ -448,6 +451,10 @@ def generate(self) -> SlotDefinition: # Shape the contained slot according to core schema of the corresponding field self._shape_slot(self._field_schema.schema) + # Ensure the notes in the slot definition are sorted in a consistent order + assert isinstance(self._slot.notes, list) + self._slot.notes.sort() + self._used = True return self._slot