Skip to content

Commit ca9dc94

Browse files
committed
Fixed StyleCop issues in JsonSchema project
1 parent 7020793 commit ca9dc94

File tree

7 files changed

+92
-44
lines changed

7 files changed

+92
-44
lines changed

src/JsonSchema/AppSettings.cs

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,120 @@
1-
using Umbraco.Cms.Core.Configuration.Models;
1+
// Copyright (c) Umbraco.
2+
// See LICENSE for more details.
3+
4+
using Umbraco.Cms.Core.Configuration.Models;
25
using Umbraco.Forms.Core.Configuration;
36
using SecuritySettings = Umbraco.Cms.Core.Configuration.Models.SecuritySettings;
47

58
namespace JsonSchema
69
{
7-
public class AppSettings
10+
internal class AppSettings
811
{
12+
/// <summary>
13+
/// Gets or sets the Umbraco
14+
/// </summary>
915
public UmbracoDefinition Umbraco { get; set; }
1016

1117
/// <summary>
12-
/// Configuration of Umbraco CMS and packages
18+
/// Configuration of Umbraco CMS and packages
1319
/// </summary>
14-
public class UmbracoDefinition
20+
internal class UmbracoDefinition
1521
{
22+
// ReSharper disable once InconsistentNaming
1623
public CmsDefinition CMS { get; set; }
24+
1725
public FormsDefinition Forms { get; set; }
26+
1827
public DeployDefinition Deploy { get; set; }
1928

2029
/// <summary>
21-
/// Configurations for the Umbraco CMS
30+
/// Configurations for the Umbraco CMS
2231
/// </summary>
2332
public class CmsDefinition
2433
{
2534
public ActiveDirectorySettings ActiveDirectory { get; set; }
35+
2636
public ContentSettings Content { get; set; }
37+
2738
public ExceptionFilterSettings ExceptionFilter { get; set; }
39+
2840
public ModelsBuilderSettings ModelsBuilder { get; set; }
41+
2942
public GlobalSettings Global { get; set; }
43+
3044
public HealthChecksSettings HealthChecks { get; set; }
45+
3146
public HostingSettings Hosting { get; set; }
47+
3248
public ImagingSettings Imaging { get; set; }
49+
3350
public IndexCreatorSettings Examine { get; set; }
51+
3452
public KeepAliveSettings KeepAlive { get; set; }
53+
3554
public LoggingSettings Logging { get; set; }
55+
3656
public MemberPasswordConfigurationSettings MemberPassword { get; set; }
57+
3758
public NuCacheSettings NuCache { get; set; }
59+
3860
public RequestHandlerSettings RequestHandler { get; set; }
61+
3962
public RuntimeSettings Runtime { get; set; }
63+
4064
public SecuritySettings Security { get; set; }
65+
4166
public TourSettings Tours { get; set; }
67+
4268
public TypeFinderSettings TypeFinder { get; set; }
69+
4370
public UserPasswordConfigurationSettings UserPassword { get; set; }
71+
4472
public WebRoutingSettings WebRouting { get; set; }
73+
4574
public UmbracoPluginSettings Plugins { get; set; }
75+
4676
public UnattendedSettings Unattended { get; set; }
77+
4778
public RichTextEditorSettings RichTextEditor { get; set; }
79+
4880
public RuntimeMinificationSettings RuntimeMinification { get; set; }
81+
4982
public BasicAuthSettings BasicAuth { get; set; }
83+
5084
public PackageMigrationSettings PackageMigration { get; set; }
5185
}
5286

5387
/// <summary>
54-
/// Configurations for the Umbraco Forms package to Umbraco CMS
88+
/// Configurations for the Umbraco Forms package to Umbraco CMS
5589
/// </summary>
5690
public class FormsDefinition
5791
{
5892
public FormDesignSettings FormDesign { get; set; }
93+
5994
public PackageOptionSettings Options { get; set; }
95+
6096
public Umbraco.Forms.Core.Configuration.SecuritySettings Security { get; set; }
97+
6198
public FieldTypesDefinition FieldTypes { get; set; }
6299

63100
/// <summary>
64-
/// Configurations for the Umbraco Forms Field Types
101+
/// Configurations for the Umbraco Forms Field Types
65102
/// </summary>
66103
public class FieldTypesDefinition
67104
{
68105
public DatePickerSettings DatePicker { get; set; }
106+
69107
public Recaptcha2Settings Recaptcha2 { get; set; }
108+
70109
public Recaptcha3Settings Recaptcha3 { get; set; }
71110
}
72111
}
73112

74113
/// <summary>
75-
/// Configurations for the Umbraco Deploy package to Umbraco CMS
114+
/// Configurations for the Umbraco Deploy package to Umbraco CMS
76115
/// </summary>
77116
public class DeployDefinition
78117
{
79-
80118
}
81119
}
82120
}

src/JsonSchema/JsonSchema.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="CommandLineParser" Version="2.8.0" />
1111
<PackageReference Include="NJsonSchema" Version="10.5.2" />
1212
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
13-
<PackageReference Include="Umbraco.Forms.Core" Version="9.0.0-preview20210624.66481" />
13+
<PackageReference Include="Umbraco.Forms.Core" Version="9.0.0" />
1414
</ItemGroup>
1515

1616
<ItemGroup>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using System;
1+
// Copyright (c) Umbraco.
2+
// See LICENSE for more details.
3+
4+
using System;
25
using NJsonSchema.Generation;
36

47
namespace JsonSchema
58
{
6-
public class NamespacePrefixedSchemaNameGenerator : DefaultSchemaNameGenerator
9+
internal class NamespacePrefixedSchemaNameGenerator : DefaultSchemaNameGenerator
710
{
8-
public override string Generate(Type type)
9-
{
10-
return type.Namespace.Replace(".", String.Empty) + base.Generate(type);
11-
}
11+
public override string Generate(Type type) => type.Namespace.Replace(".", string.Empty) + base.Generate(type);
1212
}
1313
}

src/JsonSchema/Options.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Umbraco.
2+
// See LICENSE for more details.
3+
4+
using CommandLine;
5+
6+
namespace JsonSchema
7+
{
8+
internal class Options
9+
{
10+
[Option('o', "outputFile", Required = false, HelpText = "Set path of the output file.", Default = "../../../../Umbraco.Web.UI/umbraco/config/appsettings-schema.json")]
11+
public string OutputFile { get; set; }
12+
}
13+
}

src/JsonSchema/Program.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1+
// Copyright (c) Umbraco.
2+
// See LICENSE for more details.
3+
14
using System;
25
using System.IO;
36
using System.Threading.Tasks;
47
using CommandLine;
58

69
namespace JsonSchema
710
{
8-
class Program
11+
internal class Program
912
{
10-
private class Options
11-
{
12-
[Option('o', "outputFile", Required = false, HelpText = "Set path of the output file.", Default = "../../../../Umbraco.Web.UI/umbraco/config/appsettings-schema.json")]
13-
public string OutputFile { get; set; }
14-
}
15-
1613
public static async Task Main(string[] args)
1714
{
1815
try
@@ -25,7 +22,6 @@ await Parser.Default.ParseArguments<Options>(args)
2522
Console.WriteLine(e);
2623
throw;
2724
}
28-
2925
}
3026

3127
private static async Task Execute(Options options)
@@ -34,7 +30,7 @@ private static async Task Execute(Options options)
3430
var schema = await generator.Generate();
3531

3632
var path = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, options.OutputFile));
37-
Console.WriteLine("Path to use {0}",path);
33+
Console.WriteLine("Path to use {0}", path);
3834
Directory.CreateDirectory(Path.GetDirectoryName(path));
3935
Console.WriteLine("Ensured directory exists");
4036
await File.WriteAllTextAsync(path, schema);

src/JsonSchema/UmbracoJsonSchemaGenerator.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System.Net.Http;
1+
// Copyright (c) Umbraco.
2+
// See LICENSE for more details.
3+
4+
using System.Net.Http;
25
using System.Threading.Tasks;
36
using Newtonsoft.Json;
47
using Newtonsoft.Json.Linq;
@@ -7,28 +10,26 @@
710
namespace JsonSchema
811
{
912
/// <summary>
10-
/// Generator of the JsonSchema for AppSettings.json including A specific Umbraco version.
13+
/// Generator of the JsonSchema for AppSettings.json including A specific Umbraco version.
1114
/// </summary>
1215
public class UmbracoJsonSchemaGenerator
1316
{
17+
private static readonly HttpClient s_client = new ();
1418
private readonly JsonSchemaGenerator _innerGenerator;
15-
private static readonly HttpClient s_client = new HttpClient();
1619

1720
/// <summary>
18-
/// Creates a new instance of <see cref="UmbracoJsonSchemaGenerator"/>.
21+
/// Initializes a new instance of the <see cref="UmbracoJsonSchemaGenerator" /> class.
1922
/// </summary>
20-
/// <param name="definitionPrefix">The prefix to use for definitions generated.</param>
2123
public UmbracoJsonSchemaGenerator()
2224
=> _innerGenerator = new JsonSchemaGenerator(new UmbracoJsonSchemaGeneratorSettings());
2325

24-
2526
/// <summary>
26-
/// Generates a json representing the JsonSchema for AppSettings.json including A specific Umbraco version..
27+
/// Generates a json representing the JsonSchema for AppSettings.json including A specific Umbraco version..
2728
/// </summary>
2829
public async Task<string> Generate()
2930
{
30-
var umbracoSchema = GenerateUmbracoSchema();
31-
var officialSchema = await GetOfficialAppSettingsSchema();
31+
JObject umbracoSchema = GenerateUmbracoSchema();
32+
JObject officialSchema = await GetOfficialAppSettingsSchema();
3233

3334
officialSchema.Merge(umbracoSchema);
3435

@@ -37,19 +38,17 @@ public async Task<string> Generate()
3738

3839
private async Task<JObject> GetOfficialAppSettingsSchema()
3940
{
41+
HttpResponseMessage response = await s_client.GetAsync("https://json.schemastore.org/appsettings.json")
42+
.ConfigureAwait(false);
4043

41-
var response = await s_client.GetAsync("https://json.schemastore.org/appsettings.json");
42-
43-
44-
var result = await response.Content.ReadAsStringAsync();
44+
var result = await response.Content.ReadAsStringAsync();
4545

4646
return JsonConvert.DeserializeObject<JObject>(result);
47-
4847
}
4948

5049
private JObject GenerateUmbracoSchema()
5150
{
52-
var schema = _innerGenerator.Generate(typeof(AppSettings));
51+
NJsonSchema.JsonSchema schema = _innerGenerator.Generate(typeof(AppSettings));
5352

5453
return JsonConvert.DeserializeObject<JObject>(schema.ToJson());
5554
}

src/JsonSchema/UmbracoJsonSchemaGeneratorSettings.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright (c) Umbraco.
2+
// See LICENSE for more details.
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using Newtonsoft.Json;
@@ -12,15 +15,14 @@ namespace JsonSchema
1215
public class UmbracoJsonSchemaGeneratorSettings : JsonSchemaGeneratorSettings
1316
{
1417
/// <summary>
15-
/// Creates a new instance of <see cref="UmbracoJsonSchemaGeneratorSettings"/>.
18+
/// Initializes a new instance of the <see cref="UmbracoJsonSchemaGeneratorSettings"/> class.
1619
/// </summary>
17-
/// <param name="definitionPrefix">The prefix to use for definitions generated.</param>
1820
public UmbracoJsonSchemaGeneratorSettings()
1921
{
2022
AlwaysAllowAdditionalObjectProperties = true;
2123
SerializerSettings = new JsonSerializerSettings()
2224
{
23-
ContractResolver = new WritablePropertiesOnlyResolver()
25+
ContractResolver = new WritablePropertiesOnlyResolver()
2426
};
2527
DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull;
2628
SchemaNameGenerator = new NamespacePrefixedSchemaNameGenerator();

0 commit comments

Comments
 (0)