Description
This schema:
`
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "Container",
"properties": {
"Animal": {
"oneOf": [
{
"$ref": "#/definitions/Dog"
},
{
"$ref": "#/definitions/Cat"
}
]
}
},
"definitions": {
"Dog":{
"type": "object",
"properties": {
"dogname":{
"type": "string"
}
}
},
"Cat":{
"type": "object",
"properties": {
"catname":{
"type": "number"
}
}
}
}
}
`
generates only one class: Dog. Is it a bug or feature? I am expecting to see two classes generated Dog and Cat represented via another class Animal. How can I get it?
`
//
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var coordinate = Coordinate.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class Coordinate
{
[JsonProperty("Animal", NullValueHandling = NullValueHandling.Ignore)]
public Dog Animal { get; set; }
}
public partial class Dog
{
[JsonProperty("dogname", NullValueHandling = NullValueHandling.Ignore)]
public string Dogname { get; set; }
[JsonProperty("catname", NullValueHandling = NullValueHandling.Ignore)]
public double? Catname { get; set; }
}
public partial class Coordinate
{
public static Coordinate FromJson(string json) => JsonConvert.DeserializeObject<Coordinate>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this Coordinate self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}
`