diff --git a/Cargo.lock b/Cargo.lock index 831e1840f5f..b2d394f06e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -341,7 +341,7 @@ dependencies = [ "humantime", "ignore", "im-rc", - "indexmap 2.3.0", + "indexmap", "itertools 0.14.0", "jobserver", "lazycell", @@ -1482,7 +1482,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef65b256631078ef733bc5530c4e6b1c2e7d5c2830b75d4e9034ab3997d18fe" dependencies = [ "gix-hash", - "hashbrown 0.14.5", + "hashbrown", "parking_lot", ] @@ -1518,7 +1518,7 @@ dependencies = [ "gix-traverse", "gix-utils", "gix-validate", - "hashbrown 0.14.5", + "hashbrown", "itoa 1.0.11", "libc", "memmap2", @@ -1990,12 +1990,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.14.5" @@ -2012,7 +2006,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692eaaf7f7607518dd3cef090f1474b61edc5301d8012f09579920df68b725ee" dependencies = [ - "hashbrown 0.14.5", + "hashbrown", ] [[package]] @@ -2125,17 +2119,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.3.0" @@ -2143,7 +2126,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown", ] [[package]] @@ -3001,6 +2984,26 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "regex" version = "1.10.5" @@ -3165,12 +3168,12 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.21" +version = "1.0.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +checksum = "88ef2a6523400a2228db974a8ddc9e1d3deaa04f51bddd7832ef8d7e531bafcc" dependencies = [ "dyn-clone", - "indexmap 1.9.3", + "ref-cast", "schemars_derive", "semver", "serde", @@ -3179,9 +3182,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.21" +version = "1.0.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +checksum = "c6d4e1945a3c9e58edaa708449b026519f7f4197185e1b5dbc689615c1ad724d" dependencies = [ "proc-macro2", "quote", @@ -3311,10 +3314,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ + "indexmap", "itoa 1.0.11", "memchr", "ryu", @@ -3698,7 +3702,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.3.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", diff --git a/Cargo.toml b/Cargo.toml index c0d960b560d..191d5507707 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,7 @@ rustc-hash = "2.0.0" rustc-stable-hash = "0.1.1" rustfix = { version = "0.9.0", path = "crates/rustfix" } same-file = "1.0.6" -schemars = "0.8.21" +schemars = "1.0.0-alpha.17" security-framework = "3.0.0" semver = { version = "1.0.23", features = ["serde"] } serde = "1.0.204" diff --git a/crates/cargo-util-schemas/Cargo.toml b/crates/cargo-util-schemas/Cargo.toml index 8a3152ff190..eeb1af4556c 100644 --- a/crates/cargo-util-schemas/Cargo.toml +++ b/crates/cargo-util-schemas/Cargo.toml @@ -9,7 +9,7 @@ repository.workspace = true description = "Deserialization schemas for Cargo" [dependencies] -schemars = { workspace = true, features = ["preserve_order","semver"], optional = true } +schemars = { workspace = true, features = ["preserve_order", "semver1"], optional = true } semver.workspace = true serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, optional = true } diff --git a/crates/cargo-util-schemas/manifest.schema.json b/crates/cargo-util-schemas/manifest.schema.json index 8fe710d5d69..5bc43e49d37 100644 --- a/crates/cargo-util-schemas/manifest.schema.json +++ b/crates/cargo-util-schemas/manifest.schema.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "TomlManifest", "description": "This type is used to deserialize `Cargo.toml` files.", "type": "object", @@ -16,7 +16,7 @@ "package": { "anyOf": [ { - "$ref": "#/definitions/TomlPackage" + "$ref": "#/$defs/TomlPackage" }, { "type": "null" @@ -26,7 +26,7 @@ "project": { "anyOf": [ { - "$ref": "#/definitions/TomlPackage" + "$ref": "#/$defs/TomlPackage" }, { "type": "null" @@ -60,7 +60,7 @@ "lib": { "anyOf": [ { - "$ref": "#/definitions/TomlTarget" + "$ref": "#/$defs/TomlTarget" }, { "type": "null" @@ -73,7 +73,7 @@ "null" ], "items": { - "$ref": "#/definitions/TomlTarget" + "$ref": "#/$defs/TomlTarget" } }, "example": { @@ -82,7 +82,7 @@ "null" ], "items": { - "$ref": "#/definitions/TomlTarget" + "$ref": "#/$defs/TomlTarget" } }, "test": { @@ -91,7 +91,7 @@ "null" ], "items": { - "$ref": "#/definitions/TomlTarget" + "$ref": "#/$defs/TomlTarget" } }, "bench": { @@ -100,7 +100,7 @@ "null" ], "items": { - "$ref": "#/definitions/TomlTarget" + "$ref": "#/$defs/TomlTarget" } }, "dependencies": { @@ -109,7 +109,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "dev-dependencies": { @@ -118,7 +118,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "dev_dependencies": { @@ -127,7 +127,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "build-dependencies": { @@ -136,7 +136,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "build_dependencies": { @@ -145,7 +145,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "target": { @@ -154,13 +154,13 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/TomlPlatform" + "$ref": "#/$defs/TomlPlatform" } }, "lints": { "anyOf": [ { - "$ref": "#/definitions/InheritableLints" + "$ref": "#/$defs/InheritableLints" }, { "type": "null" @@ -170,7 +170,7 @@ "workspace": { "anyOf": [ { - "$ref": "#/definitions/TomlWorkspace" + "$ref": "#/$defs/TomlWorkspace" }, { "type": "null" @@ -180,7 +180,7 @@ "profile": { "anyOf": [ { - "$ref": "#/definitions/TomlProfiles" + "$ref": "#/$defs/TomlProfiles" }, { "type": "null" @@ -195,7 +195,7 @@ "additionalProperties": { "type": "object", "additionalProperties": { - "$ref": "#/definitions/TomlDependency_for_String" + "$ref": "#/$defs/TomlDependency_for_string" } } }, @@ -205,22 +205,29 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/TomlDependency_for_String" + "$ref": "#/$defs/TomlDependency_for_string" } } }, - "definitions": { + "$defs": { "TomlPackage": { - "description": "Represents the `package`/`project` sections of a `Cargo.toml`.\n\nNote that the order of the fields matters, since this is the order they are serialized to a TOML file. For example, you cannot have values after the field `metadata`, since it is a table and values cannot appear after tables.", + "description": "Represents the `package`/`project` sections of a `Cargo.toml`.\n\n Note that the order of the fields matters, since this is the order they\n are serialized to a TOML file. For example, you cannot have values after\n the field `metadata`, since it is a table and values cannot appear after\n tables.", "type": "object", - "required": [ - "name" - ], "properties": { + "description": { + "anyOf": [ + { + "$ref": "#/$defs/InheritableField_for_string" + }, + { + "type": "null" + } + ] + }, "edition": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_String" + "$ref": "#/$defs/InheritableField_for_string" }, { "type": "null" @@ -239,7 +246,7 @@ "version": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_Version" + "$ref": "#/$defs/InheritableField_for_SemVer" }, { "type": "null" @@ -249,7 +256,7 @@ "authors": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_Array_of_String" + "$ref": "#/$defs/InheritableField_for_Array_of_string" }, { "type": "null" @@ -259,7 +266,7 @@ "build": { "anyOf": [ { - "$ref": "#/definitions/StringOrBool" + "$ref": "#/$defs/StringOrBool" }, { "type": "null" @@ -269,7 +276,7 @@ "metabuild": { "anyOf": [ { - "$ref": "#/definitions/StringOrVec" + "$ref": "#/$defs/StringOrVec" }, { "type": "null" @@ -297,7 +304,7 @@ "exclude": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_Array_of_String" + "$ref": "#/$defs/InheritableField_for_Array_of_string" }, { "type": "null" @@ -307,7 +314,7 @@ "include": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_Array_of_String" + "$ref": "#/$defs/InheritableField_for_Array_of_string" }, { "type": "null" @@ -317,7 +324,7 @@ "publish": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_VecStringOrBool" + "$ref": "#/$defs/InheritableField_for_VecStringOrBool" }, { "type": "null" @@ -372,20 +379,10 @@ "null" ] }, - "description": { - "anyOf": [ - { - "$ref": "#/definitions/InheritableField_for_String" - }, - { - "type": "null" - } - ] - }, "homepage": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_String" + "$ref": "#/$defs/InheritableField_for_string" }, { "type": "null" @@ -395,7 +392,7 @@ "documentation": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_String" + "$ref": "#/$defs/InheritableField_for_string" }, { "type": "null" @@ -405,7 +402,7 @@ "readme": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_StringOrBool" + "$ref": "#/$defs/InheritableField_for_StringOrBool" }, { "type": "null" @@ -415,7 +412,7 @@ "keywords": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_Array_of_String" + "$ref": "#/$defs/InheritableField_for_Array_of_string" }, { "type": "null" @@ -425,7 +422,7 @@ "categories": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_Array_of_String" + "$ref": "#/$defs/InheritableField_for_Array_of_string" }, { "type": "null" @@ -435,7 +432,7 @@ "license": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_String" + "$ref": "#/$defs/InheritableField_for_string" }, { "type": "null" @@ -445,7 +442,7 @@ "license-file": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_String" + "$ref": "#/$defs/InheritableField_for_string" }, { "type": "null" @@ -455,7 +452,7 @@ "repository": { "anyOf": [ { - "$ref": "#/definitions/InheritableField_for_String" + "$ref": "#/$defs/InheritableField_for_string" }, { "type": "null" @@ -471,16 +468,19 @@ "metadata": { "anyOf": [ { - "$ref": "#/definitions/TomlValue" + "$ref": "#/$defs/TomlValue" }, { "type": "null" } ] } - } + }, + "required": [ + "name" + ] }, - "InheritableField_for_String": { + "InheritableField_for_string": { "description": "An enum that allows for inheriting keys from a workspace in a Cargo.toml.", "anyOf": [ { @@ -489,47 +489,42 @@ }, { "description": "The type when inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlInheritedField" - } - ] + "$ref": "#/$defs/TomlInheritedField" } ] }, "TomlInheritedField": { "type": "object", - "required": [ - "workspace" - ], "properties": { "workspace": { - "$ref": "#/definitions/WorkspaceValue" + "$ref": "#/$defs/WorkspaceValue" } - } + }, + "required": [ + "workspace" + ] }, "WorkspaceValue": { "type": "null" }, - "InheritableField_for_Version": { + "InheritableField_for_SemVer": { "description": "An enum that allows for inheriting keys from a workspace in a Cargo.toml.", "anyOf": [ { "description": "The type that is used when not inheriting from a workspace.", - "type": "string", - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" + "$ref": "#/$defs/SemVer" }, { "description": "The type when inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlInheritedField" - } - ] + "$ref": "#/$defs/TomlInheritedField" } ] }, - "InheritableField_for_Array_of_String": { + "SemVer": { + "type": "string", + "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" + }, + "InheritableField_for_Array_of_string": { "description": "An enum that allows for inheriting keys from a workspace in a Cargo.toml.", "anyOf": [ { @@ -541,11 +536,7 @@ }, { "description": "The type when inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlInheritedField" - } - ] + "$ref": "#/$defs/TomlInheritedField" } ] }, @@ -560,7 +551,7 @@ ] }, "StringOrVec": { - "description": "This can be parsed from either a TOML string or array, but is always stored as a vector.", + "description": "This can be parsed from either a TOML string or array,\n but is always stored as a vector.", "type": "array", "items": { "type": "string" @@ -571,19 +562,11 @@ "anyOf": [ { "description": "The type that is used when not inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/VecStringOrBool" - } - ] + "$ref": "#/$defs/VecStringOrBool" }, { "description": "The type when inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlInheritedField" - } - ] + "$ref": "#/$defs/TomlInheritedField" } ] }, @@ -605,19 +588,11 @@ "anyOf": [ { "description": "The type that is used when not inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/StringOrBool" - } - ] + "$ref": "#/$defs/StringOrBool" }, { "description": "The type when inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlInheritedField" - } - ] + "$ref": "#/$defs/TomlInheritedField" } ] }, @@ -730,39 +705,27 @@ "anyOf": [ { "description": "The type that is used when not inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlDependency_for_String" - } - ] + "$ref": "#/$defs/TomlDependency_for_string" }, { "description": "The type when inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlInheritedDependency" - } - ] + "$ref": "#/$defs/TomlInheritedDependency" } ] }, - "TomlDependency_for_String": { + "TomlDependency_for_string": { "anyOf": [ { - "description": "In the simple format, only a version is specified, eg. `package = \"\"`", + "description": "In the simple format, only a version is specified, eg.\n `package = \"\"`", "type": "string" }, { - "description": "The simple format is equivalent to a detailed dependency specifying only a version, eg. `package = { version = \"\" }`", - "allOf": [ - { - "$ref": "#/definitions/TomlDetailedDependency_for_String" - } - ] + "description": "The simple format is equivalent to a detailed dependency\n specifying only a version, eg.\n `package = { version = \"\" }`", + "$ref": "#/$defs/TomlDetailedDependency_for_string" } ] }, - "TomlDetailedDependency_for_String": { + "TomlDetailedDependency_for_string": { "type": "object", "properties": { "version": { @@ -778,7 +741,7 @@ ] }, "registry-index": { - "description": "The URL of the `registry` field. This is an internal implementation detail. When Cargo creates a package, it replaces `registry` with `registry-index` so that the manifest contains the correct URL. All users won't have the same registry names configured, so Cargo can't rely on just the name for crates published by other users.", + "description": "The URL of the `registry` field.\n This is an internal implementation detail. When Cargo creates a\n package, it replaces `registry` with `registry-index` so that the\n manifest contains the correct URL. All users won't have the same\n registry names configured, so Cargo can't rely on just the name for\n crates published by other users.", "type": [ "string", "null" @@ -863,7 +826,7 @@ "description": "One or more of `bin`, `cdylib`, `staticlib`, `bin:`.", "anyOf": [ { - "$ref": "#/definitions/StringOrVec" + "$ref": "#/$defs/StringOrVec" }, { "type": "null" @@ -888,9 +851,6 @@ }, "TomlInheritedDependency": { "type": "object", - "required": [ - "workspace" - ], "properties": { "workspace": { "type": "boolean" @@ -928,7 +888,10 @@ "null" ] } - } + }, + "required": [ + "workspace" + ] }, "TomlPlatform": { "description": "Corresponds to a `target` entry, but `TomlTarget` is already used.", @@ -940,7 +903,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "build-dependencies": { @@ -949,7 +912,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "build_dependencies": { @@ -958,7 +921,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "dev-dependencies": { @@ -967,7 +930,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } }, "dev_dependencies": { @@ -976,29 +939,32 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/InheritableDependency" + "$ref": "#/$defs/InheritableDependency" } } } }, "InheritableLints": { "type": "object", - "required": [ - "workspace" - ], "properties": { "workspace": { "type": "boolean" } + }, + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/TomlLint" + } } }, "TomlLint": { "anyOf": [ { - "$ref": "#/definitions/TomlLintLevel" + "$ref": "#/$defs/TomlLintLevel" }, { - "$ref": "#/definitions/TomlLintConfig" + "$ref": "#/$defs/TomlLintConfig" } ] }, @@ -1013,18 +979,21 @@ }, "TomlLintConfig": { "type": "object", - "required": [ - "level" - ], "properties": { "level": { - "$ref": "#/definitions/TomlLintLevel" + "$ref": "#/$defs/TomlLintLevel" }, "priority": { - "default": 0, "type": "integer", - "format": "int8" + "format": "int8", + "default": 0 } + }, + "required": [ + "level" + ], + "additionalProperties": { + "$ref": "#/$defs/TomlValue" } }, "TomlWorkspace": { @@ -1066,7 +1035,7 @@ "metadata": { "anyOf": [ { - "$ref": "#/definitions/TomlValue" + "$ref": "#/$defs/TomlValue" }, { "type": "null" @@ -1076,7 +1045,7 @@ "package": { "anyOf": [ { - "$ref": "#/definitions/InheritablePackage" + "$ref": "#/$defs/InheritablePackage" }, { "type": "null" @@ -1089,7 +1058,7 @@ "null" ], "additionalProperties": { - "$ref": "#/definitions/TomlDependency_for_String" + "$ref": "#/$defs/TomlDependency_for_string" } }, "lints": { @@ -1100,7 +1069,7 @@ "additionalProperties": { "type": "object", "additionalProperties": { - "$ref": "#/definitions/TomlLint" + "$ref": "#/$defs/TomlLint" } } } @@ -1110,12 +1079,21 @@ "description": "A group of fields that are inheritable by members of the workspace", "type": "object", "properties": { - "version": { + "description": { "type": [ "string", "null" - ], - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" + ] + }, + "version": { + "anyOf": [ + { + "$ref": "#/$defs/SemVer" + }, + { + "type": "null" + } + ] }, "authors": { "type": [ @@ -1126,12 +1104,6 @@ "type": "string" } }, - "description": { - "type": [ - "string", - "null" - ] - }, "homepage": { "type": [ "string", @@ -1147,7 +1119,7 @@ "readme": { "anyOf": [ { - "$ref": "#/definitions/StringOrBool" + "$ref": "#/$defs/StringOrBool" }, { "type": "null" @@ -1193,7 +1165,7 @@ "publish": { "anyOf": [ { - "$ref": "#/definitions/VecStringOrBool" + "$ref": "#/$defs/VecStringOrBool" }, { "type": "null" @@ -1247,170 +1219,170 @@ "TomlProfiles": { "type": "object", "additionalProperties": { - "$ref": "#/definitions/TomlProfile" + "$ref": "#/$defs/TomlProfile" } }, "TomlProfile": { "type": "object", "properties": { "opt-level": { - "default": null, "anyOf": [ { - "$ref": "#/definitions/TomlOptLevel" + "$ref": "#/$defs/TomlOptLevel" }, { "type": "null" } - ] + ], + "default": null }, "lto": { - "default": null, "anyOf": [ { - "$ref": "#/definitions/StringOrBool" + "$ref": "#/$defs/StringOrBool" }, { "type": "null" } - ] + ], + "default": null }, "codegen-backend": { - "default": null, "type": [ "string", "null" - ] + ], + "default": null }, "codegen-units": { - "default": null, "type": [ "integer", "null" ], "format": "uint32", - "minimum": 0.0 + "minimum": 0, + "default": null }, "debug": { - "default": null, "anyOf": [ { - "$ref": "#/definitions/TomlDebugInfo" + "$ref": "#/$defs/TomlDebugInfo" }, { "type": "null" } - ] + ], + "default": null }, "split-debuginfo": { - "default": null, "type": [ "string", "null" - ] + ], + "default": null }, "debug-assertions": { - "default": null, "type": [ "boolean", "null" - ] + ], + "default": null }, "rpath": { - "default": null, "type": [ "boolean", "null" - ] + ], + "default": null }, "panic": { - "default": null, "type": [ "string", "null" - ] + ], + "default": null }, "overflow-checks": { - "default": null, "type": [ "boolean", "null" - ] + ], + "default": null }, "incremental": { - "default": null, "type": [ "boolean", "null" - ] + ], + "default": null }, "dir-name": { - "default": null, "type": [ "string", "null" - ] + ], + "default": null }, "inherits": { - "default": null, "type": [ "string", "null" - ] + ], + "default": null }, "strip": { - "default": null, "anyOf": [ { - "$ref": "#/definitions/StringOrBool" + "$ref": "#/$defs/StringOrBool" }, { "type": "null" } - ] + ], + "default": null }, "rustflags": { - "default": null, "type": [ "array", "null" ], "items": { "type": "string" - } + }, + "default": null }, "package": { - "default": null, "type": [ "object", "null" ], "additionalProperties": { - "$ref": "#/definitions/TomlProfile" - } + "$ref": "#/$defs/TomlProfile" + }, + "default": null }, "build-override": { - "default": null, "anyOf": [ { - "$ref": "#/definitions/TomlProfile" + "$ref": "#/$defs/TomlProfile" }, { "type": "null" } - ] + ], + "default": null }, "trim-paths": { "description": "Unstable feature `-Ztrim-paths`.", - "default": null, "anyOf": [ { - "$ref": "#/definitions/TomlTrimPaths" + "$ref": "#/$defs/TomlTrimPaths" }, { "type": "null" } - ] + ], + "default": null } } }, @@ -1432,7 +1404,7 @@ { "type": "array", "items": { - "$ref": "#/definitions/TomlTrimPathsValue" + "$ref": "#/$defs/TomlTrimPathsValue" } }, { diff --git a/crates/cargo-util-schemas/src/manifest/mod.rs b/crates/cargo-util-schemas/src/manifest/mod.rs index efa125ce533..906ff3d431f 100644 --- a/crates/cargo-util-schemas/src/manifest/mod.rs +++ b/crates/cargo-util-schemas/src/manifest/mod.rs @@ -1525,6 +1525,7 @@ impl TomlPlatform { #[cfg_attr(feature = "unstable-schema", derive(schemars::JsonSchema))] pub struct InheritableLints { #[serde(skip_serializing_if = "is_false")] + #[cfg_attr(feature = "unstable-schema", schemars(default))] pub workspace: bool, #[serde(flatten)] pub lints: TomlLints, diff --git a/crates/cargo-util-schemas/src/schema.rs b/crates/cargo-util-schemas/src/schema.rs index 400997d2b41..c48c855a9f7 100644 --- a/crates/cargo-util-schemas/src/schema.rs +++ b/crates/cargo-util-schemas/src/schema.rs @@ -2,19 +2,17 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::string::String; - use toml::Value as TomlValue; #[derive(Serialize, Deserialize)] pub struct TomlValueWrapper(pub TomlValue); impl JsonSchema for TomlValueWrapper { - fn schema_name() -> String { - "TomlValue".to_string() + fn schema_name() -> std::borrow::Cow<'static, str> { + "TomlValue".into() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + fn json_schema(gen: &mut schemars::SchemaGenerator) -> schemars::Schema { // HACK: this is both more and less permissive than `TomlValue` but its close gen.subschema_for::().into() }