NJsonSchema.Extensions 0.2.0

dotnet add package NJsonSchema.Extensions --version 0.2.0
                    
NuGet\Install-Package NJsonSchema.Extensions -Version 0.2.0
                    
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="NJsonSchema.Extensions" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NJsonSchema.Extensions" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="NJsonSchema.Extensions" />
                    
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 NJsonSchema.Extensions --version 0.2.0
                    
#r "nuget: NJsonSchema.Extensions, 0.2.0"
                    
#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.
#addin nuget:?package=NJsonSchema.Extensions&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=NJsonSchema.Extensions&version=0.2.0
                    
Install as a Cake Tool

NJsonSchema.Extensions

Some extension methods for NJsonSchema.

ToJsonSchema

Convert a JObject to a NSwag JsonSchema
JObject
var instance = new JObject
{
    {"Uri", new JValue(new Uri("http://localhost:80/abc?a=5"))},
    {"Null", new JValue((object?) null)},
    {"Guid", new JValue(_guid)},
    {"Float", new JValue(10.0f)},
    {"Double", new JValue(Math.PI)},
    {"Check", new JValue(true)},
    {
        "Child", new JObject
        {
            {"ChildInteger", new JValue(4)},
            {"ChildDateTime", new JValue(new DateTime(2018, 2, 17))},
            {"ChildTimeSpan", new JValue(TimeSpan.FromMilliseconds(999))}
        }
    },
    {"Integer", new JValue(9)},
    {"Long", new JValue(long.MaxValue)},
    {"String", new JValue("Test")},
    {"Char", new JValue('c')},
    {"Bytes", new JValue(_bytes)},
    {"Array", new JArray("a1")}
};
Call ToJsonSchema
var schema = instance.ToJsonSchema().ToJson(Formatting.Indented).Replace("  ", "    ");
Generated Swagger Schema
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "Uri": {
            "type": "string",
            "format": "uri"
        },
        "Null": {
            "type": "null"
        },
        "Guid": {
            "type": "string",
            "format": "guid"
        },
        "Float": {
            "type": "number",
            "format": "float"
        },
        "Double": {
            "type": "number",
            "format": "double"
        },
        "Check": {
            "type": "boolean"
        },
        "Child": {
            "type": "object",
            "properties": {
                "ChildInteger": {
                    "type": "integer",
                    "format": "int32"
                },
                "ChildDateTime": {
                    "type": "string",
                    "format": "date-time"
                },
                "ChildTimeSpan": {
                    "type": "string",
                    "format": "time-span"
                }
            }
        },
        "Integer": {
            "type": "integer",
            "format": "int32"
        },
        "Long": {
            "type": "integer",
            "format": "int64"
        },
        "String": {
            "type": "string"
        },
        "Char": {
            "type": "string"
        },
        "Bytes": {
            "type": "string",
            "format": "byte"
        },
        "Array": {
            "type": "array",
            "items": {
                "type": "string"
            }
        }
    }
}

Convert an Jarray to a NSwag JsonSchema
Object
var instance = new JArray("a1", "a2");
Call ToJsonSchema
var schema = instance.ToJsonSchema().ToJson(Formatting.Indented).Replace("  ", "    ");
Generated Swagger Schema
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "array",
    "items": {
        "type": "string"
    }
}

Convert a object to a NSwag JsonSchema
object
var instance = new
{
    Uri = new Uri("http://localhost:80/abc?a=5"),
    Null = (object?)null,
    Guid = _guid,
    Float = 10.0f,
    Double = Math.E,
    Check = true,
    Child = new
    {
        ChildInteger = 4,
        ChildDateTime = new DateTime(2018, 2, 17),
        ChildTimeSpan = TimeSpan.FromMilliseconds(999)
    },
    Integer = 9,
    Long = long.MaxValue,
    String = "test",
    Char = 'c',
    Bytes = _bytes,
    Array = new[] { "a1" },
    ListT = new List<int> { 1 },
    IList = (IList)new List<int> { 1 },
    IEnumerableT = (IEnumerable<string>)new[] { "s" },
    IEnumerable = (IEnumerable)new[] { "s" }
};
Call ToJsonSchema
var schema = instance.ToJsonSchema().ToJson(Formatting.Indented).Replace("  ", "    ");
Generated Swagger Schema
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "Uri": {
            "type": "string",
            "format": "uri"
        },
        "Null": {
            "type": "null"
        },
        "Guid": {
            "type": "string",
            "format": "guid"
        },
        "Float": {
            "type": "number",
            "format": "float"
        },
        "Double": {
            "type": "number",
            "format": "double"
        },
        "Check": {
            "type": "boolean"
        },
        "Child": {
            "type": "object",
            "properties": {
                "ChildInteger": {
                    "type": "integer",
                    "format": "int32"
                },
                "ChildDateTime": {
                    "type": "string",
                    "format": "date-time"
                },
                "ChildTimeSpan": {
                    "type": "string",
                    "format": "time-span"
                }
            }
        },
        "Integer": {
            "type": "integer",
            "format": "int32"
        },
        "Long": {
            "type": "integer",
            "format": "int64"
        },
        "String": {
            "type": "string"
        },
        "Char": {
            "type": "object"
        },
        "Bytes": {
            "type": "array",
            "items": {
                "type": "string",
                "format": "byte"
            }
        },
        "Array": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "ListT": {
            "type": "array",
            "items": [
                {
                    "type": "integer",
                    "format": "int32"
                }
            ]
        },
        "IList": {
            "type": "array",
            "items": [
                {
                    "type": "integer",
                    "format": "int32"
                }
            ]
        },
        "IEnumerableT": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "IEnumerable": {
            "type": "array",
            "items": {
                "type": "string"
            }
        }
    }
}

Sponsors

Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of NJsonSchema.Extensions.

Entity Framework Extensions

Dapper Plus

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NJsonSchema.Extensions:

Package Downloads
WireMock.Net.Minimal

Minimal version from the lightweight Http Mocking Server for .NET

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on NJsonSchema.Extensions:

Repository Stars
chocolatey/choco
Chocolatey - the package manager for Windows
wiremock/WireMock.Net
WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Version Downloads Last Updated
0.2.0 191 6/18/2025
0.1.0 16,422,154 5/13/2022
0.0.1 638 5/6/2022

# 0.2.0 (18 June 2025)
- #2 Upgrade some packages [enhancement]

The full release notes can be found here: https://github.com/StefH/NJsonSchema.Extensions/blob/main/ReleaseNotes.md