Add JSON Schema support (#3046)

## Summary

This PR adds JSON Schema support. The setup mirrors Ruff's own.
This commit is contained in:
Charlie Marsh
2024-04-17 13:24:41 -04:00
committed by GitHub
parent 7c5b13c412
commit 7fb2bf816f
31 changed files with 818 additions and 26 deletions
+11
View File
@@ -41,6 +41,17 @@ impl FromStr for PythonVersion {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for PythonVersion {
fn schema_name() -> String {
String::from("PythonVersion")
}
fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
<String>::json_schema(gen)
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for PythonVersion {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {