Improve JSON Schema and add export script (#3461)

## Summary

A few errors I noticed after generating the schema.
This commit is contained in:
Charlie Marsh 2024-05-08 12:15:16 -04:00 committed by GitHub
parent 18d229e2bb
commit 7c6632114b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 187 additions and 30 deletions

View file

@ -48,8 +48,20 @@ impl schemars::JsonSchema for PythonVersion {
String::from("PythonVersion")
}
fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
<String>::json_schema(gen)
fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
schemars::schema::SchemaObject {
instance_type: Some(schemars::schema::InstanceType::String.into()),
string: Some(Box::new(schemars::schema::StringValidation {
pattern: Some(r"^3\.\d+(\.\d+)?$".to_string()),
..schemars::schema::StringValidation::default()
})),
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some("A Python version specifier, e.g. `3.7` or `3.8.0`.".to_string()),
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
}
}