From d519a8ec11fdf4ef2c545e0a9233c449e75536dd Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Sat, 7 Mar 2026 19:31:01 -0600 Subject: [PATCH] Add $schema field to root of model for IDE usage --- src/correctionlib/schemav2.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/correctionlib/schemav2.py b/src/correctionlib/schemav2.py index 039f22b..31df598 100644 --- a/src/correctionlib/schemav2.py +++ b/src/correctionlib/schemav2.py @@ -29,7 +29,7 @@ class Model(BaseModel): - model_config = ConfigDict(extra="forbid") + model_config = ConfigDict(extra="forbid", serialize_by_alias=True) class Variable(Model): @@ -556,6 +556,15 @@ class CorrectionSet(Model): ) corrections: list[Correction] compound_corrections: Optional[list[CompoundCorrection]] = None + schema_url: Optional[str] = Field( + default="https://cms-nanoaod.github.io/correctionlib/_downloads/87e1187fe70c7ee30d50bbacaa2b2cb5/schemav2.json", + alias="$schema", + description="""\ +A URL to the schema. This is published in the correctionlib documentation +at https://cms-nanoaod.github.io/correctionlib/schemav2.html and some IDEs +may use it to provide autocompletion and validation against the schema. +""", + ) @field_validator("corrections") @classmethod