Skip to content

Commit f3f02eb

Browse files
authored
Add $schema field to root of model for IDE usage (#331)
1 parent d58875b commit f3f02eb

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/correctionlib/schemav2.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
class Model(BaseModel):
32-
model_config = ConfigDict(extra="forbid")
32+
model_config = ConfigDict(extra="forbid", serialize_by_alias=True)
3333

3434

3535
class Variable(Model):
@@ -556,6 +556,15 @@ class CorrectionSet(Model):
556556
)
557557
corrections: list[Correction]
558558
compound_corrections: Optional[list[CompoundCorrection]] = None
559+
schema_url: Optional[str] = Field(
560+
default="https://cms-nanoaod.github.io/correctionlib/_downloads/87e1187fe70c7ee30d50bbacaa2b2cb5/schemav2.json",
561+
alias="$schema",
562+
description="""\
563+
A URL to the schema. This is published in the correctionlib documentation
564+
at https://cms-nanoaod.github.io/correctionlib/schemav2.html and some IDEs
565+
may use it to provide autocompletion and validation against the schema.
566+
""",
567+
)
559568

560569
@field_validator("corrections")
561570
@classmethod

0 commit comments

Comments
 (0)