Skip to content

Commit 6ae63dc

Browse files
feat: Expose drafts 2019-09 and 2020-12 to Python (#457)
Co-authored-by: Dmitry Dygalo <[email protected]>
1 parent e15d4dd commit 6ae63dc

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

bindings/python/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Changed
66

7+
- Expose drafts 2019-09 and 2020-12 to Python
78
- Update `pyo3` to `0.20`.
89

910
## [0.17.1] - 2023-07-05

bindings/python/python/jsonschema_rs/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,5 @@ class ValidationError(ValueError):
6767
Draft4: int
6868
Draft6: int
6969
Draft7: int
70+
Draft201909: int
71+
Draft202012: int

bindings/python/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ mod types;
3434
const DRAFT7: u8 = 7;
3535
const DRAFT6: u8 = 6;
3636
const DRAFT4: u8 = 4;
37+
const DRAFT201909: u8 = 19;
38+
const DRAFT202012: u8 = 20;
3739

3840
/// An instance is invalid under a provided schema.
3941
#[pyclass(extends=exceptions::PyValueError, module="jsonschema_rs")]
@@ -117,6 +119,8 @@ fn get_draft(draft: u8) -> PyResult<Draft> {
117119
DRAFT4 => Ok(jsonschema::Draft::Draft4),
118120
DRAFT6 => Ok(jsonschema::Draft::Draft6),
119121
DRAFT7 => Ok(jsonschema::Draft::Draft7),
122+
DRAFT201909 => Ok(jsonschema::Draft::Draft201909),
123+
DRAFT202012 => Ok(jsonschema::Draft::Draft202012),
120124
_ => Err(exceptions::PyValueError::new_err(format!(
121125
"Unknown draft: {}",
122126
draft
@@ -462,6 +466,8 @@ fn jsonschema_rs(py: Python<'_>, module: &PyModule) -> PyResult<()> {
462466
module.add("Draft4", DRAFT4)?;
463467
module.add("Draft6", DRAFT6)?;
464468
module.add("Draft7", DRAFT7)?;
469+
module.add("Draft201909", DRAFT201909)?;
470+
module.add("Draft202012", DRAFT202012)?;
465471

466472
// Add build metadata to ease triaging incoming issues
467473
module.add("__build__", pyo3_built::pyo3_built!(py, build))?;

0 commit comments

Comments
 (0)