From be18221f83c79eacb51b7809426116a9e3efaa2b Mon Sep 17 00:00:00 2001 From: darkrrb <177549718+DarkRRb@users.noreply.github.com> Date: Tue, 14 Jan 2025 23:50:13 +0800 Subject: [PATCH] Add Configure Schema --- Lagrange.OneBot/Resources/appsettings.json | 1 + .../Resources/appsettings_schema.json | 392 ++++++++++++++++++ 2 files changed, 393 insertions(+) create mode 100644 Lagrange.OneBot/Resources/appsettings_schema.json diff --git a/Lagrange.OneBot/Resources/appsettings.json b/Lagrange.OneBot/Resources/appsettings.json index 8a3f016bf..aafc3eab9 100644 --- a/Lagrange.OneBot/Resources/appsettings.json +++ b/Lagrange.OneBot/Resources/appsettings.json @@ -1,4 +1,5 @@ { + "$schema": "https://raw.githubusercontent.com/LagrangeDev/Lagrange.Core/master/Lagrange.OneBot/Resources/appsettings_schema.json", "Logging": { "LogLevel": { "Default": "Information", diff --git a/Lagrange.OneBot/Resources/appsettings_schema.json b/Lagrange.OneBot/Resources/appsettings_schema.json new file mode 100644 index 000000000..0399b7578 --- /dev/null +++ b/Lagrange.OneBot/Resources/appsettings_schema.json @@ -0,0 +1,392 @@ +{ + "$schema": "https://json-schema.org/draft-07/hyper-schema#", + "allOf": [ + { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "Logging": { + "$ref": "#/definitions/logging" + } + } + }, + { + "type": "object", + "properties": { + "Account": { + "type": "object", + "properties": { + "Uin": { + "type": "integer", + "minimum": 0, + "description": "Uin, Only used to create lagrange-{uin}.db and qr-{uin}.png", + "default": 0 + }, + "Protocol": { + "type": "string", + "enum": [ + "Linux", + "Windows", + "MacOs" + ], + "description": "Protocol Platform", + "default": "Linux" + }, + "AutoReconnect": { + "type": "boolean", + "description": "Whether to auto reconnect", + "default": true + }, + "UseIPv6Network": { + "type": "boolean", + "description": "Whether to use IPv6, IPv6 implementation has an exception", + "default": false + }, + "GetOptimumServer": { + "type": "boolean", + "description": "Whether to get optimum server", + "default": true + }, + "AutoReLogin": { + "type": "boolean", + "description": "Whether to auto relogin", + "default": true + } + } + }, + "ConfigPath": { + "type": "object", + "properties": { + "Keystore": { + "type": "string", + "description": "Keystore file location", + "default": "keystore.json" + }, + "DeviceInfo": { + "type": "string", + "description": "device file location", + "default": "device.json" + }, + "Database": { + "type": "string", + "description": "database file location", + "default": "lagrange.db" + }, + "AppInfo": { + "type": "string", + "description": "appinfo file location", + "default": "appinfo.db" + } + } + }, + "MusicSignServerUrl": { + "type": "string", + "description": "Music signer url", + "default": "" + }, + "SignServerUrl": { + "type": "string", + "description": "Signer url", + "default": "" + }, + "SignProxyUrl": { + "type": "string", + "description": "Signer proxy url, only support HTTP proxy", + "default": "" + }, + "Message": { + "type": "object", + "properties": { + "IgnoreSelf": { + "type": "boolean", + "description": "Whether to ignore self", + "default": false + }, + "StringPost": { + "type": "boolean", + "description": "Whether to post by string", + "default": false + } + } + }, + "QrCode": { + "type": "object", + "properties": { + "ConsoleCompatibilityMode": { + "type": "boolean", + "description": "Whether to show compatibility qrcode", + "default": false + } + } + }, + "Implementations": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "object", + "properties": { + "Type": { + "type": "string", + "enum": [ + "ReverseWebSocket" + ], + "description": "Implementation type" + }, + "Host": { + "type": "string", + "description": "WS connect host" + }, + "Port": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "Suffix": { + "type": "string", + "description": "WS path" + }, + "ReconnectInterval": { + "type": "integer", + "minimum": 0, + "description": "Reconnect interval" + }, + "HeartBeatInterval": { + "type": "integer", + "minimum": 0, + "description": "Heart beat interval, 0 to disable" + }, + "HeartBeatEnable": { + "type": "boolean", + "description": "Whether to send heart beat" + }, + "AccessToken": { + "type": "string", + "description": "Access token" + } + }, + "description": "Implementation" + }, + { + "type": "object", + "properties": { + "Type": { + "type": "string", + "enum": [ + "ForwardWebSocket" + ], + "description": "Implementation type" + }, + "Host": { + "type": "string", + "description": "WS bind host" + }, + "Port": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "HeartBeatInterval": { + "type": "integer", + "minimum": 0, + "description": "Heart beat interval, 0 to disable" + }, + "HeartBeatEnable": { + "type": "boolean", + "description": "Whether to send heart beat" + }, + "AccessToken": { + "type": "string", + "description": "Access token" + } + }, + "description": "Implementation" + }, + { + "type": "object", + "properties": { + "Type": { + "type": "string", + "enum": [ + "HttpPost" + ], + "description": "Implementation type" + }, + "Host": { + "type": "string", + "description": "Http connect host" + }, + "Port": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "Suffix": { + "type": "string", + "description": "Http path" + }, + "HeartBeatInterval": { + "type": "integer", + "minimum": 0, + "description": "Heart beat interval, 0 to disable" + }, + "HeartBeatEnable": { + "type": "boolean", + "description": "Whether to send heart beat" + }, + "AccessToken": { + "type": "string", + "description": "Access token" + } + }, + "description": "Implementation" + }, + { + "type": "object", + "properties": { + "Type": { + "type": "string", + "enum": [ + "Http" + ], + "description": "Implementation type" + }, + "Host": { + "type": "string", + "description": "Http bind host" + }, + "Port": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "AccessToken": { + "type": "string", + "description": "Access token" + } + }, + "description": "Implementation" + } + ] + }, + "description": "Implementation to use" + } + } + } + ], + "definitions": { + "logging": { + "title": "logging options", + "type": "object", + "description": "Configuration for Microsoft.Extensions.Logging.", + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + }, + "Console": { + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + }, + "FormatterName": { + "description": "Name of the log message formatter to use. Defaults to 'simple'.", + "type": "string", + "default": "simple" + }, + "FormatterOptions": { + "title": "formatter options", + "description": "Log message formatter options. Additional properties are available on the options depending on the configured formatter. The formatter is specified by FormatterName.", + "type": "object", + "properties": { + "IncludeScopes": { + "description": "Include scopes when true. Defaults to false.", + "type": "boolean", + "default": false + }, + "TimestampFormat": { + "description": "Format string used to format timestamp in logging messages. Defaults to null.", + "type": "string" + }, + "UseUtcTimestamp": { + "description": "Indication whether or not UTC timezone should be used to for timestamps in logging messages. Defaults to false.", + "type": "boolean", + "default": false + } + } + }, + "LogToStandardErrorThreshold": { + "$ref": "#/definitions/logLevelThreshold", + "description": "The minimum level of messages are written to Console.Error." + } + } + }, + "EventSource": { + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + } + } + }, + "Debug": { + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + } + } + }, + "EventLog": { + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + } + } + }, + "ElmahIo": { + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + } + } + }, + "ElmahIoBreadcrumbs": { + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + } + } + } + }, + "additionalProperties": { + "title": "provider logging settings", + "type": "object", + "description": "Logging configuration for a provider. The provider name must match the configuration's JSON property property name.", + "properties": { + "LogLevel": { + "$ref": "#/definitions/logLevel" + } + } + } + }, + "logLevel": { + "title": "logging level options", + "description": "Log level configurations used when creating logs. Only logs that exceeds its matching log level will be enabled. Each log level configuration has a category specified by its JSON property name. For more information about configuring log levels, see https://docs.microsoft.com/aspnet/core/fundamentals/logging/#configure-logging.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/logLevelThreshold" + } + }, + "logLevelThreshold": { + "description": "Log level threshold.", + "type": "string", + "enum": [ + "Trace", + "Debug", + "Information", + "Warning", + "Error", + "Critical", + "None" + ] + } + } +} \ No newline at end of file