From 729776b5890e3822374ef9a93152a4eccf381752 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 1 Jan 2025 10:14:31 -0600 Subject: [PATCH] fix(schema): Correct and update the JSON Schema Fixes #14999 --- .../cargo-util-schemas/manifest.schema.json | 696 +++++++++--------- crates/cargo-util-schemas/src/manifest/mod.rs | 2 +- 2 files changed, 349 insertions(+), 349 deletions(-) diff --git a/crates/cargo-util-schemas/manifest.schema.json b/crates/cargo-util-schemas/manifest.schema.json index 000f15f2300..37f84f4f792 100644 --- a/crates/cargo-util-schemas/manifest.schema.json +++ b/crates/cargo-util-schemas/manifest.schema.json @@ -33,15 +33,29 @@ } ] }, - "profile": { - "anyOf": [ - { - "$ref": "#/definitions/TomlProfiles" - }, - { - "type": "null" + "badges": { + "type": [ + "object", + "null" + ], + "additionalProperties": { + "type": "object", + "additionalProperties": { + "type": "string" } - ] + } + }, + "features": { + "type": [ + "object", + "null" + ], + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } }, "lib": { "anyOf": [ @@ -134,18 +148,6 @@ "$ref": "#/definitions/InheritableDependency" } }, - "features": { - "type": [ - "object", - "null" - ], - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, "target": { "type": [ "object", @@ -155,26 +157,15 @@ "$ref": "#/definitions/TomlPlatform" } }, - "replace": { - "type": [ - "object", - "null" - ], - "additionalProperties": { - "$ref": "#/definitions/TomlDependency_for_String" - } - }, - "patch": { - "type": [ - "object", - "null" - ], - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TomlDependency_for_String" + "lints": { + "anyOf": [ + { + "$ref": "#/definitions/InheritableLints" + }, + { + "type": "null" } - } + ] }, "workspace": { "anyOf": [ @@ -186,7 +177,17 @@ } ] }, - "badges": { + "profile": { + "anyOf": [ + { + "$ref": "#/definitions/TomlProfiles" + }, + { + "type": "null" + } + ] + }, + "patch": { "type": [ "object", "null" @@ -194,24 +195,23 @@ "additionalProperties": { "type": "object", "additionalProperties": { - "type": "string" + "$ref": "#/definitions/TomlDependency_for_String" } } }, - "lints": { - "anyOf": [ - { - "$ref": "#/definitions/InheritableLints" - }, - { - "type": "null" - } - ] + "replace": { + "type": [ + "object", + "null" + ], + "additionalProperties": { + "$ref": "#/definitions/TomlDependency_for_String" + } } }, "definitions": { "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\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.", "type": "object", "required": [ "name" @@ -517,7 +517,7 @@ { "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-]+)*))?$" + "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-]+)*))?$" }, { "description": "The type when inheriting from a workspace.", @@ -560,7 +560,7 @@ ] }, "StringOrVec": { - "description": "A StringOrVec 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, but is always stored as a vector.", "type": "array", "items": { "type": "string" @@ -655,133 +655,94 @@ } } }, - "TomlProfiles": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TomlProfile" - } - }, - "TomlProfile": { + "TomlTarget": { "type": "object", "properties": { - "opt-level": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/TomlOptLevel" - }, - { - "type": "null" - } - ] - }, - "lto": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/StringOrBool" - }, - { - "type": "null" - } - ] - }, - "codegen-backend": { - "default": null, + "name": { "type": [ "string", "null" ] }, - "codegen-units": { - "default": null, + "crate-type": { "type": [ - "integer", + "array", "null" ], - "format": "uint32", - "minimum": 0.0 + "items": { + "type": "string" + } }, - "debug": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/TomlDebugInfo" - }, - { - "type": "null" - } + "crate_type": { + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "path": { + "type": [ + "string", + "null" ] }, - "split-debuginfo": { - "default": null, + "filename": { "type": [ "string", "null" ] }, - "debug-assertions": { - "default": null, + "test": { "type": [ "boolean", "null" ] }, - "rpath": { - "default": null, + "doctest": { "type": [ "boolean", "null" ] }, - "panic": { - "default": null, + "bench": { "type": [ - "string", + "boolean", "null" ] }, - "overflow-checks": { - "default": null, + "doc": { "type": [ "boolean", "null" ] }, - "incremental": { - "default": null, + "doc-scrape-examples": { "type": [ "boolean", "null" ] }, - "dir-name": { - "default": null, + "proc-macro": { "type": [ - "string", + "boolean", "null" ] }, - "inherits": { - "default": null, + "proc_macro": { "type": [ - "string", + "boolean", "null" ] }, - "strip": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/StringOrBool" - }, - { - "type": "null" - } + "harness": { + "type": [ + "boolean", + "null" ] }, - "rustflags": { - "default": null, + "required-features": { "type": [ "array", "null" @@ -790,207 +751,42 @@ "type": "string" } }, - "package": { - "default": null, + "edition": { "type": [ - "object", + "string", "null" - ], - "additionalProperties": { - "$ref": "#/definitions/TomlProfile" - } - }, - "build-override": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/TomlProfile" - }, + ] + } + } + }, + "InheritableDependency": { + "anyOf": [ + { + "description": "The type that is used when not inheriting from a workspace.", + "allOf": [ { - "type": "null" + "$ref": "#/definitions/TomlDependency_for_String" } ] }, - "trim-paths": { - "description": "Unstable feature `-Ztrim-paths`.", - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/TomlTrimPaths" - }, + { + "description": "The type when inheriting from a workspace.", + "allOf": [ { - "type": "null" + "$ref": "#/definitions/TomlInheritedDependency" } ] } - } - }, - "TomlOptLevel": { - "type": "string" - }, - "TomlDebugInfo": { - "type": "string", - "enum": [ - "None", - "LineDirectivesOnly", - "LineTablesOnly", - "Limited", - "Full" - ] - }, - "TomlTrimPaths": { - "anyOf": [ - { - "type": "array", - "items": { - "$ref": "#/definitions/TomlTrimPathsValue" - } - }, - { - "type": "null" - } - ] - }, - "TomlTrimPathsValue": { - "type": "string", - "enum": [ - "diagnostics", - "macro", - "object" - ] - }, - "TomlTarget": { - "type": "object", - "properties": { - "name": { - "type": [ - "string", - "null" - ] - }, - "crate-type": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "crate_type": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "path": { - "type": [ - "string", - "null" - ] - }, - "filename": { - "type": [ - "string", - "null" - ] - }, - "test": { - "type": [ - "boolean", - "null" - ] - }, - "doctest": { - "type": [ - "boolean", - "null" - ] - }, - "bench": { - "type": [ - "boolean", - "null" - ] - }, - "doc": { - "type": [ - "boolean", - "null" - ] - }, - "doc-scrape-examples": { - "type": [ - "boolean", - "null" - ] - }, - "proc-macro": { - "type": [ - "boolean", - "null" - ] - }, - "proc_macro": { - "type": [ - "boolean", - "null" - ] - }, - "harness": { - "type": [ - "boolean", - "null" - ] - }, - "required-features": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "edition": { - "type": [ - "string", - "null" - ] - } - } - }, - "InheritableDependency": { - "anyOf": [ - { - "description": "The type that is used when not inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlDependency_for_String" - } - ] - }, - { - "description": "The type when inheriting from a workspace.", - "allOf": [ - { - "$ref": "#/definitions/TomlInheritedDependency" - } - ] - } - ] + ] }, "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. `package = \"\"`", "type": "string" }, { - "description": "The simple format is equivalent to a detailed dependency specifying only a version, eg. `package = { version = /"/" }`", + "description": "The simple format is equivalent to a detailed dependency specifying only a version, eg. `package = { version = \"\" }`", "allOf": [ { "$ref": "#/definitions/TomlDetailedDependency_for_String" @@ -1218,6 +1014,52 @@ } } }, + "InheritableLints": { + "type": "object", + "required": [ + "workspace" + ], + "properties": { + "workspace": { + "type": "boolean" + } + } + }, + "TomlLint": { + "anyOf": [ + { + "$ref": "#/definitions/TomlLintLevel" + }, + { + "$ref": "#/definitions/TomlLintConfig" + } + ] + }, + "TomlLintLevel": { + "type": "string", + "enum": [ + "forbid", + "deny", + "warn", + "allow" + ] + }, + "TomlLintConfig": { + "type": "object", + "required": [ + "level" + ], + "properties": { + "level": { + "$ref": "#/definitions/TomlLintLevel" + }, + "priority": { + "default": 0, + "type": "integer", + "format": "int8" + } + } + }, "TomlWorkspace": { "type": "object", "properties": { @@ -1306,7 +1148,7 @@ "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-]+)*))?$" + "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-]+)*))?$" }, "authors": { "type": [ @@ -1435,51 +1277,209 @@ } } }, - "TomlLint": { - "anyOf": [ - { - "$ref": "#/definitions/TomlLintLevel" + "TomlProfiles": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/TomlProfile" + } + }, + "TomlProfile": { + "type": "object", + "properties": { + "opt-level": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/TomlOptLevel" + }, + { + "type": "null" + } + ] }, - { - "$ref": "#/definitions/TomlLintConfig" + "lto": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/StringOrBool" + }, + { + "type": "null" + } + ] + }, + "codegen-backend": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "codegen-units": { + "default": null, + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "debug": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/TomlDebugInfo" + }, + { + "type": "null" + } + ] + }, + "split-debuginfo": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "debug-assertions": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "rpath": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "panic": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "overflow-checks": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "incremental": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "dir-name": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "inherits": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "strip": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/StringOrBool" + }, + { + "type": "null" + } + ] + }, + "rustflags": { + "default": null, + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "package": { + "default": null, + "type": [ + "object", + "null" + ], + "additionalProperties": { + "$ref": "#/definitions/TomlProfile" + } + }, + "build-override": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/TomlProfile" + }, + { + "type": "null" + } + ] + }, + "trim-paths": { + "description": "Unstable feature `-Ztrim-paths`.", + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/TomlTrimPaths" + }, + { + "type": "null" + } + ] } - ] + } }, - "TomlLintLevel": { + "TomlOptLevel": { + "type": "string" + }, + "TomlDebugInfo": { "type": "string", "enum": [ - "forbid", - "deny", - "warn", - "allow" + "None", + "LineDirectivesOnly", + "LineTablesOnly", + "Limited", + "Full" ] }, - "TomlLintConfig": { - "type": "object", - "required": [ - "level" - ], - "properties": { - "level": { - "$ref": "#/definitions/TomlLintLevel" + "TomlTrimPaths": { + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/TomlTrimPathsValue" + } }, - "priority": { - "default": 0, - "type": "integer", - "format": "int8" + { + "type": "null" } - } + ] }, - "InheritableLints": { - "type": "object", - "required": [ - "workspace" - ], - "properties": { - "workspace": { - "type": "boolean" - } - } + "TomlTrimPathsValue": { + "type": "string", + "enum": [ + "diagnostics", + "macro", + "object" + ] } } } \ No newline at end of file diff --git a/crates/cargo-util-schemas/src/manifest/mod.rs b/crates/cargo-util-schemas/src/manifest/mod.rs index bfb23495c3e..efa125ce533 100644 --- a/crates/cargo-util-schemas/src/manifest/mod.rs +++ b/crates/cargo-util-schemas/src/manifest/mod.rs @@ -1787,5 +1787,5 @@ pub struct UnresolvedError; fn dump_manifest_schema() { let schema = schemars::schema_for!(crate::manifest::TomlManifest); let dump = serde_json::to_string_pretty(&schema).unwrap(); - snapbox::assert_data_eq!(dump, snapbox::file!("../../manifest.schema.json")); + snapbox::assert_data_eq!(dump, snapbox::file!("../../manifest.schema.json").raw()); }