diff --git a/crates/uv-resolver/src/exclude_newer.rs b/crates/uv-resolver/src/exclude_newer.rs index 5787930760684..75564c400a47d 100644 --- a/crates/uv-resolver/src/exclude_newer.rs +++ b/crates/uv-resolver/src/exclude_newer.rs @@ -436,7 +436,6 @@ impl std::fmt::Display for ExcludeNewerValue { /// This enum represents whether exclude-newer should be disabled for a package, /// or if a specific cutoff (absolute or relative) should be used. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum PackageExcludeNewer { /// Disable exclude-newer for this package (allow all versions regardless of upload date). Disabled, @@ -444,6 +443,26 @@ pub enum PackageExcludeNewer { Enabled(Box), } +#[cfg(feature = "schemars")] +impl schemars::JsonSchema for PackageExcludeNewer { + fn schema_name() -> Cow<'static, str> { + Cow::Borrowed("PackageExcludeNewer") + } + + fn json_schema(generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema { + schemars::json_schema!({ + "oneOf": [ + { + "type": "boolean", + "const": false, + "description": "Disable exclude-newer for this package." + }, + generator.subschema_for::(), + ] + }) + } +} + /// A package-specific exclude-newer entry. #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] @@ -804,7 +823,7 @@ impl std::fmt::Display for ExcludeNewer { #[cfg(feature = "schemars")] impl schemars::JsonSchema for ExcludeNewerValue { fn schema_name() -> Cow<'static, str> { - Cow::Borrowed("ExcludeNewerTimestamp") + Cow::Borrowed("ExcludeNewerValue") } fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema { diff --git a/uv.schema.json b/uv.schema.json index 78d3e978628a7..69335a928db68 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -178,7 +178,7 @@ "description": "Limit candidate packages to those that were uploaded prior to the given date.\n\nAccepts RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`), a \"friendly\" duration (e.g.,\n`24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`, `P7D`, `P30D`).\n\nDurations do not respect semantics of the local time zone and are always resolved to a fixed\nnumber of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).\nCalendar units such as months and years are not allowed.", "anyOf": [ { - "$ref": "#/definitions/ExcludeNewerTimestamp" + "$ref": "#/definitions/ExcludeNewerValue" }, { "type": "null" @@ -810,7 +810,7 @@ "$ref": "#/definitions/PackageExcludeNewer" } }, - "ExcludeNewerTimestamp": { + "ExcludeNewerValue": { "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`), as well as relative durations (e.g., `1 week`, `30 days`, `6 months`). Relative durations are resolved to a timestamp at lock time.", "type": "string" }, @@ -1102,23 +1102,14 @@ } }, "PackageExcludeNewer": { - "description": "Per-package exclude-newer setting.\n\nThis enum represents whether exclude-newer should be disabled for a package,\nor if a specific cutoff (absolute or relative) should be used.", "oneOf": [ { - "description": "Disable exclude-newer for this package (allow all versions regardless of upload date).", - "type": "string", - "const": "Disabled" + "description": "Disable exclude-newer for this package.", + "type": "boolean", + "const": false }, { - "description": "Enable exclude-newer with this cutoff for this package.", - "type": "object", - "properties": { - "Enabled": { - "$ref": "#/definitions/ExcludeNewerTimestamp" - } - }, - "additionalProperties": false, - "required": ["Enabled"] + "$ref": "#/definitions/ExcludeNewerValue" } ] }, @@ -1232,7 +1223,7 @@ "description": "Limit candidate packages to those that were uploaded prior to a given point in time.\n\nAccepts a superset of [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339.html) (e.g.,\n`2006-12-02T02:07:43Z`). A full timestamp is required to ensure that the resolver will\nbehave consistently across timezones.", "anyOf": [ { - "$ref": "#/definitions/ExcludeNewerTimestamp" + "$ref": "#/definitions/ExcludeNewerValue" }, { "type": "null"