SharpSchema 1.3.21-beta
This is a prerelease version of SharpSchema.
dotnet add package SharpSchema --version 1.3.21-beta
NuGet\Install-Package SharpSchema -Version 1.3.21-beta
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharpSchema" Version="1.3.21-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpSchema" Version="1.3.21-beta" />Directory.Packages.props
<PackageReference Include="SharpSchema" />Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpSchema --version 1.3.21-beta
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SharpSchema, 1.3.21-beta"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SharpSchema@1.3.21-beta
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SharpSchema&version=1.3.21-beta&prereleaseInstall as a Cake Addin
#tool nuget:?package=SharpSchema&version=1.3.21-beta&prereleaseInstall as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SharpSchema
SharpSchema is a very opiniated tool for transforming C# class hierarchies into JSON schema.
It is designed to work with your System.Text.Json deserialization library. SchemaSharp.Annotations provides
attributes you can apply to your DTOs to express JSON-Schema validation constraints that aren't possible
to express with pure C#.
Examples
SimplePerson
namespace SharpSchema.Tests;
public record SimplePerson(
string Surname,
string? FamilyName,
DateTime DateOfBirth,
SimplePerson.RoleKind Role)
{
public enum RoleKind
{
User,
SectionAdmin,
SystemAdmin,
}
[SchemaIgnore]
public int Age => (int)((DateTime.Now - this.DateOfBirth).TotalDays / 365.25);
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"surname": {
"$comment": "string",
"type": "string",
"title": "Surname"
},
"familyName": {
"oneOf": [
{
"$comment": "string",
"type": "string"
},
{
"type": "null"
}
],
"title": "Family Name"
},
"dateOfBirth": {
"$comment": "DateTime",
"type": "string",
"format": "date-time",
"title": "Date of Birth"
},
"role": {
"$comment": "RoleKind",
"type": "string",
"enum": [
"user",
"section-admin",
"system-admin"
],
"title": "Role"
}
},
"required": [
"surname",
"dateOfBirth",
"role"
],
"additionalProperties": false
}
$schemaCurrently, only draft-07 is supported.
propertiesEach property name is camel-cased by default.
surname$commentBy default, the comment is the .NET type name.
titleBy default, the title is the property name converted to title case.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- JsonSchema.Net (>= 7.3.1)
- libanvl.opt (>= 2.7.7-beta)
- Microsoft.VisualStudio.Validation (>= 17.8.8)
- SharpMeta (>= 2.2.13-beta)
- SharpSchema.Annotations (>= 1.3.21-beta)
- System.Reflection.MetadataLoadContext (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.21-beta | 128 | 1/16/2025 |
| 1.2.9-beta | 120 | 1/7/2025 |
| 1.2.1-alpha | 133 | 1/6/2025 |
| 0.3.33-rc | 131 | 11/10/2024 |
| 0.3.32-rc | 112 | 11/3/2024 |
| 0.2.6-rc | 134 | 5/29/2024 |
| 0.1.602-rc | 129 | 5/28/2024 |