{
"definitions": {
"Student": {
"description": "A simple student struct",
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
},
"root": "Student"
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
/// <summary>
/// A simple student struct
/// </summary>
public class Student
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
}
{
"definitions": {
"Human": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Student": {
"parent": {
"type": "reference",
"target": "Human"
},
"type": "struct",
"properties": {
"studentId": {
"type": "string"
}
}
}
},
"root": "Student"
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Human
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Student : Human
{
[JsonPropertyName("studentId")]
public string? StudentId { get; set; }
}
{
"definitions": {
"Student": {
"description": "A student struct with an assigned faculty",
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"faculty": {
"type": "reference",
"target": "Faculty"
}
}
},
"Faculty": {
"type": "struct",
"properties": {
"name": {
"type": "string"
}
}
}
},
"root": "Student"
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
/// <summary>
/// A student struct with an assigned faculty
/// </summary>
public class Student
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
[JsonPropertyName("faculty")]
public Faculty? Faculty { get; set; }
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Faculty
{
[JsonPropertyName("name")]
public string? Name { get; set; }
}
{
"definitions": {
"Student": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"type": "map",
"schema": {
"type": "string"
}
}
}
}
},
"root": "Student"
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Student
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
[JsonPropertyName("properties")]
public System.Collections.Generic.Dictionary<string, string>? Properties { get; set; }
}
{
"definitions": {
"Human": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"location": {
"type": "reference",
"target": "Location"
}
}
},
"Location": {
"type": "struct",
"base": true,
"properties": {
"type": {
"type": "string"
}
},
"discriminator": "type",
"mapping": {
"Web": "web",
"World": "world"
}
},
"Web": {
"parent": {
"type": "reference",
"target": "Location"
},
"type": "struct",
"properties": {
"url": {
"type": "string"
}
}
},
"World": {
"parent": {
"type": "reference",
"target": "Location"
},
"type": "struct",
"properties": {
"lat": {
"type": "string"
},
"long": {
"type": "string"
}
}
}
},
"root": "Human"
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Human
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("location")]
public Location? Location { get; set; }
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(Web), typeDiscriminator: "web")]
[JsonDerivedType(typeof(World), typeDiscriminator: "world")]
public abstract class Location
{
[JsonPropertyName("type")]
public string? Type { get; set; }
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Web : Location
{
[JsonPropertyName("url")]
public string? Url { get; set; }
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class World : Location
{
[JsonPropertyName("lat")]
public string? Lat { get; set; }
[JsonPropertyName("long")]
public string? Long { get; set; }
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"type": "struct",
"parent": {
"type": "reference",
"target": "Map",
"template": {
"T": "Student"
}
}
},
"Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"schema": {
"type": "generic",
"name": "T"
}
}
}
}
},
"root": "StudentMap"
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Student
{
[JsonPropertyName("matricleNumber")]
public int? MatricleNumber { get; set; }
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Map<T>
{
[JsonPropertyName("totalResults")]
public int? TotalResults { get; set; }
[JsonPropertyName("entries")]
public System.Collections.Generic.List<T>? Entries { get; set; }
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class StudentMap : Map<Student>
{
}
{
"import": {
"my_ns": "file:///generic.json"
},
"definitions": {
"Faculty": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"schema": {
"type": "reference",
"target": "my_ns:StudentMap"
}
}
}
}
},
"root": "Faculty"
}
using System.Text.Json.Serialization;
namespace TypeSchema.DTO;
public class Faculty
{
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("students")]
public System.Collections.Generic.List<StudentMap>? Students { get; set; }
}