Update schemars 1.0.0 (#13693)
Some checks are pending
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks | walltime aarch64 linux (push) Blocked by required conditions
CI / benchmarks | instrumented (push) Blocked by required conditions
CI / lint (push) Waiting to run
CI / Determine changes (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / build binary | linux libc (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | pyodide on ubuntu (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | registries (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | graalpy on ubuntu (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary
Update [schemars
0.9.0](https://github.com/GREsau/schemars/releases/tag/v0.9.0)

There are differences in the generated JSON Schema and I will [contact
the author](https://github.com/GREsau/schemars/issues/407).

## Test Plan

---------

Co-authored-by: konstin <konstin@mailbox.org>
This commit is contained in:
ya7010 2025-06-25 04:43:31 +09:00 committed by GitHub
parent 9fba7a4768
commit ac788d7cde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 524 additions and 813 deletions

9
Cargo.lock generated
View file

@ -3405,11 +3405,12 @@ dependencies = [
[[package]] [[package]]
name = "schemars" name = "schemars"
version = "0.8.22" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" checksum = "febc07c7e70b5db4f023485653c754d76e1bbe8d9dbfa20193ce13da9f9633f4"
dependencies = [ dependencies = [
"dyn-clone", "dyn-clone",
"ref-cast",
"schemars_derive", "schemars_derive",
"serde", "serde",
"serde_json", "serde_json",
@ -3418,9 +3419,9 @@ dependencies = [
[[package]] [[package]]
name = "schemars_derive" name = "schemars_derive"
version = "0.8.22" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" checksum = "c1eeedaab7b1e1d09b5b4661121f4d27f9e7487089b0117833ccd7a882ee1ecc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -151,7 +151,7 @@ rust-netrc = { version = "0.1.2" }
rustc-hash = { version = "2.0.0" } rustc-hash = { version = "2.0.0" }
rustix = { version = "1.0.0", default-features = false, features = ["fs", "std"] } rustix = { version = "1.0.0", default-features = false, features = ["fs", "std"] }
same-file = { version = "1.0.6" } same-file = { version = "1.0.6" }
schemars = { version = "0.8.21", features = ["url"] } schemars = { version = "1.0.0", features = ["url2"] }
seahash = { version = "4.1.0" } seahash = { version = "4.1.0" }
self-replace = { version = "1.5.0" } self-replace = { version = "1.5.0" }
serde = { version = "1.0.210", features = ["derive", "rc"] } serde = { version = "1.0.210", features = ["derive", "rc"] }

View file

@ -1,4 +1,4 @@
use std::str::FromStr; use std::{borrow::Cow, str::FromStr};
use uv_pep508::PackageName; use uv_pep508::PackageName;
@ -63,28 +63,16 @@ impl<'de> serde::Deserialize<'de> for PackageNameSpecifier {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for PackageNameSpecifier { impl schemars::JsonSchema for PackageNameSpecifier {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"PackageNameSpecifier".to_string() Cow::Borrowed("PackageNameSpecifier")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_gen: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
string: Some(Box::new(schemars::schema::StringValidation { "pattern": r"^(:none:|:all:|([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]))$",
// See: https://packaging.python.org/en/latest/specifications/name-normalization/#name-format "description": "The name of a package, or `:all:` or `:none:` to select or omit all packages, respectively.",
pattern: Some( })
r"^(:none:|:all:|([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]))$"
.to_string(),
),
..schemars::schema::StringValidation::default()
})),
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some("The name of a package, or `:all:` or `:none:` to select or omit all packages, respectively.".to_string()),
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -1,5 +1,5 @@
use std::fmt::Formatter;
use std::str::FromStr; use std::str::FromStr;
use std::{borrow::Cow, fmt::Formatter};
use uv_pep440::{Version, VersionSpecifier, VersionSpecifiers, VersionSpecifiersParseError}; use uv_pep440::{Version, VersionSpecifier, VersionSpecifiers, VersionSpecifiersParseError};
@ -36,20 +36,15 @@ impl FromStr for RequiredVersion {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for RequiredVersion { impl schemars::JsonSchema for RequiredVersion {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
String::from("RequiredVersion") Cow::Borrowed("RequiredVersion")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
metadata: Some(Box::new(schemars::schema::Metadata { "description": "A version specifier, e.g. `>=0.5.0` or `==0.5.0`."
description: Some("A version specifier, e.g. `>=0.5.0` or `==0.5.0`.".to_string()), })
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -1,5 +1,5 @@
use serde::{Deserialize, Deserializer}; use serde::{Deserialize, Deserializer};
use std::str::FromStr; use std::{borrow::Cow, str::FromStr};
use url::Url; use url::Url;
/// A host specification (wildcard, or host, with optional scheme and/or port) for which /// A host specification (wildcard, or host, with optional scheme and/or port) for which
@ -143,20 +143,15 @@ impl std::fmt::Display for TrustedHost {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for TrustedHost { impl schemars::JsonSchema for TrustedHost {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"TrustedHost".to_string() Cow::Borrowed("TrustedHost")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
metadata: Some(Box::new(schemars::schema::Metadata { "description": "A host or host-port pair."
description: Some("A host or host-port pair.".to_string()), })
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
use anstream::println; use anstream::println;
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use pretty_assertions::StrComparison; use pretty_assertions::StrComparison;
use schemars::{JsonSchema, schema_for}; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use uv_settings::Options as SettingsOptions; use uv_settings::Options as SettingsOptions;
@ -91,7 +91,10 @@ const REPLACEMENTS: &[(&str, &str)] = &[
/// Generate the JSON schema for the combined options as a string. /// Generate the JSON schema for the combined options as a string.
fn generate() -> String { fn generate() -> String {
let schema = schema_for!(CombinedOptions); let settings = schemars::generate::SchemaSettings::draft07();
let generator = schemars::SchemaGenerator::new(settings);
let schema = generator.into_root_schema_for::<CombinedOptions>();
let mut output = serde_json::to_string_pretty(&schema).unwrap(); let mut output = serde_json::to_string_pretty(&schema).unwrap();
for (value, replacement) in REPLACEMENTS { for (value, replacement) in REPLACEMENTS {

View file

@ -92,20 +92,15 @@ impl IndexUrl {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for IndexUrl { impl schemars::JsonSchema for IndexUrl {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"IndexUrl".to_string() Cow::Borrowed("IndexUrl")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
metadata: Some(Box::new(schemars::schema::Metadata { "description": "The URL of an index to use for fetching packages (e.g., `https://pypi.org/simple`), or a local path."
description: Some("The URL of an index to use for fetching packages (e.g., `https://pypi.org/simple`), or a local path.".to_string()), })
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -3,7 +3,7 @@
//! flags set. //! flags set.
use serde::{Deserialize, Deserializer, Serialize}; use serde::{Deserialize, Deserializer, Serialize};
use std::path::Path; use std::{borrow::Cow, path::Path};
use crate::{Index, IndexUrl}; use crate::{Index, IndexUrl};
@ -50,14 +50,14 @@ macro_rules! impl_index {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for $name { impl schemars::JsonSchema for $name {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
IndexUrl::schema_name() IndexUrl::schema_name()
} }
fn json_schema( fn json_schema(
r#gen: &mut schemars::r#gen::SchemaGenerator, generator: &mut schemars::generate::SchemaGenerator,
) -> schemars::schema::Schema { ) -> schemars::Schema {
IndexUrl::json_schema(r#gen) IndexUrl::json_schema(generator)
} }
} }
}; };

View file

@ -1,4 +1,4 @@
use std::ops::Deref; use std::{borrow::Cow, ops::Deref};
use http::StatusCode; use http::StatusCode;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
@ -136,17 +136,17 @@ impl<'de> Deserialize<'de> for SerializableStatusCode {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for SerializableStatusCode { impl schemars::JsonSchema for SerializableStatusCode {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"StatusCode".to_string() Cow::Borrowed("StatusCode")
} }
fn json_schema(r#gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
let mut schema = r#gen.subschema_for::<u16>().into_object(); schemars::json_schema!({
schema.metadata().description = Some("HTTP status code (100-599)".to_string()); "type": "number",
schema.number().minimum = Some(100.0); "minimum": 100,
schema.number().maximum = Some(599.0); "maximum": 599,
"description": "HTTP status code (100-599)"
schema.into() })
} }
} }

View file

@ -330,11 +330,11 @@ pub struct PortablePathBuf(Box<Path>);
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for PortablePathBuf { impl schemars::JsonSchema for PortablePathBuf {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
PathBuf::schema_name() Cow::Borrowed("PortablePathBuf")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_gen: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
PathBuf::json_schema(_gen) PathBuf::json_schema(_gen)
} }
} }

View file

@ -41,7 +41,7 @@ version-ranges = { workspace = true }
[dev-dependencies] [dev-dependencies]
insta = { version = "1.40.0" } insta = { version = "1.40.0" }
serde_json = { version = "1.0.128" } serde_json = { workspace = true }
tracing-test = { version = "0.2.5" } tracing-test = { version = "0.2.5" }
[features] [features]

View file

@ -16,6 +16,7 @@
#![warn(missing_docs)] #![warn(missing_docs)]
use std::borrow::Cow;
use std::error::Error; use std::error::Error;
use std::fmt::{Debug, Display, Formatter}; use std::fmt::{Debug, Display, Formatter};
use std::path::Path; use std::path::Path;
@ -334,22 +335,15 @@ impl Reporter for TracingReporter {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl<T: Pep508Url> schemars::JsonSchema for Requirement<T> { impl<T: Pep508Url> schemars::JsonSchema for Requirement<T> {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"Requirement".to_string() Cow::Borrowed("Requirement")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_gen: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
metadata: Some(Box::new(schemars::schema::Metadata { "description": "A PEP 508 dependency specifier, e.g., `ruff >= 0.6.0`"
description: Some( })
"A PEP 508 dependency specifier, e.g., `ruff >= 0.6.0`".to_string(),
),
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -1707,23 +1707,15 @@ impl Display for MarkerTreeContents {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for MarkerTree { impl schemars::JsonSchema for MarkerTree {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"MarkerTree".to_string() Cow::Borrowed("MarkerTree")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
metadata: Some(Box::new(schemars::schema::Metadata { "description": "A PEP 508-compliant marker expression, e.g., `sys_platform == 'Darwin'`"
description: Some( })
"A PEP 508-compliant marker expression, e.g., `sys_platform == 'Darwin'`"
.to_string(),
),
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }
@ -2515,7 +2507,7 @@ mod test {
#[test] #[test]
fn test_simplification_extra_versus_other() { fn test_simplification_extra_versus_other() {
// Here, the `extra != 'foo'` cannot be simplified out, because // Here, the `extra != 'foo'` cannot be simplified out, because
// `extra == 'foo'` can be true even when `extra == 'bar`' is true. // `extra == 'foo'` can be true even when `extra == 'bar'`' is true.
assert_simplifies( assert_simplifies(
r#"extra != "foo" and (extra == "bar" or extra == "baz")"#, r#"extra != "foo" and (extra == "bar" or extra == "baz")"#,
"(extra == 'bar' and extra != 'foo') or (extra == 'baz' and extra != 'foo')", "(extra == 'bar' and extra != 'foo') or (extra == 'baz' and extra != 'foo')",

View file

@ -3,7 +3,7 @@ use petgraph::{
graph::{DiGraph, NodeIndex}, graph::{DiGraph, NodeIndex},
}; };
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use std::{collections::BTreeSet, hash::Hash, rc::Rc}; use std::{borrow::Cow, collections::BTreeSet, hash::Hash, rc::Rc};
use uv_normalize::{ExtraName, GroupName, PackageName}; use uv_normalize::{ExtraName, GroupName, PackageName};
use crate::dependency_groups::{DependencyGroupSpecifier, DependencyGroups}; use crate::dependency_groups::{DependencyGroupSpecifier, DependencyGroups};
@ -638,12 +638,12 @@ pub struct SchemaConflictItem {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for SchemaConflictItem { impl schemars::JsonSchema for SchemaConflictItem {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"SchemaConflictItem".to_string() Cow::Borrowed("SchemaConflictItem")
} }
fn json_schema(r#gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
<ConflictItemWire as schemars::JsonSchema>::json_schema(r#gen) <ConflictItemWire as schemars::JsonSchema>::json_schema(generator)
} }
} }

View file

@ -1,4 +1,5 @@
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use std::borrow::Cow;
use std::fmt::Display; use std::fmt::Display;
use std::str::FromStr; use std::str::FromStr;
use thiserror::Error; use thiserror::Error;
@ -99,25 +100,16 @@ impl Serialize for Identifier {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for Identifier { impl schemars::JsonSchema for Identifier {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"Identifier".to_string() Cow::Borrowed("Identifier")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
string: Some(Box::new(schemars::schema::StringValidation { "pattern": r"^[_\p{Alphabetic}][_0-9\p{Alphabetic}]*$",
// Best-effort Unicode support (https://stackoverflow.com/a/68844380/3549270) "description": "An identifier in Python"
pattern: Some(r"^[_\p{Alphabetic}][_0-9\p{Alphabetic}]*$".to_string()), })
..schemars::schema::StringValidation::default()
})),
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some("An identifier in Python".to_string()),
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use std::ops::Deref; use std::ops::Deref;
use std::str::FromStr; use std::str::FromStr;
@ -65,26 +66,16 @@ impl FromStr for PythonVersion {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for PythonVersion { impl schemars::JsonSchema for PythonVersion {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
String::from("PythonVersion") Cow::Borrowed("PythonVersion")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
string: Some(Box::new(schemars::schema::StringValidation { "pattern": r"^3\.\d+(\.\d+)?$",
pattern: Some(r"^3\.\d+(\.\d+)?$".to_string()), "description": "A Python version specifier, e.g. `3.11` or `3.12.4`."
..schemars::schema::StringValidation::default() })
})),
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
"A Python version specifier, e.g. `3.11` or `3.12.4`.".to_string(),
),
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -1,4 +1,4 @@
use std::str::FromStr; use std::{borrow::Cow, str::FromStr};
use jiff::{Timestamp, ToSpan, tz::TimeZone}; use jiff::{Timestamp, ToSpan, tz::TimeZone};
@ -67,25 +67,15 @@ impl std::fmt::Display for ExcludeNewer {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for ExcludeNewer { impl schemars::JsonSchema for ExcludeNewer {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
"ExcludeNewer".to_string() Cow::Borrowed("ExcludeNewer")
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
schemars::schema::SchemaObject { schemars::json_schema!({
instance_type: Some(schemars::schema::InstanceType::String.into()), "type": "string",
string: Some(Box::new(schemars::schema::StringValidation { "pattern": r"^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2}))?$",
pattern: Some( "description": "Exclude distributions uploaded after the given timestamp.\n\nAccepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same format (e.g., `2006-12-02`).",
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()
})),
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some("Exclude distributions uploaded after the given timestamp.\n\nAccepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same format (e.g., `2006-12-02`).".to_string()),
..schemars::schema::Metadata::default()
})),
..schemars::schema::SchemaObject::default()
}
.into()
} }
} }

View file

@ -41,6 +41,7 @@ pub(crate) struct Tools {
#[derive(Debug, Clone, Default, Deserialize, CombineOptions, OptionsMetadata)] #[derive(Debug, Clone, Default, Deserialize, CombineOptions, OptionsMetadata)]
#[serde(from = "OptionsWire", rename_all = "kebab-case")] #[serde(from = "OptionsWire", rename_all = "kebab-case")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "schemars", schemars(!from))]
pub struct Options { pub struct Options {
#[serde(flatten)] #[serde(flatten)]
pub globals: GlobalOptions, pub globals: GlobalOptions,

View file

@ -147,15 +147,15 @@ impl PartialOrd<SmallString> for rkyv::string::ArchivedString {
/// An [`schemars::JsonSchema`] implementation for [`SmallString`]. /// An [`schemars::JsonSchema`] implementation for [`SmallString`].
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for SmallString { impl schemars::JsonSchema for SmallString {
fn is_referenceable() -> bool { fn inline_schema() -> bool {
String::is_referenceable() true
} }
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
String::schema_name() String::schema_name()
} }
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
String::json_schema(_gen) String::json_schema(generator)
} }
} }

View file

@ -6,6 +6,7 @@
//! //!
//! Then lowers them into a dependency specification. //! Then lowers them into a dependency specification.
use std::borrow::Cow;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::fmt::Formatter; use std::fmt::Formatter;
use std::ops::Deref; use std::ops::Deref;
@ -813,12 +814,12 @@ impl<'de> serde::Deserialize<'de> for SerdePattern {
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
impl schemars::JsonSchema for SerdePattern { impl schemars::JsonSchema for SerdePattern {
fn schema_name() -> String { fn schema_name() -> Cow<'static, str> {
<String as schemars::JsonSchema>::schema_name() Cow::Borrowed("SerdePattern")
} }
fn json_schema(r#gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { fn json_schema(generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema {
<String as schemars::JsonSchema>::json_schema(r#gen) <String as schemars::JsonSchema>::json_schema(generator)
} }
} }

1031
uv.schema.json generated

File diff suppressed because it is too large Load diff