Fixed StyleCop issues in JsonSchema project
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Umbraco
|
||||
/// </summary>
|
||||
public UmbracoDefinition Umbraco { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Configuration of Umbraco CMS and packages
|
||||
/// Configuration of Umbraco CMS and packages
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Configurations for the Umbraco CMS
|
||||
/// Configurations for the Umbraco CMS
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configurations for the Umbraco Forms package to Umbraco CMS
|
||||
/// Configurations for the Umbraco Forms package to Umbraco CMS
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Configurations for the Umbraco Forms Field Types
|
||||
/// Configurations for the Umbraco Forms Field Types
|
||||
/// </summary>
|
||||
public class FieldTypesDefinition
|
||||
{
|
||||
public DatePickerSettings DatePicker { get; set; }
|
||||
|
||||
public Recaptcha2Settings Recaptcha2 { get; set; }
|
||||
|
||||
public Recaptcha3Settings Recaptcha3 { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configurations for the Umbraco Deploy package to Umbraco CMS
|
||||
/// Configurations for the Umbraco Deploy package to Umbraco CMS
|
||||
/// </summary>
|
||||
public class DeployDefinition
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
||||
<PackageReference Include="NJsonSchema" Version="10.5.2" />
|
||||
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
|
||||
<PackageReference Include="Umbraco.Forms.Core" Version="9.0.0-preview20210624.66481" />
|
||||
<PackageReference Include="Umbraco.Forms.Core" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
13
src/JsonSchema/Options.cs
Normal file
13
src/JsonSchema/Options.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Generator of the JsonSchema for AppSettings.json including A specific Umbraco version.
|
||||
/// Generator of the JsonSchema for AppSettings.json including A specific Umbraco version.
|
||||
/// </summary>
|
||||
public class UmbracoJsonSchemaGenerator
|
||||
{
|
||||
private static readonly HttpClient s_client = new ();
|
||||
private readonly JsonSchemaGenerator _innerGenerator;
|
||||
private static readonly HttpClient s_client = new HttpClient();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="UmbracoJsonSchemaGenerator"/>.
|
||||
/// Initializes a new instance of the <see cref="UmbracoJsonSchemaGenerator" /> class.
|
||||
/// </summary>
|
||||
/// <param name="definitionPrefix">The prefix to use for definitions generated.</param>
|
||||
public UmbracoJsonSchemaGenerator()
|
||||
=> _innerGenerator = new JsonSchemaGenerator(new UmbracoJsonSchemaGeneratorSettings());
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
public async Task<string> 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<JObject> 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<JObject>(result);
|
||||
|
||||
}
|
||||
|
||||
private JObject GenerateUmbracoSchema()
|
||||
{
|
||||
var schema = _innerGenerator.Generate(typeof(AppSettings));
|
||||
NJsonSchema.JsonSchema schema = _innerGenerator.Generate(typeof(AppSettings));
|
||||
|
||||
return JsonConvert.DeserializeObject<JObject>(schema.ToJson());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="UmbracoJsonSchemaGeneratorSettings"/>.
|
||||
/// Initializes a new instance of the <see cref="UmbracoJsonSchemaGeneratorSettings"/> class.
|
||||
/// </summary>
|
||||
/// <param name="definitionPrefix">The prefix to use for definitions generated.</param>
|
||||
public UmbracoJsonSchemaGeneratorSettings()
|
||||
{
|
||||
AlwaysAllowAdditionalObjectProperties = true;
|
||||
SerializerSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ContractResolver = new WritablePropertiesOnlyResolver()
|
||||
ContractResolver = new WritablePropertiesOnlyResolver()
|
||||
};
|
||||
DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull;
|
||||
SchemaNameGenerator = new NamespacePrefixedSchemaNameGenerator();
|
||||
|
||||
Reference in New Issue
Block a user