mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 04:17:37 +00:00
Add JSON Schema support (#3046)
## Summary This PR adds JSON Schema support. The setup mirrors Ruff's own.
This commit is contained in:
parent
7c5b13c412
commit
7fb2bf816f
31 changed files with 818 additions and 26 deletions
|
|
@ -48,6 +48,7 @@ petgraph = { workspace = true }
|
|||
pubgrub = { workspace = true }
|
||||
rkyv = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
schemars = { workspace = true, optional = true }
|
||||
serde = { workspace = true, optional = true }
|
||||
textwrap = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -52,3 +52,24 @@ impl std::fmt::Display for ExcludeNewer {
|
|||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "schemars")]
|
||||
impl schemars::JsonSchema for ExcludeNewer {
|
||||
fn schema_name() -> String {
|
||||
"ExcludeNewer".to_string()
|
||||
}
|
||||
|
||||
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"^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2}))?$".to_string(),
|
||||
),
|
||||
..schemars::schema::StringValidation::default()
|
||||
})),
|
||||
..Default::default()
|
||||
}
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use crate::Manifest;
|
|||
feature = "serde",
|
||||
serde(deny_unknown_fields, rename_all = "kebab-case")
|
||||
)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum PreReleaseMode {
|
||||
/// Disallow all pre-release versions.
|
||||
Disallow,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use crate::{Manifest, ResolveError};
|
|||
feature = "serde",
|
||||
serde(deny_unknown_fields, rename_all = "kebab-case")
|
||||
)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum AnnotationStyle {
|
||||
/// Render the annotations on a single, comma-separated line.
|
||||
Line,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use crate::Manifest;
|
|||
feature = "serde",
|
||||
serde(deny_unknown_fields, rename_all = "kebab-case")
|
||||
)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum ResolutionMode {
|
||||
/// Resolve the highest compatible version of each package.
|
||||
#[default]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue