Create umbraco-jsonschema
.NET tool to generate JSON schemas
#13560
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
This converts the
Umbraco.JsonSchema
console application into a .NET tool to generate JSON schemas from a specific type in an assembly file.Although the CMS still directly invokes the console application to generate the JSON schema for the CMS (at least for now), it now does so in the same way as invoking it as a .NET tool.
To this this, first check whether the
Umbraco.Cms.Targets
NuGet package still includes the generatedappsettings-schema.Umbraco.Cms.json
file (both on a local build and in the Azure Pipeline build artifacts). Next, create a local build, install the tool and generate the JSON schema using:After validating whether the generated JSON schema is correct, you can uninstall this global tool using
dotnet tool uninstall Umbraco.JsonSchema --global
.We might want to move this into a separate repository, since we don't need new releases with every CMS version and the CMS can then also use the tool. Either way, once this tool is published on NuGet, this can be used as a local tool by other packages:
You can then create the C# class to generate the JSON schema from (e.g.
Umbraco.Forms.UmbracoFormsSchema
) and add this to the same project file to automatically generate it on build and include it as part of the NuGet package (this generated JSON schema file can be added to.gitignore
):The following build property file (e.g.
buildTransitive\Umbraco.Forms.props
) ensures the JSON schema that's included in the NuGet package gets automatically copied into the Umbraco project directory and added as a reference in theappsettings-schema.json
file: