diff --git a/src/JsonSchema/AppSettings.cs b/src/JsonSchema/AppSettings.cs index 1b7c6d46fc..4af6685d8a 100644 --- a/src/JsonSchema/AppSettings.cs +++ b/src/JsonSchema/AppSettings.cs @@ -1,82 +1,120 @@ -using Umbraco.Cms.Core.Configuration.Models; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Forms.Core.Configuration; using SecuritySettings = Umbraco.Cms.Core.Configuration.Models.SecuritySettings; namespace JsonSchema { - public class AppSettings + internal class AppSettings { + /// + /// Gets or sets the Umbraco + /// public UmbracoDefinition Umbraco { get; set; } /// - /// Configuration of Umbraco CMS and packages + /// Configuration of Umbraco CMS and packages /// - public class UmbracoDefinition + internal class UmbracoDefinition { + // ReSharper disable once InconsistentNaming public CmsDefinition CMS { get; set; } + public FormsDefinition Forms { get; set; } + public DeployDefinition Deploy { get; set; } /// - /// Configurations for the Umbraco CMS + /// Configurations for the Umbraco CMS /// public class CmsDefinition { public ActiveDirectorySettings ActiveDirectory { get; set; } + public ContentSettings Content { 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 MemberPasswordConfigurationSettings MemberPassword { 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 UserPasswordConfigurationSettings UserPassword { 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; } } /// - /// Configurations for the Umbraco Forms package to Umbraco CMS + /// Configurations for the Umbraco Forms package to Umbraco CMS /// public class FormsDefinition { public FormDesignSettings FormDesign { get; set; } + public PackageOptionSettings Options { get; set; } + public Umbraco.Forms.Core.Configuration.SecuritySettings Security { get; set; } + public FieldTypesDefinition FieldTypes { get; set; } /// - /// Configurations for the Umbraco Forms Field Types + /// Configurations for the Umbraco Forms Field Types /// public class FieldTypesDefinition { public DatePickerSettings DatePicker { get; set; } + public Recaptcha2Settings Recaptcha2 { get; set; } + public Recaptcha3Settings Recaptcha3 { get; set; } } } /// - /// Configurations for the Umbraco Deploy package to Umbraco CMS + /// Configurations for the Umbraco Deploy package to Umbraco CMS /// public class DeployDefinition { - } } } diff --git a/src/JsonSchema/JsonSchema.csproj b/src/JsonSchema/JsonSchema.csproj index 3b64612b62..942bdd9705 100644 --- a/src/JsonSchema/JsonSchema.csproj +++ b/src/JsonSchema/JsonSchema.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/JsonSchema/NamespacePrefixedSchemaNameGenerator.cs b/src/JsonSchema/NamespacePrefixedSchemaNameGenerator.cs index 77b7b8c474..54ce0fdedf 100644 --- a/src/JsonSchema/NamespacePrefixedSchemaNameGenerator.cs +++ b/src/JsonSchema/NamespacePrefixedSchemaNameGenerator.cs @@ -1,13 +1,13 @@ -using System; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System; using NJsonSchema.Generation; namespace JsonSchema { - public class NamespacePrefixedSchemaNameGenerator : DefaultSchemaNameGenerator + internal class NamespacePrefixedSchemaNameGenerator : DefaultSchemaNameGenerator { - public override string Generate(Type type) - { - return type.Namespace.Replace(".", String.Empty) + base.Generate(type); - } + 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 new file mode 100644 index 0000000000..9930210cd8 --- /dev/null +++ b/src/JsonSchema/Options.cs @@ -0,0 +1,13 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using CommandLine; + +namespace JsonSchema +{ + internal class Options + { + [Option('o', "outputFile", Required = false, HelpText = "Set path of the output file.", Default = "../../../../Umbraco.Web.UI/umbraco/config/appsettings-schema.json")] + public string OutputFile { get; set; } + } +} diff --git a/src/JsonSchema/Program.cs b/src/JsonSchema/Program.cs index cd09093020..8b02068c46 100644 --- a/src/JsonSchema/Program.cs +++ b/src/JsonSchema/Program.cs @@ -1,3 +1,6 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + using System; using System.IO; using System.Threading.Tasks; @@ -5,14 +8,8 @@ using CommandLine; namespace JsonSchema { - class Program + internal class Program { - private class Options - { - [Option('o', "outputFile", Required = false, HelpText = "Set path of the output file.", Default = "../../../../Umbraco.Web.UI/umbraco/config/appsettings-schema.json")] - public string OutputFile { get; set; } - } - public static async Task Main(string[] args) { try @@ -25,7 +22,6 @@ namespace JsonSchema Console.WriteLine(e); throw; } - } private static async Task Execute(Options options) @@ -34,7 +30,7 @@ namespace JsonSchema var schema = await generator.Generate(); var path = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, options.OutputFile)); - Console.WriteLine("Path to use {0}",path); + Console.WriteLine("Path to use {0}", path); Directory.CreateDirectory(Path.GetDirectoryName(path)); Console.WriteLine("Ensured directory exists"); await File.WriteAllTextAsync(path, schema); diff --git a/src/JsonSchema/UmbracoJsonSchemaGenerator.cs b/src/JsonSchema/UmbracoJsonSchemaGenerator.cs index b6e516d0c5..e06189d3b4 100644 --- a/src/JsonSchema/UmbracoJsonSchemaGenerator.cs +++ b/src/JsonSchema/UmbracoJsonSchemaGenerator.cs @@ -1,4 +1,7 @@ -using System.Net.Http; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -7,28 +10,26 @@ using NJsonSchema.Generation; namespace JsonSchema { /// - /// Generator of the JsonSchema for AppSettings.json including A specific Umbraco version. + /// 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; - private static readonly HttpClient s_client = new HttpClient(); /// - /// Creates a new instance of . + /// Initializes a new instance of the class. /// - /// The prefix to use for definitions generated. public UmbracoJsonSchemaGenerator() => _innerGenerator = new JsonSchemaGenerator(new UmbracoJsonSchemaGeneratorSettings()); - /// - /// Generates a json representing the JsonSchema for AppSettings.json including A specific Umbraco version.. + /// Generates a json representing the JsonSchema for AppSettings.json including A specific Umbraco version.. /// public async Task Generate() { - var umbracoSchema = GenerateUmbracoSchema(); - var officialSchema = await GetOfficialAppSettingsSchema(); + JObject umbracoSchema = GenerateUmbracoSchema(); + JObject officialSchema = await GetOfficialAppSettingsSchema(); officialSchema.Merge(umbracoSchema); @@ -37,19 +38,17 @@ namespace JsonSchema private async Task GetOfficialAppSettingsSchema() { + HttpResponseMessage response = await s_client.GetAsync("https://json.schemastore.org/appsettings.json") + .ConfigureAwait(false); - var response = await s_client.GetAsync("https://json.schemastore.org/appsettings.json"); - - - var result = await response.Content.ReadAsStringAsync(); + var result = await response.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject(result); - } private JObject GenerateUmbracoSchema() { - var schema = _innerGenerator.Generate(typeof(AppSettings)); + NJsonSchema.JsonSchema schema = _innerGenerator.Generate(typeof(AppSettings)); return JsonConvert.DeserializeObject(schema.ToJson()); } diff --git a/src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs b/src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs index 26af0faae2..46625aeb2c 100644 --- a/src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs +++ b/src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; @@ -12,15 +15,14 @@ namespace JsonSchema public class UmbracoJsonSchemaGeneratorSettings : JsonSchemaGeneratorSettings { /// - /// Creates a new instance of . + /// Initializes a new instance of the class. /// - /// The prefix to use for definitions generated. public UmbracoJsonSchemaGeneratorSettings() { AlwaysAllowAdditionalObjectProperties = true; SerializerSettings = new JsonSerializerSettings() { - ContractResolver = new WritablePropertiesOnlyResolver() + ContractResolver = new WritablePropertiesOnlyResolver() }; DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull; SchemaNameGenerator = new NamespacePrefixedSchemaNameGenerator();