From 3ba567eaddeaa0bb2bdd749b56e0601d1cf65a25 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Aug 2019 03:28:34 -0400 Subject: add JSON validator with initial support for manifest format (#654) --- src/SMAPI.Web/wwwroot/schemas/manifest.json | 120 ++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 src/SMAPI.Web/wwwroot/schemas/manifest.json (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/manifest.json b/src/SMAPI.Web/wwwroot/schemas/manifest.json new file mode 100644 index 00000000..06173333 --- /dev/null +++ b/src/SMAPI.Web/wwwroot/schemas/manifest.json @@ -0,0 +1,120 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://smapi.io/schemas/manifest.json", + "title": "SMAPI manifest", + "description": "Manifest file for a SMAPI mod or content pack", + "type": "object", + "properties": { + "Name": { + "title": "Mod name", + "description": "The mod's display name. SMAPI uses this in player messages, logs, and errors.", + "type": "string", + "examples": [ "Lookup Anything" ] + }, + "Author": { + "title": "Mod author", + "description": "The name of the person who created the mod. Ideally this should include the username used to publish mods.", + "type": "string", + "examples": [ "Pathoschild" ] + }, + "Version": { + "title": "Mod version", + "description": "The mod's semantic version. Make sure you update this for each release! SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game).", + "$ref": "#/definitions/SemanticVersion" + }, + "Description": { + "title": "Mod description", + "description": "A short explanation of what your mod does (one or two sentences), shown in the SMAPI log.", + "type": "string", + "examples": [ "View metadata about anything by pressing a button." ] + }, + "UniqueID": { + "title": "Mod unique ID", + "description": "A unique identifier for your mod. The recommended format is \"Username.ModName\", with no spaces or special characters. SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). When another mod needs to reference this mod, it uses the unique ID.", + "$ref": "#/definitions/ModID" + }, + "EntryDll": { + "title": "Mod entry DLL", + "description": "The DLL filename SMAPI should load for this mod. Mutually exclusive with ContentPackFor.", + "type": "string", + "pattern": "^[a-zA-Z0-9_.-]+\\.dll$", + "examples": "LookupAnything.dll" + }, + "ContentPackFor": { + "title": "Content pack for", + "description": "Specifies the mod which can read this content pack.", + "type": "object", + "properties": { + "UniqueID": { + "title": "Required unique ID", + "description": "The unique ID of the mod which can read this content pack.", + "$ref": "#/definitions/ModID" + }, + "MinimumVersion": { + "title": "Required minimum version", + "description": "The minimum semantic version of the mod which can read this content pack, if applicable.", + "$ref": "#/definitions/SemanticVersion" + } + }, + + "required": [ "UniqueID" ] + }, + "Dependencies": { + "title": "Mod dependencies", + "description": "Specifies other mods to load before this mod. If a dependency is required and a player tries to use the mod without the dependency installed, the mod won't be loaded and they'll see a friendly message saying they need to install those.", + "type": "array", + "items": { + "type": "object", + "properties": { + "UniqueID": { + "title": "Dependency unique ID", + "description": "The unique ID of the mod to load first.", + "$ref": "#/definitions/ModID" + }, + "MinimumVersion": { + "title": "Dependency minimum version", + "description": "The minimum semantic version of the mod to load first, if applicable.", + "$ref": "#/definitions/SemanticVersion" + }, + "IsRequired": { + "title": "Dependency is required", + "description": "Whether the dependency is required. Default true if not specified." + } + }, + "required": [ "UniqueID" ] + } + }, + "UpdateKeys": { + "title": "Mod update keys", + "description": "Specifies where SMAPI should check for mod updates, so it can alert the user with a link to your mod page. See https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Manifest#Update_checks for more info.", + "type": "array", + "items": { + "type": "string", + "pattern": "^(Chucklefish:\\d+|Nexus:\\d+|GitHub:[A-Za-z0-9_]+/[A-Za-z0-9_]+|ModDrop:\\d+)$" + } + } + }, + + "required": [ "Name", "Author", "Version", "Description", "UniqueID" ], + "oneOf": [ + { + "required": [ "EntryDll" ] + }, + { + "required": [ "ContentPackFor" ] + } + ], + + "definitions": { + "SemanticVersion": { + "type": "string", + "pattern": "(?>(?0|[1-9]\\d*))\\.(?>(?0|[1-9]\\d*))(?>(?:\\.(?0|[1-9]\\d*))?)(?:-(?(?>[a-zA-Z0-9]+[\\-\\.]?)+))?", // derived from SMAPI.Toolkit.SemanticVersion + "examples": [ "1.0.0", "1.0.1-beta.2" ] + }, + "ModID": { + "type": "string", + "pattern": "^[a-zA-Z0-9_.-]+$", // derived from SMAPI.Toolkit.Utilities.PathUtilities.IsSlug + "examples": [ "Pathoschild.LookupAnything" ] + } + } +} -- cgit From ee0ff5687d4002aab20cd91fd28d007d916af36c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Aug 2019 18:01:05 -0400 Subject: add user-friendly doc link & error messages, document validator, improve manifest schema (#654) --- src/SMAPI.Web/wwwroot/schemas/manifest.json | 48 ++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/manifest.json b/src/SMAPI.Web/wwwroot/schemas/manifest.json index 06173333..804eb53d 100644 --- a/src/SMAPI.Web/wwwroot/schemas/manifest.json +++ b/src/SMAPI.Web/wwwroot/schemas/manifest.json @@ -3,6 +3,7 @@ "$id": "https://smapi.io/schemas/manifest.json", "title": "SMAPI manifest", "description": "Manifest file for a SMAPI mod or content pack", + "@documentationUrl": "https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Manifest", "type": "object", "properties": { "Name": { @@ -38,7 +39,10 @@ "description": "The DLL filename SMAPI should load for this mod. Mutually exclusive with ContentPackFor.", "type": "string", "pattern": "^[a-zA-Z0-9_.-]+\\.dll$", - "examples": "LookupAnything.dll" + "examples": "LookupAnything.dll", + "@errorMessages": { + "pattern": "Invalid value; must be a filename ending with .dll." + } }, "ContentPackFor": { "title": "Content pack for", @@ -59,12 +63,17 @@ "required": [ "UniqueID" ] }, + "MinimumApiVersion": { + "title": "Minimum API version", + "description": "The minimum SMAPI version needed to use this mod. If a player tries to use the mod with an older SMAPI version, they'll see a friendly message saying they need to update SMAPI. This also serves as a proxy for the minimum game version, since SMAPI itself enforces a minimum game version.", + "$ref": "#/definitions/SemanticVersion" + }, "Dependencies": { "title": "Mod dependencies", "description": "Specifies other mods to load before this mod. If a dependency is required and a player tries to use the mod without the dependency installed, the mod won't be loaded and they'll see a friendly message saying they need to install those.", "type": "array", "items": { - "type": "object", + "type": "object", "properties": { "UniqueID": { "title": "Dependency unique ID", @@ -90,8 +99,26 @@ "type": "array", "items": { "type": "string", - "pattern": "^(Chucklefish:\\d+|Nexus:\\d+|GitHub:[A-Za-z0-9_]+/[A-Za-z0-9_]+|ModDrop:\\d+)$" + "pattern": "^(Chucklefish:\\d+|Nexus:\\d+|GitHub:[A-Za-z0-9_]+/[A-Za-z0-9_]+|ModDrop:\\d+)$", + "@errorMessages": { + "pattern": "Invalid update key; see https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Manifest#Update_checks for more info." + } + } + } + }, + "definitions": { + "SemanticVersion": { + "type": "string", + "pattern": "^(?>(?0|[1-9]\\d*))\\.(?>(?0|[1-9]\\d*))(?>(?:\\.(?0|[1-9]\\d*))?)(?:-(?(?>[a-zA-Z0-9]+[\\-\\.]?)+))?$", // derived from SMAPI.Toolkit.SemanticVersion + "examples": [ "1.0.0", "1.0.1-beta.2" ], + "@errorMessages": { + "pattern": "Invalid semantic version; must be formatted like 1.2.0 or 1.2.0-prerelease.tags. See https://semver.org/ for more info." } + }, + "ModID": { + "type": "string", + "pattern": "^[a-zA-Z0-9_.-]+$", // derived from SMAPI.Toolkit.Utilities.PathUtilities.IsSlug + "examples": [ "Pathoschild.LookupAnything" ] } }, @@ -104,17 +131,8 @@ "required": [ "ContentPackFor" ] } ], - - "definitions": { - "SemanticVersion": { - "type": "string", - "pattern": "(?>(?0|[1-9]\\d*))\\.(?>(?0|[1-9]\\d*))(?>(?:\\.(?0|[1-9]\\d*))?)(?:-(?(?>[a-zA-Z0-9]+[\\-\\.]?)+))?", // derived from SMAPI.Toolkit.SemanticVersion - "examples": [ "1.0.0", "1.0.1-beta.2" ] - }, - "ModID": { - "type": "string", - "pattern": "^[a-zA-Z0-9_.-]+$", // derived from SMAPI.Toolkit.Utilities.PathUtilities.IsSlug - "examples": [ "Pathoschild.LookupAnything" ] - } + "additionalProperties": false, + "@errorMessages": { + "oneOf": "Can't specify both EntryDll or ContentPackFor, they're mutually exclusive." } } -- cgit From 84ad8b2a92eac9155cada821c57d62a517b958a8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Aug 2019 20:13:10 -0400 Subject: fix manifest error if neither EntryDll nor ContentPackFor are specified (#654) --- src/SMAPI.Web/wwwroot/schemas/manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/manifest.json b/src/SMAPI.Web/wwwroot/schemas/manifest.json index 804eb53d..41d1ec2d 100644 --- a/src/SMAPI.Web/wwwroot/schemas/manifest.json +++ b/src/SMAPI.Web/wwwroot/schemas/manifest.json @@ -133,6 +133,7 @@ ], "additionalProperties": false, "@errorMessages": { - "oneOf": "Can't specify both EntryDll or ContentPackFor, they're mutually exclusive." + "oneOf:valid against no schemas": "Missing required field: EntryDll or ContentPackFor.", + "oneOf:valid against more than one schema": "Can't specify both EntryDll or ContentPackFor, they're mutually exclusive." } } -- cgit From c785572fdd07df17487fedd67551cb9e5ff60a2d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 5 Aug 2019 00:48:52 -0400 Subject: raise JSON validation error for duplicate fields (#654) --- src/SMAPI.Web/wwwroot/schemas/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/manifest.json b/src/SMAPI.Web/wwwroot/schemas/manifest.json index 41d1ec2d..d4727eda 100644 --- a/src/SMAPI.Web/wwwroot/schemas/manifest.json +++ b/src/SMAPI.Web/wwwroot/schemas/manifest.json @@ -134,6 +134,6 @@ "additionalProperties": false, "@errorMessages": { "oneOf:valid against no schemas": "Missing required field: EntryDll or ContentPackFor.", - "oneOf:valid against more than one schema": "Can't specify both EntryDll or ContentPackFor, they're mutually exclusive." + "oneOf:valid against more than one schema": "Can't specify both EntryDll and ContentPackFor, they're mutually exclusive." } } -- cgit From 093c68cac4839603e8c1fcc456d86bcfdf309b60 Mon Sep 17 00:00:00 2001 From: TehPers Date: Mon, 5 Aug 2019 19:39:42 -0700 Subject: Fixed --- src/SMAPI.Web/wwwroot/schemas/content-patcher.json | 358 +++++++++++++++++++++ 1 file changed, 358 insertions(+) create mode 100644 src/SMAPI.Web/wwwroot/schemas/content-patcher.json (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json new file mode 100644 index 00000000..e4008abb --- /dev/null +++ b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json @@ -0,0 +1,358 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://raw.githubusercontent.com/Pathoschild/SMAPI/develop/src/SMAPI.Web/wwwroot/schemas/content-patcher.json", + "title": "Content Patcher", + "description": "Content Patcher content file for mods", + "type": "object", + "definitions": { + "Version": { + "type": "string", + "pattern": "\\d+\\.\\d+" + }, + "Change": { + "properties": { + "Action": { + "title": "Action", + "description": "The kind of change to make.", + "type": "string", + "enum": ["Load", "EditImage", "EditData", "EditMap"] + }, + "Target": { + "title": "Target asset", + "description": "The game asset you want to patch (or multiple comma-delimited assets). This is the file path inside your game's Content folder, without the file extension or language (like Animals/Dinosaur to edit Content/Animals/Dinosaur.xnb). This field supports tokens and capitalisation doesn't matter. Your changes are applied in all languages unless you specify a language condition.", + "type": "string" + }, + "LogName": { + "title": "Patch log name", + "description": "A name for this patch shown in log messages. This is very useful for understanding errors; if not specified, will default to a name like entry #14 (EditImage Animals/Dinosaurs).", + "type": "string" + }, + "Enabled": { + "title": "Enabled", + "description": "Whether to apply this patch. Default true. This fields supports immutable tokens (e.g. config tokens) if they return true/false.", + "anyOf": [ + { + "type": "string", + "enum": ["true", "false"] + }, + { + "type": "string", + "pattern": "\\{\\{[^{}]+\\}\\}" + } + ] + }, + "When": { + "title": "When", + "description": "Only apply the patch if the given conditions match.", + "$ref": "#/definitions/Condition" + } + }, + "required": ["Action", "Target"], + "allOf": [ + { + "if": { + "properties": { + "Action": { + "const": "Load" + } + } + }, + "then": { + "$ref": "#/definitions/LoadChange" + } + }, + { + "if": { + "properties": { + "Action": { + "const": "EditImage" + } + } + }, + "then": { + "$ref": "#/definitions/EditImageChange" + } + }, + { + "if": { + "properties": { + "Action": { + "const": "EditData" + } + } + }, + "then": { + "$ref": "#/definitions/EditDataChange" + } + }, + { + "if": { + "properties": { + "Action": { + "const": "EditMap" + } + } + }, + "then": { + "$ref": "#/definitions/EditMapChange" + } + } + ] + }, + "LoadChange": { + "properties": { + "FromFile": { + "$ref": "#/definitions/FromFile" + } + }, + "required": ["FromFile"] + }, + "EditImageChange": { + "properties": { + "FromFile": { + "$ref": "#/definitions/FromFile" + }, + "FromArea": { + "title": "Source area", + "description": "The part of the source image to copy. Defaults to the whole source image.", + "$ref": "#/definitions/Rectangle" + }, + "ToArea": { + "title": "Destination area", + "description": "The part of the target image to replace. Defaults to the FromArea size starting from the top-left corner.", + "$ref": "#/definitions/Rectangle" + }, + "PatchMode": { + "title": "Patch mode", + "description": "How to apply FromArea to ToArea. Defaults to Replace.", + "type": "string", + "enum": ["Replace", "Overlay"] + } + }, + "required": ["FromFile"] + }, + "EditDataChange": { + "properties": { + "Fields": { + "title": "Fields", + "description": "The individual fields you want to change for existing entries. This field supports tokens in field keys and values. The key for each field is the field index (starting at zero) for a slash-delimited string, or the field name for an object.", + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "Entries": { + "title": "Entries", + "description": "The entries in the data file you want to add, replace, or delete. If you only want to change a few fields, use Fields instead for best compatibility with other mods. To add an entry, just specify a key that doesn't exist; to delete an entry, set the value to null (like \"some key\": null). This field supports tokens in entry keys and values.\nCaution: some XNB files have extra fields at the end for translations; when adding or replacing an entry for all locales, make sure you include the extra fields to avoid errors for non-English players." + }, + "MoveEntries": { + "type": "array", + "items": { + "type": "object", + "properties": { + "ID": { + "title": "ID", + "description": "The ID of the entry to move", + "type": "string" + } + }, + "anyOf": [ + { + "properties": { + "ID": {}, + "BeforeID": { + "title": "Before ID", + "description": "Move entry so it's right before this ID", + "type": "string" + } + }, + "required": ["ID", "BeforeID"], + "additionalProperties": false + }, + { + "properties": { + "ID": {}, + "AfterID": { + "title": "After ID", + "description": "Move entry so it's right after this ID", + "type": "string" + } + }, + "required": ["ID", "AfterID"], + "additionalProperties": false + }, + { + "properties": { + "ID": {}, + "ToPosition": { + "title": "To position", + "description": "Move entry so it's right at this position", + "enum": ["Top", "Bottom"] + } + }, + "required": ["ID", "ToPosition"], + "additionalProperties": false + } + ], + "required": ["ID"] + } + } + } + }, + "EditMapChange": { + "properties": { + "FromFile": { + "description": "The relative path to the map in your content pack folder from which to copy (like assets/town.tbin). This can be a .tbin or .xnb file. This field supports tokens and capitalisation doesn't matter.\nContent Patcher will handle tilesheets referenced by the FromFile map for you if it's a .tbin file:\n - If a tilesheet isn't referenced by the target map, Content Patcher will add it for you (with a z_ ID prefix to avoid conflicts with hardcoded game logic). If the source map has a custom version of a tilesheet that's already referenced, it'll be added as a separate tilesheet only used by your tiles.\n - If you include the tilesheet file in your mod folder, Content Patcher will use that one automatically; otherwise it will be loaded from the game's Content/Maps folder.", + "$ref": "#/definitions/FromFile" + }, + "FromArea": { + "title": "Source area", + "description": "The part of the source map to copy. Defaults to the whole source map.", + "$ref": "#/definitions/Rectangle" + }, + "ToArea": { + "title": "Target area", + "description": "The part of the target map to replace.", + "$ref": "#/definitions/Rectangle" + } + }, + "required": ["FromFile", "ToArea"] + }, + "Config": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "AllowValues": { + "title": "Allowed values", + "description": "The values the player can provide, as a comma-delimited string. If omitted, any value is allowed.\nTip: for a boolean flag, use \"true, false\".", + "type": "string" + }, + "AllowBlank": { + "title": "Allow blank", + "description": "Whether the field can be left blank. If false or omitted, blank fields will be replaced with the default value.", + "type": "boolean" + }, + "AllowMultiple": { + "title": "Allow multiple values", + "description": "Whether the player can specify multiple comma-delimited values. Default false.", + "type": "boolean" + }, + "Default": { + "title": "Default value", + "description": "The default values when the field is missing. Can contain multiple comma-delimited values if AllowMultiple is true. If omitted, blank fields are left blank.", + "type": "string" + } + }, + "if": { + "properties": { + "AllowBlank": { + "const": false + } + }, + "required": ["AllowBlank"] + }, + "then": { + "required": ["Default"] + } + } + }, + "Condition": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "DynamicToken": { + "type": "object", + "properties": { + "Name": { + "title": "Name", + "description": "The name of the token to use for tokens & condition.", + "type": "string" + }, + "Value": { + "title": "Token value", + "description": "The value(s) to set. This can be a comma-delimited value to give it multiple values. If any block for a token name has multiple values, it will only be usable in conditions. This field supports tokens, including dynamic tokens defined before this entry.", + "type": "string" + }, + "When": { + "title": "When", + "description": "Only set the value if the given conditions match. If not specified, always matches.", + "$ref": "#/definitions/Condition" + } + }, + "required": ["Name", "Value"] + }, + "FromFile": { + "title": "Source file", + "description": "The relative file path in your content pack folder to load instead (like assets/dinosaur.png). This can be a .json (data), .png (image), .tbin (map), or .xnb file. This field supports tokens and capitalisation doesn't matter.", + "type": "string", + "pattern": ".*\\.(json|png|tbin|xnb)$|.*\\{\\{[^}]+}}$" + }, + "Rectangle": { + "type": "object", + "properties": { + "X": { + "title": "X-Coordinate", + "description": "Location in pixels of the top-left of the rectangle", + "type": "number", + "multipleOf": 1 + }, + "Y": { + "title": "Y-Coordinate", + "description": "Location in pixels of the top-left of the rectangle", + "type": "number", + "multipleOf": 1 + }, + "Width": { + "title": "Width", + "description": "The width of the rectangle", + "type": "number", + "multipleOf": 1 + }, + "Height": { + "title": "Height", + "description": "The height of the rectangle", + "type": "number", + "multipleOf": 1 + } + } + } + }, + "properties": { + "Format": { + "title": "Format version", + "description": "The format version. You should always use the latest version to use the latest features and avoid obsolete behavior.", + "$ref": "#/definitions/Version" + }, + "Changes": { + "title": "Changes", + "description": "The changes you want to make. Each entry is called a patch, and describes a specific action to perform: replace this file, copy this image into the file, etc. You can list any number of patches.", + "type": "array", + "items": { + "$ref": "#/definitions/Change" + } + }, + "ConfigSchema": { + "title": "Config schema", + "description": "Defines the config.json format, to support more complex mods.", + "$ref": "#/definitions/Config" + }, + "DynamicTokens": { + "title": "Dynamic tokens", + "description": "Custom tokens that you can use.", + "type": "array", + "items": { + "$ref": "#/definitions/DynamicToken" + } + }, + "$schema": { + "title": "Schema", + "description": "The schema this JSON should follow. Useful for JSON validation tools.", + "type": "string", + "format": "uri" + } + }, + "required": ["Format", "Changes"] +} -- cgit From 31990916198708dc89343066faaf34703f2c1cf1 Mon Sep 17 00:00:00 2001 From: TehPers Date: Mon, 5 Aug 2019 19:47:26 -0700 Subject: Updated $id --- src/SMAPI.Web/wwwroot/schemas/content-patcher.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json index e4008abb..3ef5d263 100644 --- a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json +++ b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://raw.githubusercontent.com/Pathoschild/SMAPI/develop/src/SMAPI.Web/wwwroot/schemas/content-patcher.json", + "$id": "https://smapi.io/schemas/content-patcher.json", "title": "Content Patcher", "description": "Content Patcher content file for mods", "type": "object", -- cgit From 5d06d0b83692e1209a8338ee3b3a2c9f0aa776ca Mon Sep 17 00:00:00 2001 From: TehPers Date: Mon, 5 Aug 2019 19:51:36 -0700 Subject: Updated title with feedback from Cat --- src/SMAPI.Web/wwwroot/schemas/content-patcher.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json index 3ef5d263..e5810871 100644 --- a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json +++ b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://smapi.io/schemas/content-patcher.json", - "title": "Content Patcher", + "title": "Content Patcher content pack", "description": "Content Patcher content file for mods", "type": "object", "definitions": { -- cgit From 3331beb17a7bda439b281e7507ae187c68b6359c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 5 Aug 2019 23:30:11 -0400 Subject: integrate Content Patcher schema into validator, update docs (#654) --- src/SMAPI.Web/wwwroot/schemas/content-patcher.json | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json index e5810871..8dae5a98 100644 --- a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json +++ b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json @@ -3,6 +3,7 @@ "$id": "https://smapi.io/schemas/content-patcher.json", "title": "Content Patcher content pack", "description": "Content Patcher content file for mods", + "@documentationUrl": "https://github.com/Pathoschild/StardewMods/tree/develop/ContentPatcher#readme", "type": "object", "definitions": { "Version": { @@ -15,7 +16,7 @@ "title": "Action", "description": "The kind of change to make.", "type": "string", - "enum": ["Load", "EditImage", "EditData", "EditMap"] + "enum": [ "Load", "EditImage", "EditData", "EditMap" ] }, "Target": { "title": "Target asset", @@ -33,7 +34,7 @@ "anyOf": [ { "type": "string", - "enum": ["true", "false"] + "enum": [ "true", "false" ] }, { "type": "string", @@ -47,7 +48,7 @@ "$ref": "#/definitions/Condition" } }, - "required": ["Action", "Target"], + "required": [ "Action", "Target" ], "allOf": [ { "if": { @@ -105,7 +106,7 @@ "$ref": "#/definitions/FromFile" } }, - "required": ["FromFile"] + "required": [ "FromFile" ] }, "EditImageChange": { "properties": { @@ -126,10 +127,10 @@ "title": "Patch mode", "description": "How to apply FromArea to ToArea. Defaults to Replace.", "type": "string", - "enum": ["Replace", "Overlay"] + "enum": [ "Replace", "Overlay" ] } }, - "required": ["FromFile"] + "required": [ "FromFile" ] }, "EditDataChange": { "properties": { @@ -166,7 +167,7 @@ "type": "string" } }, - "required": ["ID", "BeforeID"], + "required": [ "ID", "BeforeID" ], "additionalProperties": false }, { @@ -178,7 +179,7 @@ "type": "string" } }, - "required": ["ID", "AfterID"], + "required": [ "ID", "AfterID" ], "additionalProperties": false }, { @@ -187,14 +188,14 @@ "ToPosition": { "title": "To position", "description": "Move entry so it's right at this position", - "enum": ["Top", "Bottom"] + "enum": [ "Top", "Bottom" ] } }, - "required": ["ID", "ToPosition"], + "required": [ "ID", "ToPosition" ], "additionalProperties": false } ], - "required": ["ID"] + "required": [ "ID" ] } } } @@ -216,7 +217,7 @@ "$ref": "#/definitions/Rectangle" } }, - "required": ["FromFile", "ToArea"] + "required": [ "FromFile", "ToArea" ] }, "Config": { "type": "object", @@ -250,10 +251,10 @@ "const": false } }, - "required": ["AllowBlank"] + "required": [ "AllowBlank" ] }, "then": { - "required": ["Default"] + "required": [ "Default" ] } } }, @@ -282,7 +283,7 @@ "$ref": "#/definitions/Condition" } }, - "required": ["Name", "Value"] + "required": [ "Name", "Value" ] }, "FromFile": { "title": "Source file", @@ -354,5 +355,5 @@ "format": "uri" } }, - "required": ["Format", "Changes"] + "required": [ "Format", "Changes" ] } -- cgit From 22480d25b9ba15df8cd26e788cd4a2d73f002a0d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 6 Aug 2019 00:15:21 -0400 Subject: restructure Content Patcher schema a bit (#654) --- src/SMAPI.Web/wwwroot/schemas/content-patcher.json | 508 ++++++++++----------- 1 file changed, 238 insertions(+), 270 deletions(-) (limited to 'src/SMAPI.Web/wwwroot/schemas') diff --git a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json index 8dae5a98..25cba70e 100644 --- a/src/SMAPI.Web/wwwroot/schemas/content-patcher.json +++ b/src/SMAPI.Web/wwwroot/schemas/content-patcher.json @@ -5,221 +5,17 @@ "description": "Content Patcher content file for mods", "@documentationUrl": "https://github.com/Pathoschild/StardewMods/tree/develop/ContentPatcher#readme", "type": "object", - "definitions": { - "Version": { + + "properties": { + "Format": { + "title": "Format version", + "description": "The format version. You should always use the latest version to use the latest features and avoid obsolete behavior.", "type": "string", "pattern": "\\d+\\.\\d+" }, - "Change": { - "properties": { - "Action": { - "title": "Action", - "description": "The kind of change to make.", - "type": "string", - "enum": [ "Load", "EditImage", "EditData", "EditMap" ] - }, - "Target": { - "title": "Target asset", - "description": "The game asset you want to patch (or multiple comma-delimited assets). This is the file path inside your game's Content folder, without the file extension or language (like Animals/Dinosaur to edit Content/Animals/Dinosaur.xnb). This field supports tokens and capitalisation doesn't matter. Your changes are applied in all languages unless you specify a language condition.", - "type": "string" - }, - "LogName": { - "title": "Patch log name", - "description": "A name for this patch shown in log messages. This is very useful for understanding errors; if not specified, will default to a name like entry #14 (EditImage Animals/Dinosaurs).", - "type": "string" - }, - "Enabled": { - "title": "Enabled", - "description": "Whether to apply this patch. Default true. This fields supports immutable tokens (e.g. config tokens) if they return true/false.", - "anyOf": [ - { - "type": "string", - "enum": [ "true", "false" ] - }, - { - "type": "string", - "pattern": "\\{\\{[^{}]+\\}\\}" - } - ] - }, - "When": { - "title": "When", - "description": "Only apply the patch if the given conditions match.", - "$ref": "#/definitions/Condition" - } - }, - "required": [ "Action", "Target" ], - "allOf": [ - { - "if": { - "properties": { - "Action": { - "const": "Load" - } - } - }, - "then": { - "$ref": "#/definitions/LoadChange" - } - }, - { - "if": { - "properties": { - "Action": { - "const": "EditImage" - } - } - }, - "then": { - "$ref": "#/definitions/EditImageChange" - } - }, - { - "if": { - "properties": { - "Action": { - "const": "EditData" - } - } - }, - "then": { - "$ref": "#/definitions/EditDataChange" - } - }, - { - "if": { - "properties": { - "Action": { - "const": "EditMap" - } - } - }, - "then": { - "$ref": "#/definitions/EditMapChange" - } - } - ] - }, - "LoadChange": { - "properties": { - "FromFile": { - "$ref": "#/definitions/FromFile" - } - }, - "required": [ "FromFile" ] - }, - "EditImageChange": { - "properties": { - "FromFile": { - "$ref": "#/definitions/FromFile" - }, - "FromArea": { - "title": "Source area", - "description": "The part of the source image to copy. Defaults to the whole source image.", - "$ref": "#/definitions/Rectangle" - }, - "ToArea": { - "title": "Destination area", - "description": "The part of the target image to replace. Defaults to the FromArea size starting from the top-left corner.", - "$ref": "#/definitions/Rectangle" - }, - "PatchMode": { - "title": "Patch mode", - "description": "How to apply FromArea to ToArea. Defaults to Replace.", - "type": "string", - "enum": [ "Replace", "Overlay" ] - } - }, - "required": [ "FromFile" ] - }, - "EditDataChange": { - "properties": { - "Fields": { - "title": "Fields", - "description": "The individual fields you want to change for existing entries. This field supports tokens in field keys and values. The key for each field is the field index (starting at zero) for a slash-delimited string, or the field name for an object.", - "type": "object", - "additionalProperties": { - "type": "object" - } - }, - "Entries": { - "title": "Entries", - "description": "The entries in the data file you want to add, replace, or delete. If you only want to change a few fields, use Fields instead for best compatibility with other mods. To add an entry, just specify a key that doesn't exist; to delete an entry, set the value to null (like \"some key\": null). This field supports tokens in entry keys and values.\nCaution: some XNB files have extra fields at the end for translations; when adding or replacing an entry for all locales, make sure you include the extra fields to avoid errors for non-English players." - }, - "MoveEntries": { - "type": "array", - "items": { - "type": "object", - "properties": { - "ID": { - "title": "ID", - "description": "The ID of the entry to move", - "type": "string" - } - }, - "anyOf": [ - { - "properties": { - "ID": {}, - "BeforeID": { - "title": "Before ID", - "description": "Move entry so it's right before this ID", - "type": "string" - } - }, - "required": [ "ID", "BeforeID" ], - "additionalProperties": false - }, - { - "properties": { - "ID": {}, - "AfterID": { - "title": "After ID", - "description": "Move entry so it's right after this ID", - "type": "string" - } - }, - "required": [ "ID", "AfterID" ], - "additionalProperties": false - }, - { - "properties": { - "ID": {}, - "ToPosition": { - "title": "To position", - "description": "Move entry so it's right at this position", - "enum": [ "Top", "Bottom" ] - } - }, - "required": [ "ID", "ToPosition" ], - "additionalProperties": false - } - ], - "required": [ "ID" ] - } - } - } - }, - "EditMapChange": { - "properties": { - "FromFile": { - "description": "The relative path to the map in your content pack folder from which to copy (like assets/town.tbin). This can be a .tbin or .xnb file. This field supports tokens and capitalisation doesn't matter.\nContent Patcher will handle tilesheets referenced by the FromFile map for you if it's a .tbin file:\n - If a tilesheet isn't referenced by the target map, Content Patcher will add it for you (with a z_ ID prefix to avoid conflicts with hardcoded game logic). If the source map has a custom version of a tilesheet that's already referenced, it'll be added as a separate tilesheet only used by your tiles.\n - If you include the tilesheet file in your mod folder, Content Patcher will use that one automatically; otherwise it will be loaded from the game's Content/Maps folder.", - "$ref": "#/definitions/FromFile" - }, - "FromArea": { - "title": "Source area", - "description": "The part of the source map to copy. Defaults to the whole source map.", - "$ref": "#/definitions/Rectangle" - }, - "ToArea": { - "title": "Target area", - "description": "The part of the target map to replace.", - "$ref": "#/definitions/Rectangle" - } - }, - "required": [ "FromFile", "ToArea" ] - }, - "Config": { + "ConfigSchema": { + "title": "Config schema", + "description": "Defines the config.json format, to support more complex mods.", "type": "object", "additionalProperties": { "type": "object", @@ -247,9 +43,7 @@ }, "if": { "properties": { - "AllowBlank": { - "const": false - } + "AllowBlank": { "const": false } }, "required": [ "AllowBlank" ] }, @@ -258,33 +52,240 @@ } } }, + "DynamicTokens": { + "title": "Dynamic tokens", + "description": "Custom tokens that you can use.", + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "title": "Name", + "description": "The name of the token to use for tokens & condition.", + "type": "string" + }, + "Value": { + "title": "Token value", + "description": "The value(s) to set. This can be a comma-delimited value to give it multiple values. If any block for a token name has multiple values, it will only be usable in conditions. This field supports tokens, including dynamic tokens defined before this entry.", + "type": "string" + }, + "When": { + "title": "When", + "description": "Only set the value if the given conditions match. If not specified, always matches.", + "$ref": "#/definitions/Condition" + } + }, + "required": [ "Name", "Value" ] + } + }, + "Changes": { + "title": "Changes", + "description": "The changes you want to make. Each entry is called a patch, and describes a specific action to perform: replace this file, copy this image into the file, etc. You can list any number of patches.", + "type": "array", + "items": { + "properties": { + "Action": { + "title": "Action", + "description": "The kind of change to make.", + "type": "string", + "enum": [ "Load", "EditImage", "EditData", "EditMap" ] + }, + "Target": { + "title": "Target asset", + "description": "The game asset you want to patch (or multiple comma-delimited assets). This is the file path inside your game's Content folder, without the file extension or language (like Animals/Dinosaur to edit Content/Animals/Dinosaur.xnb). This field supports tokens and capitalisation doesn't matter. Your changes are applied in all languages unless you specify a language condition.", + "type": "string" + }, + "LogName": { + "title": "Patch log name", + "description": "A name for this patch shown in log messages. This is very useful for understanding errors; if not specified, will default to a name like entry #14 (EditImage Animals/Dinosaurs).", + "type": "string" + }, + "Enabled": { + "title": "Enabled", + "description": "Whether to apply this patch. Default true. This fields supports immutable tokens (e.g. config tokens) if they return true/false.", + "anyOf": [ + { + "type": "string", + "enum": [ "true", "false" ] + }, + { + "type": "string", + "pattern": "\\{\\{[^{}]+\\}\\}" + } + ] + }, + "When": { + "title": "When", + "description": "Only apply the patch if the given conditions match.", + "$ref": "#/definitions/Condition" + } + }, + "required": [ "Action", "Target" ], + "allOf": [ + { + "if": { + "properties": { + "Action": { "const": "Load" } + } + }, + "then": { + "properties": { + "FromFile": { + "$ref": "#/definitions/FromFile" + } + }, + "required": [ "FromFile" ] + } + }, + { + "if": { + "properties": { + "Action": { "const": "EditImage" } + } + }, + "then": { + "properties": { + "FromFile": { + "$ref": "#/definitions/FromFile" + }, + "FromArea": { + "title": "Source area", + "description": "The part of the source image to copy. Defaults to the whole source image.", + "$ref": "#/definitions/Rectangle" + }, + "ToArea": { + "title": "Destination area", + "description": "The part of the target image to replace. Defaults to the FromArea size starting from the top-left corner.", + "$ref": "#/definitions/Rectangle" + }, + "PatchMode": { + "title": "Patch mode", + "description": "How to apply FromArea to ToArea. Defaults to Replace.", + "type": "string", + "enum": [ "Replace", "Overlay" ] + } + }, + "required": [ "FromFile" ] + } + }, + { + "if": { + "properties": { + "Action": { "const": "EditData" } + } + }, + "then": { + "properties": { + "Fields": { + "title": "Fields", + "description": "The individual fields you want to change for existing entries. This field supports tokens in field keys and values. The key for each field is the field index (starting at zero) for a slash-delimited string, or the field name for an object.", + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "Entries": { + "title": "Entries", + "description": "The entries in the data file you want to add, replace, or delete. If you only want to change a few fields, use Fields instead for best compatibility with other mods. To add an entry, just specify a key that doesn't exist; to delete an entry, set the value to null (like \"some key\": null). This field supports tokens in entry keys and values.\nCaution: some XNB files have extra fields at the end for translations; when adding or replacing an entry for all locales, make sure you include the extra fields to avoid errors for non-English players." + }, + "MoveEntries": { + "type": "array", + "items": { + "type": "object", + "properties": { + "ID": { + "title": "ID", + "description": "The ID of the entry to move", + "type": "string" + } + }, + "anyOf": [ + { + "properties": { + "ID": {}, + "BeforeID": { + "title": "Before ID", + "description": "Move entry so it's right before this ID", + "type": "string" + } + }, + "required": [ "ID", "BeforeID" ], + "additionalProperties": false + }, + { + "properties": { + "ID": {}, + "AfterID": { + "title": "After ID", + "description": "Move entry so it's right after this ID", + "type": "string" + } + }, + "required": [ "ID", "AfterID" ], + "additionalProperties": false + }, + { + "properties": { + "ID": {}, + "ToPosition": { + "title": "To position", + "description": "Move entry so it's right at this position", + "enum": [ "Top", "Bottom" ] + } + }, + "required": [ "ID", "ToPosition" ], + "additionalProperties": false + } + ], + "required": [ "ID" ] + } + } + } + } + }, + { + "if": { + "properties": { + "Action": { "const": "EditMap" } + } + }, + "then": { + "properties": { + "FromFile": { + "description": "The relative path to the map in your content pack folder from which to copy (like assets/town.tbin). This can be a .tbin or .xnb file. This field supports tokens and capitalisation doesn't matter.\nContent Patcher will handle tilesheets referenced by the FromFile map for you if it's a .tbin file:\n - If a tilesheet isn't referenced by the target map, Content Patcher will add it for you (with a z_ ID prefix to avoid conflicts with hardcoded game logic). If the source map has a custom version of a tilesheet that's already referenced, it'll be added as a separate tilesheet only used by your tiles.\n - If you include the tilesheet file in your mod folder, Content Patcher will use that one automatically; otherwise it will be loaded from the game's Content/Maps folder.", + "$ref": "#/definitions/FromFile" + }, + "FromArea": { + "title": "Source area", + "description": "The part of the source map to copy. Defaults to the whole source map.", + "$ref": "#/definitions/Rectangle" + }, + "ToArea": { + "title": "Target area", + "description": "The part of the target map to replace.", + "$ref": "#/definitions/Rectangle" + } + }, + "required": [ "FromFile", "ToArea" ] + } + } + ] + } + }, + "$schema": { + "title": "Schema", + "description": "The schema this JSON should follow. Useful for JSON validation tools.", + "type": "string", + "format": "uri" + } + }, + "definitions": { "Condition": { "type": "object", "additionalProperties": { "type": "string" } }, - "DynamicToken": { - "type": "object", - "properties": { - "Name": { - "tit