Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ship two json schema files.. One that reference others, and a CMS one #12858

Closed
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
0794316
Ship two json schema files.. One that reference others, and a CMS one
bergmania Aug 18, 2022
f33b724
Content modal heading fix (#12797)
tiffy74 Aug 18, 2022
56e2829
Added copy functionality for data types (#11867)
patrickdemooij9 Aug 19, 2022
d6cd9a2
Ship two json schema files.. One that reference others, and a CMS one
bergmania Aug 18, 2022
e520434
Merge remote-tracking branch 'origin/v10/feature/read_json_schema_fro…
bergmania Aug 19, 2022
1024b26
Fix umb-range-slider merging overlapping tooltips (#12777)
bjarnef Aug 19, 2022
753cf35
Use umb-icon component in tracked references to support custom SVG ic…
bjarnef Aug 19, 2022
fa8bb3f
Fix #12770 (#12865)
MayurDeore Aug 22, 2022
523aa6c
V10 Fixup GitHub CodeSpaces / VSCode Remote Container (#12882)
Aug 23, 2022
38f144f
Merge branch 'v10/dev' into v10/contrib
nul800sebastiaan Aug 23, 2022
2431a21
V10/bugfix/variant permissions segments (#12890)
madsrasmussen Aug 24, 2022
0f3feb1
#12802 Fix partial view model type replacements (#12831)
mikaellindemann Aug 24, 2022
6242314
Update appsettings-schema: remove {Member,User}Password from Umbraco:CMS
PerplexDaniel Aug 24, 2022
b55f50c
Translate TreeHeaders to Spanish (#12902)
erikjanwestendorp Aug 26, 2022
47f77b6
Added support for disabling tabs in <umbTabsNav /> elements
abjerner Aug 7, 2022
68cf801
Replace uppercase chars to make behaviour consistent
bjarnef Aug 16, 2022
07fba1e
Revert "Break word for limited width content"
nul800sebastiaan Aug 30, 2022
fcd1c22
chore: Set permissions for GitHub actions
neilnaveen Jun 24, 2022
5f4f169
Translate 'settingsGroup' treeHeader to Spanish
erikjanwestendorp Aug 30, 2022
17d72f9
Update 01_bug_report.yml
nul800sebastiaan Sep 2, 2022
8f4d8d6
Use SVG logo in installer/upgrader (#12922)
bjarnef Sep 2, 2022
7bb5fbf
Translate languages area
erikjanwestendorp Sep 1, 2022
df3777f
Update add-issues-to-review-project.yml
sashashura Sep 2, 2022
1f5d58b
Fix: Media Picker creates duplicated folders (#12918) (#12948)
MayurDeore Sep 5, 2022
a0d6732
Translate content apps to spanish (#12950)
erikjanwestendorp Sep 6, 2022
5f42cf0
Revert "Replace uppercase chars to make behaviour consistent"
nul800sebastiaan Sep 8, 2022
fdc1b02
Fix Nucache rebuilding more type caches than necessary (#12785)
nzdev Sep 8, 2022
1bd0a1f
Set the first app to active if no active apps
matthewcare Sep 3, 2022
4df012e
Skip move logic if the parent is staying the same (#12937)
CyberReiter Sep 9, 2022
902f126
Added support for virtual backoffice icons (#12833)
abjerner Sep 9, 2022
09e2b04
V10: Update examine dependency (#12982)
Zeegaan Sep 12, 2022
a356cf4
Backoffice api: Refactor controllers (#12934)
nikolajlauridsen Sep 13, 2022
e9883ea
Add custom PrependBasePathFileProvider to handle media files with spe…
kjac Sep 13, 2022
b84ccea
Add label-key to prevent cleanup button (#12990)
erikjanwestendorp Sep 14, 2022
6d27454
Added nullable helper for IfNullOrWhiteSpace (#12979)
patrickdemooij9 Sep 15, 2022
eddf0ad
Only show table when any filtered result (#12993)
bjarnef Sep 16, 2022
ad1c945
update npm packages
iOvergaard Sep 16, 2022
6298fb3
Merge pull request #13014 from umbraco/v10/feature/september-dep-updates
nikolajlauridsen Sep 16, 2022
6967fad
pass in parameters needed to member service (#13020)
Bakersbakebread Sep 17, 2022
6f9bf59
fix: focus state for search and help icons
MMasey Sep 17, 2022
51f7beb
Ship two json schema files.. One that reference others, and a CMS one
bergmania Aug 18, 2022
63052dc
Merge remote-tracking branch 'origin/v10/feature/read_json_schema_fro…
bergmania Sep 19, 2022
0b1295d
Missing methods from IMemberService (#13022)
Zeegaan Sep 19, 2022
d18dc92
V10: Fix to allow dragged images in the rich text editor to be correc…
iOvergaard Sep 19, 2022
c1010e5
Merge remote-tracking branch 'origin/v10/dev' into v11/dev
bergmania Sep 19, 2022
ef15da3
Bypass model validation for rendering models (#12999)
kjac Sep 19, 2022
803c044
Updated dependencies and fixed new NRT issues
bergmania Sep 19, 2022
40df989
Merge remote-tracking branch 'origin/v11/dev' into v11/dev
bergmania Sep 19, 2022
8de26c6
Revert "Merge remote-tracking branch 'origin/v11/dev' into v11/dev"
iOvergaard Sep 19, 2022
1ddfcba
Updated more dependencies
bergmania Sep 19, 2022
87c06f5
Back to 10.2.0-ish
nul800sebastiaan Sep 19, 2022
48bd4a5
Grammar (do -> does) and some extra text
nul800sebastiaan Aug 29, 2022
31dc7fa
Fix #12770 (#12865)
MayurDeore Aug 22, 2022
6302630
Revert "Break word for limited width content"
nul800sebastiaan Aug 30, 2022
147c60f
Performance improvement: Reusable data editors (#12921)
kjac Aug 31, 2022
6b967a9
Add virtual SetUpTestConfiguration method (#12928)
Zeegaan Aug 31, 2022
126a259
remove styling from installer (#12923)
iOvergaard Aug 31, 2022
669f8ff
Backoffice Api: Server Controller (#12932)
nikolajlauridsen Sep 1, 2022
7852220
Use staticserviceprovider to provide service (#12939)
Zeegaan Sep 2, 2022
5500f87
Limit what API does when not in used in Install level
bergmania Sep 5, 2022
7d0be19
Add PagedViewModel (#12955)
Zeegaan Sep 6, 2022
3ab57ce
Bump version
nikolajlauridsen Sep 7, 2022
0a77775
Fixed InstallAuthorizeAttribute and simplified other things
bergmania Sep 7, 2022
aa7a7c4
Fix tree root font being larger than it used to be
nul800sebastiaan Sep 7, 2022
48c981d
Hotfix: Move allow edit invariant from non default setting to content…
nikolajlauridsen Sep 7, 2022
0c84b1a
Extend error message with possible solution (#12962)
Zeegaan Sep 7, 2022
788f8c6
Undo breaking change
nikolajlauridsen Sep 7, 2022
79c6733
Ensure new projects use the correct apssettings key for AllowEditInva…
nikolajlauridsen Sep 8, 2022
352da6c
V10: Update examine dependency (#12982)
Zeegaan Sep 12, 2022
22576ed
Backoffice api: Refactor controllers (#12934)
nikolajlauridsen Sep 13, 2022
07b7ef2
Add custom PrependBasePathFileProvider to handle media files with spe…
kjac Sep 13, 2022
963d001
update npm packages
iOvergaard Sep 16, 2022
1fe4c51
V10: Fix to allow dragged images in the rich text editor to be correc…
iOvergaard Sep 19, 2022
b2b2903
Updated dependencies and fixed new NRT issues
bergmania Sep 19, 2022
85147fb
Merge branch 'v10/dev' into v11/dev
nul800sebastiaan Sep 19, 2022
db5d05d
Revert files that shouldn't change back in v11
nul800sebastiaan Sep 19, 2022
85e31bd
Merge branch 'v10/dev' into v10/contrib
nul800sebastiaan Sep 19, 2022
8d5fb41
Revert "Updated dependencies and fixed new NRT issues"
nul800sebastiaan Sep 20, 2022
40035aa
Merge branch 'v10/dev' into v11/dev
nul800sebastiaan Sep 20, 2022
48954bb
New Backoffice - Exposing hardcoded Open API contract (#12953)
bergmania Sep 20, 2022
954d3ec
v10: add Umbraco UI Library to the backoffice (#13031)
iOvergaard Sep 20, 2022
d139f4a
Updated dependencies and fixed new NRT issues
bergmania Sep 19, 2022
42c32e7
Merge branch 'v10/dev' into v11/dev
nul800sebastiaan Sep 20, 2022
0841531
Fix merge conflict
nul800sebastiaan Sep 20, 2022
510d8bf
V11: Update the rich text editor TinyMCE to v6 (#13013)
iOvergaard Sep 20, 2022
d206df0
Updated dependencies and cleaned up
bergmania Sep 23, 2022
3873a07
v11: Decouple dependencies (#12907)
ronaldbarendse Sep 27, 2022
7963b76
Adds additional deploy selector. (#13094)
AndyButland Oct 3, 2022
c9f6d60
Add GitVersionBaseDirectory and fix typo
ronaldbarendse Oct 3, 2022
ad39041
Ship two json schema files.. One that reference others, and a CMS one
bergmania Aug 18, 2022
dbc985c
Ship two json schema files.. One that reference others, and a CMS one
bergmania Aug 18, 2022
c34578b
Ship two json schema files.. One that reference others, and a CMS one
bergmania Aug 18, 2022
2ee9ad1
git ignore
bergmania Oct 5, 2022
94a06eb
Merge remote-tracking branch 'origin/v10/feature/read_json_schema_fro…
bergmania Oct 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 41 additions & 100 deletions src/JsonSchema/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,137 +3,78 @@

using Umbraco.Cms.Core.Configuration;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Deploy.Core.Configuration.DebugConfiguration;
using Umbraco.Deploy.Core.Configuration.DeployConfiguration;
using Umbraco.Deploy.Core.Configuration.DeployProjectConfiguration;
using Umbraco.Forms.Core.Configuration;
using SecuritySettings = Umbraco.Cms.Core.Configuration.Models.SecuritySettings;

namespace JsonSchema
{
internal class AppSettings
{
/// <summary>
/// Gets or sets the Umbraco
/// </summary>
public UmbracoDefinition? Umbraco { get; set; }

/// <summary>
/// Configuration of Umbraco CMS and packages
/// </summary>
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
/// </summary>
public class CmsDefinition
{
public ContentSettings? Content { get; set; }
public CoreDebugSettings? Debug { get; set; }

public ExceptionFilterSettings? ExceptionFilter { get; set; }

public ModelsBuilderSettings? ModelsBuilder { get; set; }
namespace JsonSchema;

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; }
internal class AppSettings
{
// ReSharper disable once InconsistentNaming
public CmsDefinition? CMS { get; set; }

public MemberPasswordConfigurationSettings? MemberPassword { get; set; }
/// <summary>
/// Configurations for the Umbraco CMS
/// </summary>
public class CmsDefinition
{
public ContentSettings? Content { get; set; }
public CoreDebugSettings? Debug { get; set; }

public NuCacheSettings? NuCache { get; set; }
public ExceptionFilterSettings? ExceptionFilter { get; set; }

public RequestHandlerSettings? RequestHandler { get; set; }
public ModelsBuilderSettings? ModelsBuilder { get; set; }

public RuntimeSettings? Runtime { get; set; }
public GlobalSettings? Global { get; set; }

public SecuritySettings? Security { get; set; }
public HealthChecksSettings? HealthChecks { get; set; }

public TourSettings? Tours { get; set; }
public HostingSettings? Hosting { get; set; }

public TypeFinderSettings? TypeFinder { get; set; }
public ImagingSettings? Imaging { get; set; }

public UserPasswordConfigurationSettings? UserPassword { get; set; }
public IndexCreatorSettings? Examine { get; set; }

public WebRoutingSettings? WebRouting { get; set; }
public KeepAliveSettings? KeepAlive { get; set; }

public UmbracoPluginSettings? Plugins { get; set; }
public LoggingSettings? Logging { get; set; }

public UnattendedSettings? Unattended { get; set; }
public MemberPasswordConfigurationSettings? MemberPassword { get; set; }

public RichTextEditorSettings? RichTextEditor { get; set; }
public NuCacheSettings? NuCache { get; set; }

public RuntimeMinificationSettings? RuntimeMinification { get; set; }
public RequestHandlerSettings? RequestHandler { get; set; }

public BasicAuthSettings? BasicAuth { get; set; }
public RuntimeSettings? Runtime { get; set; }

public PackageMigrationSettings? PackageMigration { get; set; }
public SecuritySettings? Security { get; set; }

public LegacyPasswordMigrationSettings? LegacyPasswordMigration { get; set; }
public TourSettings? Tours { get; set; }

public ContentDashboardSettings? ContentDashboard { get; set; }
public TypeFinderSettings? TypeFinder { get; set; }

public HelpPageSettings? HelpPage { get; set; }
public UserPasswordConfigurationSettings? UserPassword { get; set; }

public InstallDefaultDataSettings? DefaultDataCreation { get; set; }
public WebRoutingSettings? WebRouting { get; set; }

public DataTypesSettings? DataTypes { get; set; }
}
public UmbracoPluginSettings? Plugins { get; set; }

/// <summary>
/// Configurations for the Umbraco Forms package to Umbraco CMS
/// </summary>
public class FormsDefinition
{
public FormDesignSettings? FormDesign { get; set; }
public UnattendedSettings? Unattended { get; set; }

public PackageOptionSettings? Options { get; set; }
public RichTextEditorSettings? RichTextEditor { get; set; }

public Umbraco.Forms.Core.Configuration.SecuritySettings? Security { get; set; }
public RuntimeMinificationSettings? RuntimeMinification { get; set; }

public FieldTypesDefinition? FieldTypes { get; set; }
public BasicAuthSettings? BasicAuth { get; set; }

/// <summary>
/// Configurations for the Umbraco Forms Field Types
/// </summary>
public class FieldTypesDefinition
{
public DatePickerSettings? DatePicker { get; set; }
public PackageMigrationSettings? PackageMigration { get; set; }

public Recaptcha2Settings? Recaptcha2 { get; set; }
public LegacyPasswordMigrationSettings? LegacyPasswordMigration { get; set; }

public Recaptcha3Settings? Recaptcha3 { get; set; }
}
}
public ContentDashboardSettings? ContentDashboard { get; set; }

/// <summary>
/// Configurations for the Umbraco Deploy package to Umbraco CMS
/// </summary>
public class DeployDefinition
{
public DeploySettings? Settings { get; set; }
public HelpPageSettings? HelpPage { get; set; }

public DeployProjectConfig? Project { get; set; }
public InstallDefaultDataSettings? DefaultDataCreation { get; set; }

public DebugSettings? Debug { get; set; }
}
}
public DataTypesSettings? DataTypes { get; set; }
}
}
9 changes: 5 additions & 4 deletions src/JsonSchema/JsonSchema.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="NJsonSchema" Version="10.7.2" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
<PackageReference Include="Umbraco.Deploy.Core" Version="9.3.1" />
<PackageReference Include="Umbraco.Forms.Core" Version="10.0.0-rc1" />
<PackageReference Include="Umbraco.Deploy.Core" Version="9.4.0" />
<PackageReference Include="Umbraco.Forms.Core" Version="9.4.0" />
<PackageReference Update="Nerdbank.GitVersioning">
<Version>3.5.107</Version>
</PackageReference>
Expand All @@ -24,6 +20,11 @@
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
</ItemGroup>

<ItemGroup>
<None Remove="appsettings-schema.json" />
<EmbeddedResource Include="appsettings-schema.json" />
</ItemGroup>

<!-- Copy Forms XML docs-->
<PropertyGroup>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
Expand Down
7 changes: 5 additions & 2 deletions src/JsonSchema/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ namespace JsonSchema
{
internal class Options
{
[Option('o', "outputFile", Required = false, HelpText = "Set path of the output file.", Default = "../../../../Umbraco.Web.UI/appsettings-schema.json")]
public string OutputFile { get; set; } = null!;
[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!;
}
}
20 changes: 14 additions & 6 deletions src/JsonSchema/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ await Parser.Default.ParseArguments<Options>(args)
private static async Task Execute(Options options)
{
var generator = new UmbracoJsonSchemaGenerator();
var schema = await generator.Generate();

var path = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, options.OutputFile));
Console.WriteLine("Path to use {0}", path);
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
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(path, schema);
await File.WriteAllTextAsync(mainPath, schema);

Console.WriteLine("File written at {0}", path);
Console.WriteLine("File written at {0}", mainPath);
}
}
}
91 changes: 56 additions & 35 deletions src/JsonSchema/UmbracoJsonSchemaGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,56 +1,77 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.

using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.FileProviders;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NJsonSchema.Generation;

namespace JsonSchema
namespace JsonSchema;

/// <summary>
/// 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;

/// <summary>
/// Generator of the JsonSchema for AppSettings.json including A specific Umbraco version.
/// Initializes a new instance of the <see cref="UmbracoJsonSchemaGenerator" /> class.
/// </summary>
public class UmbracoJsonSchemaGenerator
public UmbracoJsonSchemaGenerator()
=> _innerGenerator = new JsonSchemaGenerator(new UmbracoJsonSchemaGeneratorSettings());

/// <summary>
/// Generates a json representing the JsonSchema for AppSettings.json including A specific Umbraco version..
/// </summary>
public async Task<string> GenerateMainFile()
{
private static readonly HttpClient s_client = new ();
private readonly JsonSchemaGenerator _innerGenerator;

/// <summary>
/// Initializes a new instance of the <see cref="UmbracoJsonSchemaGenerator" /> class.
/// </summary>
public UmbracoJsonSchemaGenerator()
=> _innerGenerator = new JsonSchemaGenerator(new UmbracoJsonSchemaGeneratorSettings());

/// <summary>
/// Generates a json representing the JsonSchema for AppSettings.json including A specific Umbraco version..
/// </summary>
public async Task<string> Generate()
{
JObject umbracoSchema = GenerateUmbracoSchema();
JObject officialSchema = await GetOfficialAppSettingsSchema();
JObject officialSchema = await GetOfficialAppSettingsSchema();
JObject externalFilePoints = GenerateSchemaWithExternalDefinitions();

officialSchema.Merge(umbracoSchema);
officialSchema.Merge(externalFilePoints);

return officialSchema.ToString();
}
return officialSchema.ToString();
}

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

var result = await response.Content.ReadAsStringAsync();
public Task<string> GenerateCmsFile()
{
JObject cmsSchema = GenerateUmbracoSchema();

return Task.FromResult(cmsSchema.ToString());
}

return JsonConvert.DeserializeObject<JObject>(result)!;
}

private JObject GenerateUmbracoSchema()
{
NJsonSchema.JsonSchema schema = _innerGenerator.Generate(typeof(AppSettings));

return JsonConvert.DeserializeObject<JObject>(schema.ToJson())!;
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<JObject>(reader.ReadToEnd())!;
}
}

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

var result = await response.Content.ReadAsStringAsync();

return JsonConvert.DeserializeObject<JObject>(result)!;
}

private JObject GenerateUmbracoSchema()
{
NJsonSchema.JsonSchema schema = _innerGenerator.Generate(typeof(AppSettings));

return JsonConvert.DeserializeObject<JObject>(schema.ToJson())!;
}
}
Loading