diff --git a/.gitignore b/.gitignore index 81c60b6019..9f17b77d05 100644 --- a/.gitignore +++ b/.gitignore @@ -101,7 +101,7 @@ preserve.belle /tests/Umbraco.Tests.UnitTests/[Uu]mbraco/[Dd]ata/TEMP/ # Ignore auto-generated schema -/src/Umbraco.Cms.Targets/appsettings-schema.json +/src/Umbraco.Cms.Targets/tasks/ /src/Umbraco.Cms.Targets/appsettings-schema.*.json /src/Umbraco.Web.UI/appsettings-schema.json /src/Umbraco.Web.UI/appsettings-schema.*.json diff --git a/Directory.Build.props b/Directory.Build.props index dd6f8126b1..37b2e66977 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ net7.0 - preview + latest Umbraco HQ Umbraco Copyright © Umbraco $([System.DateTime]::Today.ToString('yyyy')) @@ -41,7 +41,7 @@ - + diff --git a/src/JsonSchema/AppSettings.cs b/src/JsonSchema/AppSettings.cs deleted file mode 100644 index 6f53541df4..0000000000 --- a/src/JsonSchema/AppSettings.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using Umbraco.Cms.Core.Configuration; -using Umbraco.Cms.Core.Configuration.Models; - -namespace JsonSchema; - -internal class AppSettings -{ - // ReSharper disable once InconsistentNaming - public CmsDefinition? CMS { get; set; } - - /// - /// Configurations for the Umbraco CMS - /// - public class CmsDefinition - { - public ContentSettings? Content { get; set; } - - public CoreDebugSettings? Debug { get; set; } - - public ExceptionFilterSettings? ExceptionFilter { get; set; } - - public ModelsBuilderSettings? ModelsBuilder { get; set; } - - public GlobalSettings? Global { get; set; } - - public HealthChecksSettings? HealthChecks { get; set; } - - public HostingSettings? Hosting { get; set; } - - public ImagingSettings? Imaging { get; set; } - - public IndexCreatorSettings? Examine { get; set; } - - public KeepAliveSettings? KeepAlive { get; set; } - - public LoggingSettings? Logging { get; set; } - - public NuCacheSettings? NuCache { get; set; } - - public RequestHandlerSettings? RequestHandler { get; set; } - - public RuntimeSettings? Runtime { get; set; } - - public SecuritySettings? Security { get; set; } - - public TourSettings? Tours { get; set; } - - public TypeFinderSettings? TypeFinder { get; set; } - - public WebRoutingSettings? WebRouting { get; set; } - - public UmbracoPluginSettings? Plugins { get; set; } - - public UnattendedSettings? Unattended { get; set; } - - public RichTextEditorSettings? RichTextEditor { get; set; } - - public RuntimeMinificationSettings? RuntimeMinification { get; set; } - - public BasicAuthSettings? BasicAuth { get; set; } - - public PackageMigrationSettings? PackageMigration { get; set; } - - public LegacyPasswordMigrationSettings? LegacyPasswordMigration { get; set; } - - public ContentDashboardSettings? ContentDashboard { get; set; } - - public HelpPageSettings? HelpPage { get; set; } - - public InstallDefaultDataSettings? DefaultDataCreation { get; set; } - - public DataTypesSettings? DataTypes { get; set; } - - public LicensesSettings? Licenses { get; set; } - - public MarketplaceSettings? Marketplace { get; set; } - } -} diff --git a/src/JsonSchema/NamespacePrefixedSchemaNameGenerator.cs b/src/JsonSchema/NamespacePrefixedSchemaNameGenerator.cs deleted file mode 100644 index 137dd551cf..0000000000 --- a/src/JsonSchema/NamespacePrefixedSchemaNameGenerator.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using System; -using NJsonSchema.Generation; - -namespace JsonSchema -{ - internal class NamespacePrefixedSchemaNameGenerator : DefaultSchemaNameGenerator - { - public override string Generate(Type type) => type.Namespace?.Replace(".", string.Empty) + base.Generate(type); - } -} diff --git a/src/JsonSchema/Options.cs b/src/JsonSchema/Options.cs deleted file mode 100644 index 7f4ed511a9..0000000000 --- a/src/JsonSchema/Options.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using CommandLine; - -namespace JsonSchema -{ - internal class Options - { - [Option('m', "mainOutputFile", Required = false, HelpText = "Set path of the main output file.", Default = "../../../../Umbraco.Web.UI/appsettings-schema.json")] - public string MainOutputFile { get; set; } = null!; - - [Option('f', "cmsOutputFile", Required = false, HelpText = "Set path of the cms output file.", Default = "../../../../Umbraco.Web.UI/appsettings-schema.umbraco.json")] - public string CmsOutputFile { get; set; } = null!; - } -} diff --git a/src/JsonSchema/Program.cs b/src/JsonSchema/Program.cs deleted file mode 100644 index 12246ceecb..0000000000 --- a/src/JsonSchema/Program.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using System; -using System.IO; -using System.Threading.Tasks; -using CommandLine; - -namespace JsonSchema -{ - internal class Program - { - public static async Task Main(string[] args) - { - try - { - await Parser.Default.ParseArguments(args) - .WithParsedAsync(Execute); - } - catch (Exception e) - { - Console.WriteLine(e); - throw; - } - } - - private static async Task Execute(Options options) - { - var generator = new UmbracoJsonSchemaGenerator(); - - var cmsSchema = await generator.GenerateCmsFile(); - await WriteSchemaToFile(cmsSchema, options.CmsOutputFile); - - var schema = await generator.GenerateMainFile(); - await WriteSchemaToFile(schema, options.MainOutputFile); - } - - private static async Task WriteSchemaToFile(string schema, string filePath) - { - var mainPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, filePath)); - Console.WriteLine("Path to use {0}", mainPath); - Directory.CreateDirectory(Path.GetDirectoryName(mainPath)!); - Console.WriteLine("Ensured directory exists"); - await File.WriteAllTextAsync(mainPath, schema); - - Console.WriteLine("File written at {0}", mainPath); - } - } -} diff --git a/src/JsonSchema/UmbracoJsonSchemaGenerator.cs b/src/JsonSchema/UmbracoJsonSchemaGenerator.cs deleted file mode 100644 index eeec48bcd7..0000000000 --- a/src/JsonSchema/UmbracoJsonSchemaGenerator.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using Microsoft.Extensions.FileProviders; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using NJsonSchema.Generation; -using Umbraco.Cms.Core.Configuration.Models; - -namespace JsonSchema; - -/// -/// Generator of the JsonSchema for AppSettings.json including A specific Umbraco version. -/// -public class UmbracoJsonSchemaGenerator -{ - private static readonly HttpClient s_client = new(); - private readonly JsonSchemaGenerator _innerGenerator; - - /// - /// Initializes a new instance of the class. - /// - public UmbracoJsonSchemaGenerator() - => _innerGenerator = new JsonSchemaGenerator(new UmbracoJsonSchemaGeneratorSettings()); - - /// - /// Generates a json representing the JsonSchema for AppSettings.json including A specific Umbraco version.. - /// - public async Task GenerateMainFile() - { - JObject officialSchema = await GetOfficialAppSettingsSchema(); - JObject externalFilePoints = GenerateSchemaWithExternalDefinitions(); - - officialSchema.Merge(externalFilePoints); - - return officialSchema.ToString(); - } - - - /// - /// Generates the CMS file - /// - /// - public Task GenerateCmsFile() - { - JObject cmsSchema = GenerateUmbracoSchema(); - - return Task.FromResult(cmsSchema.ToString()); - } - - - - private JObject GenerateSchemaWithExternalDefinitions() - { - var fileProvider = new EmbeddedFileProvider(GetType().Assembly); - - IFileInfo schema = fileProvider.GetFileInfo("appsettings-schema.json"); - - using (Stream? stream = schema.CreateReadStream()) - using (var reader = new StreamReader(stream)) - { - return JsonConvert.DeserializeObject(reader.ReadToEnd())!; - } - } - - private async Task GetOfficialAppSettingsSchema() - { - HttpResponseMessage response = await s_client.GetAsync("https://json.schemastore.org/appsettings.json") - .ConfigureAwait(false); - - var result = await response.Content.ReadAsStringAsync(); - - return JsonConvert.DeserializeObject(result)!; - } - - private JObject GenerateUmbracoSchema() - { - NJsonSchema.JsonSchema schema = _innerGenerator.Generate(typeof(AppSettings)); - - // TODO: when the "UmbracoPath" setter is removed from "GlobalSettings" (scheduled for V12), remove this line as well - schema.Definitions["UmbracoCmsCoreConfigurationModelsGlobalSettings"]?.Properties?.Remove(nameof(GlobalSettings.UmbracoPath));return JsonConvert.DeserializeObject(schema.ToJson())!; - } -} diff --git a/src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs b/src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs deleted file mode 100644 index 46625aeb2c..0000000000 --- a/src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using System; -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Serialization; -using NJsonSchema.Generation; - -namespace JsonSchema -{ - /// - public class UmbracoJsonSchemaGeneratorSettings : JsonSchemaGeneratorSettings - { - /// - /// Initializes a new instance of the class. - /// - public UmbracoJsonSchemaGeneratorSettings() - { - AlwaysAllowAdditionalObjectProperties = true; - SerializerSettings = new JsonSerializerSettings() - { - ContractResolver = new WritablePropertiesOnlyResolver() - }; - DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull; - SchemaNameGenerator = new NamespacePrefixedSchemaNameGenerator(); - SerializerSettings.Converters.Add(new StringEnumConverter()); - IgnoreObsoleteProperties = true; - GenerateExamples = true; - } - - private class WritablePropertiesOnlyResolver : DefaultContractResolver - { - protected override IList CreateProperties(Type type, MemberSerialization memberSerialization) - { - IList props = base.CreateProperties(type, memberSerialization); - return props.Where(p => p.Writable).ToList(); - } - } - } -} diff --git a/src/JsonSchema/appsettings-schema.json b/src/JsonSchema/appsettings-schema.json deleted file mode 100644 index 44b006b853..0000000000 --- a/src/JsonSchema/appsettings-schema.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "properties": { - "Umbraco": { - "description": "The container of all Umbraco content", - "oneOf": [ - { - "type": "null" - }, - { - "properties": { - "CMS": { - "description": "Configuration of Umbraco CMS", - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "appsettings-schema.Umbraco.Cms.json#/definitions/JsonSchemaCmsDefinition" - } - ] - }, - "Forms": { - "description": "Configuration of Umbraco Forms", - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "appsettings-schema.Umbraco.Forms.json#/definitions/JsonSchemaFormsDefinition" - } - ] - }, - "Deploy": { - "description": "Configuration of Umbraco Deploy", - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "appsettings-schema.Umbraco.Deploy.json#/definitions/JsonSchemaDeployDefinition" - } - ] - }, - "Workflow": { - "description": "Configuration of Umbraco Workflow", - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "appsettings-schema.Umbraco.Workflow.json#/definitions/JsonSchemaWorkflowDefinition" - } - ] - } - } - } - ] - } - } -} diff --git a/src/Umbraco.Cms.Targets/Umbraco.Cms.Targets.csproj b/src/Umbraco.Cms.Targets/Umbraco.Cms.Targets.csproj index b86d4f6e52..056eb09513 100644 --- a/src/Umbraco.Cms.Targets/Umbraco.Cms.Targets.csproj +++ b/src/Umbraco.Cms.Targets/Umbraco.Cms.Targets.csproj @@ -16,18 +16,38 @@ - - - + - $(MSBuildThisFileDirectory)appsettings-schema.json - $(MSBuildThisFileDirectory)appsettings-schema.Umbraco.Cms.json - $(MSBuildThisFileDirectory)..\JsonSchema\ + <_UmbracoCmsJsonSchemaReference>appsettings-schema.Umbraco.Cms.json + NU5100;NU5128 - - - + + + + + + + + + + <_UmbracoJsonSchemaExtensionsFiles Include="$(PkgUmbraco_JsonSchema_Extensions)\tasks\netstandard2.0\**" /> + + + + + + + + + + + + + + + + diff --git a/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.props b/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.props index a967c4fd33..6168686bcb 100644 --- a/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.props +++ b/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.props @@ -9,4 +9,8 @@ + + + + diff --git a/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.targets b/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.targets index d33f644293..4d6e128b68 100644 --- a/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.targets +++ b/src/Umbraco.Cms.Targets/buildTransitive/Umbraco.Cms.Targets.targets @@ -1,13 +1,32 @@ - - - <_SchemaFiles Include="$(MSBuildThisFileDirectory)..\appsettings-schema.json" /> - <_SchemaFiles Include="$(MSBuildThisFileDirectory)..\appsettings-schema.Umbraco.Cms.json" /> - - - + + + + appsettings.json + + + appsettings-schema.json + + + + + + + + + + + + + + + + + + + <_AppPluginsFiles Include="App_Plugins\**" /> @@ -15,6 +34,7 @@ + <_UmbracoFolderFiles Include="umbraco\config\**" /> diff --git a/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs b/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs index 92c443fd77..19b2fb44fb 100644 --- a/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs @@ -82,8 +82,8 @@ public class GlobalSettings public string UmbracoPath { get => Constants.System.DefaultUmbracoPath; - [Obsolete($"{nameof(UmbracoPath)} is no longer configurable, property setter is scheduled for removal in V12")] - // NOTE: when removing this, also clean up the hardcoded removal of UmbracoPath in UmbracoJsonSchemaGenerator + [Obsolete($"{nameof(UmbracoPath)} is no longer configurable, this property setter is scheduled for removal in V12.")] + // NOTE: When removing this, also clean up the hardcoded removal of UmbracoPath in Umbraco.JsonSchema set { } } diff --git a/src/Umbraco.Core/Configuration/Models/LicensesSettings.cs b/src/Umbraco.Core/Configuration/Models/LicensesSettings.cs deleted file mode 100644 index f8de1d7265..0000000000 --- a/src/Umbraco.Core/Configuration/Models/LicensesSettings.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -namespace Umbraco.Cms.Core.Configuration.Models; - -/// -/// Typed configuration options for license settings. -/// -public class LicensesSettings : Dictionary -{ -} diff --git a/src/Umbraco.Core/Configuration/Models/MarketplaceSettings.cs b/src/Umbraco.Core/Configuration/Models/MarketplaceSettings.cs index 73f7da185f..092e420e3c 100644 --- a/src/Umbraco.Core/Configuration/Models/MarketplaceSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/MarketplaceSettings.cs @@ -12,5 +12,5 @@ public class MarketplaceSettings /// /// Gets or sets the additional parameters that are sent to the Marketplace. /// - public Dictionary AdditionalParameters { get; set; } = new (); + public IDictionary AdditionalParameters { get; set; } = new Dictionary(); } diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index e1a0831efd..45d32a65ee 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -28,15 +28,6 @@ false - - - appsettings.json - - - appsettings-schema.json - - - diff --git a/src/Umbraco.Web.UI/appsettings.Development.template.json b/src/Umbraco.Web.UI/appsettings.Development.template.json index b2bde5bf2d..b02fdd604a 100644 --- a/src/Umbraco.Web.UI/appsettings.Development.template.json +++ b/src/Umbraco.Web.UI/appsettings.Development.template.json @@ -1,5 +1,5 @@ { - "$schema" : "./appsettings-schema.json", + "$schema": "appsettings-schema.json", "Serilog": { "MinimumLevel": { "Default": "Information", diff --git a/src/Umbraco.Web.UI/appsettings.template.json b/src/Umbraco.Web.UI/appsettings.template.json index b7aa07acf8..c0d6784ac2 100644 --- a/src/Umbraco.Web.UI/appsettings.template.json +++ b/src/Umbraco.Web.UI/appsettings.template.json @@ -1,5 +1,5 @@ { - "$schema": "./appsettings-schema.json", + "$schema": "appsettings-schema.json", "ConnectionStrings": { "umbracoDbDSN": "" }, diff --git a/templates/UmbracoProject/.gitignore b/templates/UmbracoProject/.gitignore index 088126cc3a..1b6f65e6da 100644 --- a/templates/UmbracoProject/.gitignore +++ b/templates/UmbracoProject/.gitignore @@ -459,8 +459,9 @@ $RECYCLE.BIN/ ## Umbraco CMS ## -# JSON schema file for appsettings.json +# JSON schema files for appsettings.json appsettings-schema.json +appsettings-schema.*.json # Packages created from the backoffice (package.xml/package.zip) /umbraco/Data/CreatedPackages/ diff --git a/templates/UmbracoProject/UmbracoProject.csproj b/templates/UmbracoProject/UmbracoProject.csproj index a71d367a7a..00f7c4b6ff 100644 --- a/templates/UmbracoProject/UmbracoProject.csproj +++ b/templates/UmbracoProject/UmbracoProject.csproj @@ -26,15 +26,6 @@ false false - - - - appsettings.json - - - appsettings-schema.json - - diff --git a/templates/UmbracoProject/appsettings.Development.json b/templates/UmbracoProject/appsettings.Development.json index d789f6cd32..17b9f86361 100644 --- a/templates/UmbracoProject/appsettings.Development.json +++ b/templates/UmbracoProject/appsettings.Development.json @@ -1,5 +1,5 @@ { - "$schema": "./appsettings-schema.json", + "$schema": "appsettings-schema.json", "Serilog": { "MinimumLevel": { "Default": "Information" diff --git a/templates/UmbracoProject/appsettings.json b/templates/UmbracoProject/appsettings.json index 85f6c15dc7..f1e53a9e48 100644 --- a/templates/UmbracoProject/appsettings.json +++ b/templates/UmbracoProject/appsettings.json @@ -1,5 +1,5 @@ { - "$schema": "./appsettings-schema.json", + "$schema": "appsettings-schema.json", "Serilog": { "MinimumLevel": { "Default": "Information", diff --git a/tools/Umbraco.JsonSchema/Options.cs b/tools/Umbraco.JsonSchema/Options.cs new file mode 100644 index 0000000000..e2e8793db4 --- /dev/null +++ b/tools/Umbraco.JsonSchema/Options.cs @@ -0,0 +1,7 @@ +using CommandLine; + +internal class Options +{ + [Option("outputFile", Default = "appsettings-schema.Umbraco.Cms.json", HelpText = "Output file to save the generated JSON schema for Umbraco CMS.")] + public string OutputFile { get; set; } = null!; +} diff --git a/tools/Umbraco.JsonSchema/Program.cs b/tools/Umbraco.JsonSchema/Program.cs new file mode 100644 index 0000000000..adf17c5c8c --- /dev/null +++ b/tools/Umbraco.JsonSchema/Program.cs @@ -0,0 +1,14 @@ +using CommandLine; +using Umbraco.Cms.Core.Configuration.Models; + +await Parser.Default.ParseArguments(args).WithParsedAsync(async options => +{ + // Generate CMS schema + var jsonSchemaGenerator = new UmbracoJsonSchemaGenerator(); + var jsonSchema = jsonSchemaGenerator.Generate(typeof(UmbracoCmsSchema)); + + // TODO: When the UmbracoPath setter is removed from GlobalSettings (scheduled for V12), remove this line as well + jsonSchema.Definitions[nameof(GlobalSettings)]?.Properties?.Remove(nameof(GlobalSettings.UmbracoPath)); + + await File.WriteAllTextAsync(options.OutputFile, jsonSchema.ToJson()); +}); diff --git a/src/JsonSchema/JsonSchema.csproj b/tools/Umbraco.JsonSchema/Umbraco.JsonSchema.csproj similarity index 62% rename from src/JsonSchema/JsonSchema.csproj rename to tools/Umbraco.JsonSchema/Umbraco.JsonSchema.csproj index 36463de3e0..32da8f798a 100644 --- a/src/JsonSchema/JsonSchema.csproj +++ b/tools/Umbraco.JsonSchema/Umbraco.JsonSchema.csproj @@ -8,14 +8,9 @@ - - - - - - + diff --git a/tools/Umbraco.JsonSchema/UmbracoCmsSchema.cs b/tools/Umbraco.JsonSchema/UmbracoCmsSchema.cs new file mode 100644 index 0000000000..86e64d2aa5 --- /dev/null +++ b/tools/Umbraco.JsonSchema/UmbracoCmsSchema.cs @@ -0,0 +1,81 @@ +using Umbraco.Cms.Core.Configuration; +using Umbraco.Cms.Core.Configuration.Models; + +internal class UmbracoCmsSchema +{ + public UmbracoDefinition Umbraco { get; set; } = null!; + + /// + /// Configuration container for all Umbraco products. + /// + public class UmbracoDefinition + { + public UmbracoCmsDefinition CMS { get; set; } = null!; + } + + /// + /// Configuration of Umbraco CMS. + /// + public class UmbracoCmsDefinition + { + public ContentSettings Content { get; set; } = null!; + + public CoreDebugSettings Debug { get; set; } = null!; + + public ExceptionFilterSettings ExceptionFilter { get; set; } = null!; + + public ModelsBuilderSettings ModelsBuilder { get; set; } = null!; + + public GlobalSettings Global { get; set; } = null!; + + public HealthChecksSettings HealthChecks { get; set; } = null!; + + public HostingSettings Hosting { get; set; } = null!; + + public ImagingSettings Imaging { get; set; } = null!; + + public IndexCreatorSettings Examine { get; set; } = null!; + + public KeepAliveSettings KeepAlive { get; set; } = null!; + + public LoggingSettings Logging { get; set; } = null!; + + public NuCacheSettings NuCache { get; set; } = null!; + + public RequestHandlerSettings RequestHandler { get; set; } = null!; + + public RuntimeSettings Runtime { get; set; } = null!; + + public SecuritySettings Security { get; set; } = null!; + + public TourSettings Tours { get; set; } = null!; + + public TypeFinderSettings TypeFinder { get; set; } = null!; + + public WebRoutingSettings WebRouting { get; set; } = null!; + + public UmbracoPluginSettings Plugins { get; set; } = null!; + + public UnattendedSettings Unattended { get; set; } = null!; + + public RichTextEditorSettings RichTextEditor { get; set; } = null!; + + public RuntimeMinificationSettings RuntimeMinification { get; set; } = null!; + + public BasicAuthSettings BasicAuth { get; set; } = null!; + + public PackageMigrationSettings PackageMigration { get; set; } = null!; + + public LegacyPasswordMigrationSettings LegacyPasswordMigration { get; set; } = null!; + + public ContentDashboardSettings ContentDashboard { get; set; } = null!; + + public HelpPageSettings HelpPage { get; set; } = null!; + + public InstallDefaultDataSettings DefaultDataCreation { get; set; } = null!; + + public DataTypesSettings DataTypes { get; set; } = null!; + + public MarketplaceSettings Marketplace { get; set; } = null!; + } +} diff --git a/tools/Umbraco.JsonSchema/UmbracoJsonSchemaGenerator.cs b/tools/Umbraco.JsonSchema/UmbracoJsonSchemaGenerator.cs new file mode 100644 index 0000000000..f1a55479e3 --- /dev/null +++ b/tools/Umbraco.JsonSchema/UmbracoJsonSchemaGenerator.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using NJsonSchema.Generation; + +/// +public class UmbracoJsonSchemaGenerator : JsonSchemaGenerator +{ + /// + /// Initializes a new instance of the class. + /// + public UmbracoJsonSchemaGenerator() + : base(new JsonSchemaGeneratorSettings() + { + AlwaysAllowAdditionalObjectProperties = true, + DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull, + FlattenInheritanceHierarchy = true, + IgnoreObsoleteProperties = true, + SerializerSettings = new JsonSerializerSettings() + { + ContractResolver = new WritablePropertiesOnlyResolver() + } + }) + { + Settings.SerializerSettings.Converters.Add(new StringEnumConverter()); + } + + /// + private class WritablePropertiesOnlyResolver : DefaultContractResolver + { + /// + protected override IList CreateProperties(Type type, MemberSerialization memberSerialization) + => base.CreateProperties(type, memberSerialization).Where(p => p.Writable).ToList(); + } +} diff --git a/umbraco.sln b/umbraco.sln index a98ac5cc0d..f0122909d6 100644 --- a/umbraco.sln +++ b/umbraco.sln @@ -81,7 +81,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Tests.UnitTests", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Web.Common", "src\Umbraco.Web.Common\Umbraco.Web.Common.csproj", "{79E4293D-C92C-4649-AEC8-F1EFD95BDEB1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonSchema", "src\JsonSchema\JsonSchema.csproj", "{2A5027D9-F71D-4957-929E-F7A56AA1B95A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.JsonSchema", "tools\Umbraco.JsonSchema\Umbraco.JsonSchema.csproj", "{2A5027D9-F71D-4957-929E-F7A56AA1B95A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Cms.Persistence.Sqlite", "src\Umbraco.Cms.Persistence.Sqlite\Umbraco.Cms.Persistence.Sqlite.csproj", "{32F6A309-EC1E-4CDB-BA80-C804CF680BEE}" EndProject @@ -156,6 +156,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "styles", "styles", "{EA628A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Cms.Imaging.ImageSharp", "src\Umbraco.Cms.Imaging.ImageSharp\Umbraco.Cms.Imaging.ImageSharp.csproj", "{C280181E-597B-4AA5-82E7-D7017E928749}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{05878304-40EB-4F84-B40B-91BDB70DE094}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -325,6 +327,7 @@ Global {D6319409-777A-4BD0-93ED-B2DFD805B32C} = {B5BD12C1-A454-435E-8A46-FF4A364C0382} {A499779C-1B3B-48A8-B551-458E582E6E96} = {B5BD12C1-A454-435E-8A46-FF4A364C0382} {9102ABDF-E537-4E46-B525-C9ED4833EED0} = {B5BD12C1-A454-435E-8A46-FF4A364C0382} + {2A5027D9-F71D-4957-929E-F7A56AA1B95A} = {05878304-40EB-4F84-B40B-91BDB70DE094} {05C1D0C8-C592-468F-AF8F-A299B9B3A903} = {6D72A60B-0542-4AA9-A493-DD4179E838A1} {0946531B-F06D-415B-A4E3-6CBFF5DB1C12} = {995D9EFA-8BB1-4333-80AD-C525A06FD984} {CBCE0A1E-BF29-49A6-9581-EAB3587D823A} = {995D9EFA-8BB1-4333-80AD-C525A06FD984}