Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
5test cases
100files differ
73modified
27new
0deleted
2,245changed lines
+2,231 −14insertions / deletions
Base a49b94e8f6f1b319a4da9fb15d57ef13ba316ddc · PR merge 6d5f0f62a95913489d5b7481370b73674ac1061a · Head cf2a19487bcf7a7195359ff90ea31e8ef1041ae5 · raw patch
Test case

test/inputs/schema/description-ref.schema

27 generated files · +2,019 −0
Aschema-cplusplusdefault / quicktype.hpp+74 −0
@@ -0,0 +1,74 @@
1+// To parse this JSON data, first install
2+//
3+// json.hpp https://github.com/nlohmann/json
4+//
5+// Then include this file, and then do
6+//
7+// TopLevel data = nlohmann::json::parse(jsonString);
8+
9+#pragma once
10+
11+#include "json.hpp"
12+
13+#include <optional>
14+#include <stdexcept>
15+#include <regex>
16+
17+namespace quicktype {
18+ using nlohmann::json;
19+
20+ #ifndef NLOHMANN_UNTYPED_quicktype_HELPER
21+ #define NLOHMANN_UNTYPED_quicktype_HELPER
22+ inline json get_untyped(const json & j, const char * property) {
23+ if (j.find(property) != j.end()) {
24+ return j.at(property).get<json>();
25+ }
26+ return json();
27+ }
28+
29+ inline json get_untyped(const json & j, std::string property) {
30+ return get_untyped(j, property.data());
31+ }
32+ #endif
33+
34+ class TopLevel {
35+ public:
36+ TopLevel() = default;
37+ virtual ~TopLevel() = default;
38+
39+ private:
40+ std::string name;
41+ std::string surname;
42+
43+ public:
44+ /**
45+ * name description
46+ */
47+ const std::string & get_name() const { return name; }
48+ std::string & get_mutable_name() { return name; }
49+ void set_name(const std::string & value) { this->name = value; }
50+
51+ /**
52+ * surname description
53+ */
54+ const std::string & get_surname() const { return surname; }
55+ std::string & get_mutable_surname() { return surname; }
56+ void set_surname(const std::string & value) { this->surname = value; }
57+ };
58+}
59+
60+namespace quicktype {
61+ void from_json(const json & j, TopLevel & x);
62+ void to_json(json & j, const TopLevel & x);
63+
64+ inline void from_json(const json & j, TopLevel& x) {
65+ x.set_name(j.at("name").get<std::string>());
66+ x.set_surname(j.at("surname").get<std::string>());
67+ }
68+
69+ inline void to_json(json & j, const TopLevel & x) {
70+ j = json::object();
71+ j["name"] = x.get_name();
72+ j["surname"] = x.get_surname();
73+ }
74+}
Aschema-csharp-recordsdefault / QuickType.cs+70 −0
@@ -0,0 +1,70 @@
1+// <auto-generated />
2+//
3+// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
4+//
5+// using QuickType;
6+//
7+// var topLevel = TopLevel.FromJson(jsonString);
8+#nullable enable
9+#pragma warning disable CS8618
10+#pragma warning disable CS8601
11+#pragma warning disable CS8602
12+#pragma warning disable CS8603
13+#pragma warning disable CS8604
14+#pragma warning disable CS8625
15+#pragma warning disable CS8765
16+
17+namespace QuickType
18+{
19+ using System;
20+ using System.Collections.Generic;
21+
22+ using System.Globalization;
23+ using Newtonsoft.Json;
24+ using Newtonsoft.Json.Converters;
25+
26+ public partial record TopLevel
27+ {
28+ /// <summary>
29+ /// name description
30+ /// </summary>
31+ [JsonProperty("name", Required = Required.Always)]
32+ public string Name { get; set; }
33+
34+ /// <summary>
35+ /// surname description
36+ /// </summary>
37+ [JsonProperty("surname", Required = Required.Always)]
38+ public string Surname { get; set; }
39+ }
40+
41+ public partial record TopLevel
42+ {
43+ public static TopLevel FromJson(string json) => JsonConvert.DeserializeObject<TopLevel>(json, QuickType.Converter.Settings);
44+ }
45+
46+ public static partial class Serialize
47+ {
48+ public static string ToJson(this TopLevel self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
49+ }
50+
51+ internal static partial class Converter
52+ {
53+ public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
54+ {
55+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
56+ DateParseHandling = DateParseHandling.None,
57+ Converters =
58+ {
59+ new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
60+ },
61+ };
62+ }
63+}
64+#pragma warning restore CS8618
65+#pragma warning restore CS8601
66+#pragma warning restore CS8602
67+#pragma warning restore CS8603
68+#pragma warning restore CS8604
69+#pragma warning restore CS8625
70+#pragma warning restore CS8765
Aschema-csharp-SystemTextJsondefault / QuickType.cs+176 −0
@@ -0,0 +1,176 @@
1+// <auto-generated />
2+//
3+// To parse this JSON data, add NuGet 'System.Text.Json' then do:
4+//
5+// using QuickType;
6+//
7+// var topLevel = TopLevel.FromJson(jsonString);
8+#nullable enable
9+#pragma warning disable CS8618
10+#pragma warning disable CS8601
11+#pragma warning disable CS8602
12+#pragma warning disable CS8603
13+
14+namespace QuickType
15+{
16+ using System;
17+ using System.Collections.Generic;
18+
19+ using System.Text.Json;
20+ using System.Text.Json.Serialization;
21+ using System.Globalization;
22+
23+ public partial class TopLevel
24+ {
25+ /// <summary>
26+ /// name description
27+ /// </summary>
28+ [JsonRequired]
29+ [JsonPropertyName("name")]
30+ public string Name { get; set; }
31+
32+ /// <summary>
33+ /// surname description
34+ /// </summary>
35+ [JsonRequired]
36+ [JsonPropertyName("surname")]
37+ public string Surname { get; set; }
38+ }
39+
40+ public partial class TopLevel
41+ {
42+ public static TopLevel FromJson(string json) => JsonSerializer.Deserialize<TopLevel>(json, QuickType.Converter.Settings);
43+ }
44+
45+ public static partial class Serialize
46+ {
47+ public static string ToJson(this TopLevel self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
48+ }
49+
50+ internal static partial class Converter
51+ {
52+ public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
53+ {
54+ Converters =
55+ {
56+ new DateOnlyConverter(),
57+ new TimeOnlyConverter(),
58+ IsoDateTimeOffsetConverter.Singleton
59+ },
60+ };
61+ }
62+
63+ public class DateOnlyConverter : JsonConverter<DateOnly>
64+ {
65+ private readonly string serializationFormat;
66+ public DateOnlyConverter() : this(null) { }
67+
68+ public DateOnlyConverter(string? serializationFormat)
69+ {
70+ this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
71+ }
72+
73+ public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
74+ {
75+ var value = reader.GetString();
76+ return DateOnly.Parse(value!);
77+ }
78+
79+ public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
80+ => writer.WriteStringValue(value.ToString(serializationFormat));
81+ }
82+
83+ public class TimeOnlyConverter : JsonConverter<TimeOnly>
84+ {
85+ private readonly string serializationFormat;
86+
87+ public TimeOnlyConverter() : this(null) { }
88+
89+ public TimeOnlyConverter(string? serializationFormat)
90+ {
91+ this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
92+ }
93+
94+ public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
95+ {
96+ var value = reader.GetString();
97+ return TimeOnly.Parse(value!);
98+ }
99+
100+ public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
101+ => writer.WriteStringValue(value.ToString(serializationFormat));
102+ }
103+
104+ internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
105+ {
106+ public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
107+
108+ private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
109+
110+ private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
111+ private string? _dateTimeFormat;
112+ private CultureInfo? _culture;
113+
114+ public DateTimeStyles DateTimeStyles
115+ {
116+ get => _dateTimeStyles;
117+ set => _dateTimeStyles = value;
118+ }
119+
120+ public string? DateTimeFormat
121+ {
122+ get => _dateTimeFormat ?? string.Empty;
123+ set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
124+ }
125+
126+ public CultureInfo Culture
127+ {
128+ get => _culture ?? CultureInfo.CurrentCulture;
129+ set => _culture = value;
130+ }
131+
132+ public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
133+ {
134+ string text;
135+
136+
137+ if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
138+ || (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
139+ {
140+ value = value.ToUniversalTime();
141+ }
142+
143+ text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
144+
145+ writer.WriteStringValue(text);
146+ }
147+
148+ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
149+ {
150+ string? dateText = reader.GetString();
151+
152+ if (string.IsNullOrEmpty(dateText) == false)
153+ {
154+ if (!string.IsNullOrEmpty(_dateTimeFormat))
155+ {
156+ return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
157+ }
158+ else
159+ {
160+ return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
161+ }
162+ }
163+ else
164+ {
165+ return default(DateTimeOffset);
166+ }
167+ }
168+
169+
170+ public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
171+ }
172+}
173+#pragma warning restore CS8618
174+#pragma warning restore CS8601
175+#pragma warning restore CS8602
176+#pragma warning restore CS8603
Aschema-csharpdefault / QuickType.cs+70 −0
@@ -0,0 +1,70 @@
1+// <auto-generated />
2+//
3+// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
4+//
5+// using QuickType;
6+//
7+// var topLevel = TopLevel.FromJson(jsonString);
8+#nullable enable
9+#pragma warning disable CS8618
10+#pragma warning disable CS8601
11+#pragma warning disable CS8602
12+#pragma warning disable CS8603
13+#pragma warning disable CS8604
14+#pragma warning disable CS8625
15+#pragma warning disable CS8765
16+
17+namespace QuickType
18+{
19+ using System;
20+ using System.Collections.Generic;
21+
22+ using System.Globalization;
23+ using Newtonsoft.Json;
24+ using Newtonsoft.Json.Converters;
25+
26+ public partial class TopLevel
27+ {
28+ /// <summary>
29+ /// name description
30+ /// </summary>
31+ [JsonProperty("name", Required = Required.Always)]
32+ public string Name { get; set; }
33+
34+ /// <summary>
35+ /// surname description
36+ /// </summary>
37+ [JsonProperty("surname", Required = Required.Always)]
38+ public string Surname { get; set; }
39+ }
40+
41+ public partial class TopLevel
42+ {
43+ public static TopLevel FromJson(string json) => JsonConvert.DeserializeObject<TopLevel>(json, QuickType.Converter.Settings);
44+ }
45+
46+ public static partial class Serialize
47+ {
48+ public static string ToJson(this TopLevel self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
49+ }
50+
51+ internal static partial class Converter
52+ {
53+ public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
54+ {
55+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
56+ DateParseHandling = DateParseHandling.None,
57+ Converters =
58+ {
59+ new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
60+ },
61+ };
62+ }
63+}
64+#pragma warning restore CS8618
65+#pragma warning restore CS8601
66+#pragma warning restore CS8602
67+#pragma warning restore CS8603
68+#pragma warning restore CS8604
69+#pragma warning restore CS8625
70+#pragma warning restore CS8765
Aschema-dartdefault / TopLevel.dart+33 −0
@@ -0,0 +1,33 @@
1+// To parse this JSON data, do
2+//
3+// final topLevel = topLevelFromJson(jsonString);
4+
5+import 'dart:convert';
6+
7+TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
8+
9+String topLevelToJson(TopLevel data) => json.encode(data.toJson());
10+
11+class TopLevel {
12+
13+ ///name description
14+ final String name;
15+
16+ ///surname description
17+ final String surname;
18+
19+ TopLevel({
20+ required this.name,
21+ required this.surname,
22+ });
23+
24+ factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
25+ name: json["name"],
26+ surname: json["surname"],
27+ );
28+
29+ Map<String, dynamic> toJson() => {
30+ "name": name,
31+ "surname": surname,
32+ };
33+}
Aschema-elmdefault / QuickType.elm+60 −0
@@ -0,0 +1,60 @@
1+-- To decode the JSON data, add this file to your project, run
2+--
3+-- elm install NoRedInk/elm-json-decode-pipeline
4+--
5+-- add these imports
6+--
7+-- import Json.Decode exposing (decodeString)
8+-- import QuickType exposing (quickType)
9+--
10+-- and you're off to the races with
11+--
12+-- decodeString quickType myJsonString
13+
14+module QuickType exposing
15+ ( QuickType
16+ , quickTypeToString
17+ , quickType
18+ )
19+
20+import Json.Decode as Jdec
21+import Json.Decode.Pipeline as Jpipe
22+import Json.Encode as Jenc
23+import Dict exposing (Dict)
24+
25+{-| name:
26+name description
27+
28+surname:
29+surname description
30+-}
31+type alias QuickType =
32+ { name : String
33+ , surname : String
34+ }
35+
36+-- decoders and encoders
37+
38+quickTypeToString : QuickType -> String
39+quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
40+
41+quickType : Jdec.Decoder QuickType
42+quickType =
43+ Jdec.succeed QuickType
44+ |> Jpipe.required "name" Jdec.string
45+ |> Jpipe.required "surname" Jdec.string
46+
47+encodeQuickType : QuickType -> Jenc.Value
48+encodeQuickType x =
49+ Jenc.object
50+ [ ("name", Jenc.string x.name)
51+ , ("surname", Jenc.string x.surname)
52+ ]
53+
54+--- encoder helpers
55+
56+makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
57+makeNullableEncoder f m =
58+ case m of
59+ Just x -> f x
60+ Nothing -> Jenc.null
Aschema-flowdefault / TopLevel.js+197 −0
@@ -0,0 +1,197 @@
1+// @flow
2+
3+// To parse this data:
4+//
5+// const Convert = require("./TopLevel");
6+//
7+// const topLevel = Convert.toTopLevel(json);
8+//
9+// These functions will throw an error if the JSON doesn't
10+// match the expected interface, even if the JSON is valid.
11+
12+export type TopLevel = {
13+ /**
14+ * name description
15+ */
16+ name: string;
17+ /**
18+ * surname description
19+ */
20+ surname: string;
21+ [property: string]: mixed;
22+};
23+
24+// Converts JSON strings to/from your types
25+// and asserts the results of JSON.parse at runtime
26+function toTopLevel(json: string): TopLevel {
27+ return cast(JSON.parse(json), r("TopLevel"));
28+}
29+
30+function topLevelToJson(value: TopLevel): string {
31+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
32+}
33+
34+function invalidValue(typ: any, val: any, key: any, parent: any = '') {
35+ const prettyTyp = prettyTypeName(typ);
36+ const parentText = parent ? ` on ${parent}` : '';
37+ const keyText = key ? ` for key "${key}"` : '';
38+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
39+}
40+
41+function prettyTypeName(typ: any): string {
42+ if (Array.isArray(typ)) {
43+ if (typ.length === 2 && typ[0] === undefined) {
44+ return `an optional ${prettyTypeName(typ[1])}`;
45+ } else {
46+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
47+ }
48+ } else if (typeof typ === "object" && typ.literal !== undefined) {
49+ return typ.literal;
50+ } else {
51+ return typeof typ;
52+ }
53+}
54+
55+function jsonToJSProps(typ: any): any {
56+ if (typ.jsonToJS === undefined) {
57+ const map: any = {};
58+ typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
59+ typ.jsonToJS = map;
60+ }
61+ return typ.jsonToJS;
62+}
63+
64+function jsToJSONProps(typ: any): any {
65+ if (typ.jsToJSON === undefined) {
66+ const map: any = {};
67+ typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
68+ typ.jsToJSON = map;
69+ }
70+ return typ.jsToJSON;
71+}
72+
73+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
74+ function transformPrimitive(typ: string, val: any): any {
75+ if (typeof typ === typeof val) return val;
76+ return invalidValue(typ, val, key, parent);
77+ }
78+
79+ function transformUnion(typs: any[], val: any): any {
80+ // val must validate against one typ in typs
81+ const l = typs.length;
82+ for (let i = 0; i < l; i++) {
83+ const typ = typs[i];
84+ try {
85+ return transform(val, typ, getProps);
86+ } catch (_) {}
87+ }
88+ return invalidValue(typs, val, key, parent);
89+ }
90+
91+ function transformEnum(cases: string[], val: any): any {
92+ if (cases.indexOf(val) !== -1) return val;
93+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
94+ }
95+
96+ function transformArray(typ: any, val: any): any {
97+ // val must be an array with no invalid elements
98+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
99+ return val.map(el => transform(el, typ, getProps));
100+ }
101+
102+ function transformDate(val: any): any {
103+ if (val === null) {
104+ return null;
105+ }
106+ const d = new Date(val);
107+ if (isNaN(d.valueOf())) {
108+ return invalidValue(l("Date"), val, key, parent);
109+ }
110+ return d;
111+ }
112+
113+ function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
114+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
115+ return invalidValue(l(ref || "object"), val, key, parent);
116+ }
117+ const result: any = {};
118+ Object.getOwnPropertyNames(props).forEach(key => {
119+ const prop = props[key];
120+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
121+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
122+ });
123+ Object.getOwnPropertyNames(val).forEach(key => {
124+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
125+ result[key] = transform(val[key], additional, getProps, key, ref);
126+ }
127+ });
128+ return result;
129+ }
130+
131+ if (typ === "any") return val;
132+ if (typ === null) {
133+ if (val === null) return val;
134+ return invalidValue(typ, val, key, parent);
135+ }
136+ if (typ === false) return invalidValue(typ, val, key, parent);
137+ let ref: any = undefined;
138+ while (typeof typ === "object" && typ.ref !== undefined) {
139+ ref = typ.ref;
140+ typ = typeMap[typ.ref];
141+ }
142+ if (Array.isArray(typ)) return transformEnum(typ, val);
143+ if (typeof typ === "object") {
144+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
145+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
146+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
147+ : invalidValue(typ, val, key, parent);
148+ }
149+ // Numbers can be parsed by Date but shouldn't be.
150+ if (typ === Date && typeof val !== "number") return transformDate(val);
151+ return transformPrimitive(typ, val);
152+}
153+
154+function cast<T>(val: any, typ: any): T {
155+ return transform(val, typ, jsonToJSProps);
156+}
157+
158+function uncast<T>(val: T, typ: any): any {
159+ return transform(val, typ, jsToJSONProps);
160+}
161+
162+function l(typ: any) {
163+ return { literal: typ };
164+}
165+
166+function a(typ: any) {
167+ return { arrayItems: typ };
168+}
169+
170+function u(...typs: any[]) {
171+ return { unionMembers: typs };
172+}
173+
174+function o(props: any[], additional: any) {
175+ return { props, additional };
176+}
177+
178+function m(additional: any) {
179+ const props: any[] = [];
180+ return { props, additional };
181+}
182+
183+function r(name: string) {
184+ return { ref: name };
185+}
186+
187+const typeMap: any = {
188+ "TopLevel": o([
189+ { json: "name", js: "name", typ: "" },
190+ { json: "surname", js: "surname", typ: "" },
191+ ], "any"),
192+};
193+
194+module.exports = {
195+ "topLevelToJson": topLevelToJson,
196+ "toTopLevel": toTopLevel,
197+};
Aschema-golangdefault / quicktype.go+26 −0
@@ -0,0 +1,26 @@
1+// Code generated from JSON Schema using quicktype. DO NOT EDIT.
2+// To parse and unparse this JSON data, add this code to your project and do:
3+//
4+// topLevel, err := UnmarshalTopLevel(bytes)
5+// bytes, err = topLevel.Marshal()
6+
7+package main
8+
9+import "encoding/json"
10+
11+func UnmarshalTopLevel(data []byte) (TopLevel, error) {
12+ var r TopLevel
13+ err := json.Unmarshal(data, &r)
14+ return r, err
15+}
16+
17+func (r *TopLevel) Marshal() ([]byte, error) {
18+ return json.Marshal(r)
19+}
20+
21+type TopLevel struct {
22+ // name description
23+ Name string `json:"name"`
24+ // surname description
25+ Surname string `json:"surname"`
26+}
Aschema-java-datetime-legacydefault / src / main / java / io / quicktype / Converter.java+121 −0
@@ -0,0 +1,121 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+//
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.util.Date;
24+import java.text.SimpleDateFormat;
25+
26+public class Converter {
27+ // Date-time helpers
28+
29+ private static final String[] DATE_TIME_FORMATS = {
30+ "yyyy-MM-dd'T'HH:mm:ss.SX",
31+ "yyyy-MM-dd'T'HH:mm:ss.S",
32+ "yyyy-MM-dd'T'HH:mm:ssX",
33+ "yyyy-MM-dd'T'HH:mm:ss",
34+ "yyyy-MM-dd HH:mm:ss.SX",
35+ "yyyy-MM-dd HH:mm:ss.S",
36+ "yyyy-MM-dd HH:mm:ssX",
37+ "yyyy-MM-dd HH:mm:ss",
38+ "HH:mm:ss.SZ",
39+ "HH:mm:ss.S",
40+ "HH:mm:ssZ",
41+ "HH:mm:ss",
42+ "yyyy-MM-dd",
43+ };
44+
45+ public static Date parseAllDateTimeString(String str) {
46+ for (String format : DATE_TIME_FORMATS) {
47+ try {
48+ return new SimpleDateFormat(format).parse(str);
49+ } catch (Exception ex) {
50+ // Ignored
51+ }
52+ }
53+ return null;
54+ }
55+
56+ public static String serializeDateTime(Date datetime) {
57+ return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ").format(datetime);
58+ }
59+
60+ public static String serializeDate(Date datetime) {
61+ return new SimpleDateFormat("yyyy-MM-dd").format(datetime);
62+ }
63+
64+ public static String serializeTime(Date datetime) {
65+ return new SimpleDateFormat("hh:mm:ssZ").format(datetime);
66+ }
67+ // Serialize/deserialize helpers
68+
69+ public static TopLevel fromJsonString(String json) throws IOException {
70+ return getObjectReader().readValue(json);
71+ }
72+
73+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
74+ return getObjectWriter().writeValueAsString(obj);
75+ }
76+
77+ private static ObjectReader reader;
78+ private static ObjectWriter writer;
79+
80+ private static void instantiateMapper() {
81+ ObjectMapper mapper = new ObjectMapper();
82+ mapper.findAndRegisterModules();
83+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
84+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
85+ SimpleModule module = new SimpleModule();
86+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
87+ @Override
88+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
89+ String value = jsonParser.getText();
90+ return Converter.parseAllDateTimeString(value);
91+ }
92+ });
93+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
94+ @Override
95+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
96+ String value = jsonParser.getText();
97+ return Converter.parseAllDateTimeString(value);
98+ }
99+ });
100+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
101+ @Override
102+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
103+ String value = jsonParser.getText();
104+ return Converter.parseAllDateTimeString(value);
105+ }
106+ });
107+ mapper.registerModule(module);
108+ reader = mapper.readerFor(TopLevel.class);
109+ writer = mapper.writerFor(TopLevel.class);
110+ }
111+
112+ private static ObjectReader getObjectReader() {
113+ if (reader == null) instantiateMapper();
114+ return reader;
115+ }
116+
117+ private static ObjectWriter getObjectWriter() {
118+ if (writer == null) instantiateMapper();
119+ return writer;
120+ }
121+}
Aschema-java-datetime-legacydefault / src / main / java / io / quicktype / TopLevel.java+24 −0
@@ -0,0 +1,24 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class TopLevel {
6+ private String name;
7+ private String surname;
8+
9+ /**
10+ * name description
11+ */
12+ @JsonProperty("name")
13+ public String getName() { return name; }
14+ @JsonProperty("name")
15+ public void setName(String value) { this.name = value; }
16+
17+ /**
18+ * surname description
19+ */
20+ @JsonProperty("surname")
21+ public String getSurname() { return surname; }
22+ @JsonProperty("surname")
23+ public void setSurname(String value) { this.surname = value; }
24+}
Aschema-java-lombokdefault / src / main / java / io / quicktype / Converter.java+101 −0
@@ -0,0 +1,101 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+// com.fasterxml.jackson.datatype : jackson-datatype-jsr310 : 2.9.0
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.time.LocalDate;
24+import java.time.OffsetDateTime;
25+import java.time.OffsetTime;
26+import java.time.ZoneOffset;
27+import java.time.ZonedDateTime;
28+import java.time.format.DateTimeFormatter;
29+import java.time.format.DateTimeFormatterBuilder;
30+import java.time.temporal.ChronoField;
31+
32+public class Converter {
33+ // Date-time helpers
34+
35+ private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
36+ .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
37+ .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
38+ .appendOptional(DateTimeFormatter.ISO_INSTANT)
39+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
40+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
41+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
42+ .toFormatter()
43+ .withZone(ZoneOffset.UTC);
44+
45+ public static OffsetDateTime parseDateTimeString(String str) {
46+ return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
47+ }
48+
49+ private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
50+ .appendOptional(DateTimeFormatter.ISO_TIME)
51+ .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
52+ .parseDefaulting(ChronoField.YEAR, 2020)
53+ .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
54+ .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
55+ .toFormatter()
56+ .withZone(ZoneOffset.UTC);
57+
58+ public static OffsetTime parseTimeString(String str) {
59+ return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
60+ }
61+ // Serialize/deserialize helpers
62+
63+ public static TopLevel fromJsonString(String json) throws IOException {
64+ return getObjectReader().readValue(json);
65+ }
66+
67+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
68+ return getObjectWriter().writeValueAsString(obj);
69+ }
70+
71+ private static ObjectReader reader;
72+ private static ObjectWriter writer;
73+
74+ private static void instantiateMapper() {
75+ ObjectMapper mapper = new ObjectMapper();
76+ mapper.findAndRegisterModules();
77+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
78+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
79+ SimpleModule module = new SimpleModule();
80+ module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
81+ @Override
82+ public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
83+ String value = jsonParser.getText();
84+ return Converter.parseDateTimeString(value);
85+ }
86+ });
87+ mapper.registerModule(module);
88+ reader = mapper.readerFor(TopLevel.class);
89+ writer = mapper.writerFor(TopLevel.class);
90+ }
91+
92+ private static ObjectReader getObjectReader() {
93+ if (reader == null) instantiateMapper();
94+ return reader;
95+ }
96+
97+ private static ObjectWriter getObjectWriter() {
98+ if (writer == null) instantiateMapper();
99+ return writer;
100+ }
101+}
Aschema-java-lombokdefault / src / main / java / io / quicktype / TopLevel.java+24 −0
@@ -0,0 +1,24 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class TopLevel {
6+ private String name;
7+ private String surname;
8+
9+ /**
10+ * name description
11+ */
12+ @JsonProperty("name")
13+ public String getName() { return name; }
14+ @JsonProperty("name")
15+ public void setName(String value) { this.name = value; }
16+
17+ /**
18+ * surname description
19+ */
20+ @JsonProperty("surname")
21+ public String getSurname() { return surname; }
22+ @JsonProperty("surname")
23+ public void setSurname(String value) { this.surname = value; }
24+}
Aschema-javadefault / src / main / java / io / quicktype / Converter.java+101 −0
@@ -0,0 +1,101 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+// com.fasterxml.jackson.datatype : jackson-datatype-jsr310 : 2.9.0
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.time.LocalDate;
24+import java.time.OffsetDateTime;
25+import java.time.OffsetTime;
26+import java.time.ZoneOffset;
27+import java.time.ZonedDateTime;
28+import java.time.format.DateTimeFormatter;
29+import java.time.format.DateTimeFormatterBuilder;
30+import java.time.temporal.ChronoField;
31+
32+public class Converter {
33+ // Date-time helpers
34+
35+ private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
36+ .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
37+ .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
38+ .appendOptional(DateTimeFormatter.ISO_INSTANT)
39+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
40+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
41+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
42+ .toFormatter()
43+ .withZone(ZoneOffset.UTC);
44+
45+ public static OffsetDateTime parseDateTimeString(String str) {
46+ return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
47+ }
48+
49+ private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
50+ .appendOptional(DateTimeFormatter.ISO_TIME)
51+ .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
52+ .parseDefaulting(ChronoField.YEAR, 2020)
53+ .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
54+ .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
55+ .toFormatter()
56+ .withZone(ZoneOffset.UTC);
57+
58+ public static OffsetTime parseTimeString(String str) {
59+ return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
60+ }
61+ // Serialize/deserialize helpers
62+
63+ public static TopLevel fromJsonString(String json) throws IOException {
64+ return getObjectReader().readValue(json);
65+ }
66+
67+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
68+ return getObjectWriter().writeValueAsString(obj);
69+ }
70+
71+ private static ObjectReader reader;
72+ private static ObjectWriter writer;
73+
74+ private static void instantiateMapper() {
75+ ObjectMapper mapper = new ObjectMapper();
76+ mapper.findAndRegisterModules();
77+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
78+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
79+ SimpleModule module = new SimpleModule();
80+ module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
81+ @Override
82+ public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
83+ String value = jsonParser.getText();
84+ return Converter.parseDateTimeString(value);
85+ }
86+ });
87+ mapper.registerModule(module);
88+ reader = mapper.readerFor(TopLevel.class);
89+ writer = mapper.writerFor(TopLevel.class);
90+ }
91+
92+ private static ObjectReader getObjectReader() {
93+ if (reader == null) instantiateMapper();
94+ return reader;
95+ }
96+
97+ private static ObjectWriter getObjectWriter() {
98+ if (writer == null) instantiateMapper();
99+ return writer;
100+ }
101+}
Aschema-javadefault / src / main / java / io / quicktype / TopLevel.java+24 −0
@@ -0,0 +1,24 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class TopLevel {
6+ private String name;
7+ private String surname;
8+
9+ /**
10+ * name description
11+ */
12+ @JsonProperty("name")
13+ public String getName() { return name; }
14+ @JsonProperty("name")
15+ public void setName(String value) { this.name = value; }
16+
17+ /**
18+ * surname description
19+ */
20+ @JsonProperty("surname")
21+ public String getSurname() { return surname; }
22+ @JsonProperty("surname")
23+ public void setSurname(String value) { this.surname = value; }
24+}
Aschema-javascriptdefault / TopLevel.js+183 −0
@@ -0,0 +1,183 @@
1+// To parse this data:
2+//
3+// const Convert = require("./TopLevel");
4+//
5+// const topLevel = Convert.toTopLevel(json);
6+//
7+// These functions will throw an error if the JSON doesn't
8+// match the expected interface, even if the JSON is valid.
9+
10+// Converts JSON strings to/from your types
11+// and asserts the results of JSON.parse at runtime
12+function toTopLevel(json) {
13+ return cast(JSON.parse(json), r("TopLevel"));
14+}
15+
16+function topLevelToJson(value) {
17+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
18+}
19+
20+function invalidValue(typ, val, key, parent = '') {
21+ const prettyTyp = prettyTypeName(typ);
22+ const parentText = parent ? ` on ${parent}` : '';
23+ const keyText = key ? ` for key "${key}"` : '';
24+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
25+}
26+
27+function prettyTypeName(typ) {
28+ if (Array.isArray(typ)) {
29+ if (typ.length === 2 && typ[0] === undefined) {
30+ return `an optional ${prettyTypeName(typ[1])}`;
31+ } else {
32+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
33+ }
34+ } else if (typeof typ === "object" && typ.literal !== undefined) {
35+ return typ.literal;
36+ } else {
37+ return typeof typ;
38+ }
39+}
40+
41+function jsonToJSProps(typ) {
42+ if (typ.jsonToJS === undefined) {
43+ const map = {};
44+ typ.props.forEach((p) => map[p.json] = { key: p.js, typ: p.typ });
45+ typ.jsonToJS = map;
46+ }
47+ return typ.jsonToJS;
48+}
49+
50+function jsToJSONProps(typ) {
51+ if (typ.jsToJSON === undefined) {
52+ const map = {};
53+ typ.props.forEach((p) => map[p.js] = { key: p.json, typ: p.typ });
54+ typ.jsToJSON = map;
55+ }
56+ return typ.jsToJSON;
57+}
58+
59+function transform(val, typ, getProps, key = '', parent = '') {
60+ function transformPrimitive(typ, val) {
61+ if (typeof typ === typeof val) return val;
62+ return invalidValue(typ, val, key, parent);
63+ }
64+
65+ function transformUnion(typs, val) {
66+ // val must validate against one typ in typs
67+ const l = typs.length;
68+ for (let i = 0; i < l; i++) {
69+ const typ = typs[i];
70+ try {
71+ return transform(val, typ, getProps);
72+ } catch (_) {}
73+ }
74+ return invalidValue(typs, val, key, parent);
75+ }
76+
77+ function transformEnum(cases, val) {
78+ if (cases.indexOf(val) !== -1) return val;
79+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
80+ }
81+
82+ function transformArray(typ, val) {
83+ // val must be an array with no invalid elements
84+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
85+ return val.map(el => transform(el, typ, getProps));
86+ }
87+
88+ function transformDate(val) {
89+ if (val === null) {
90+ return null;
91+ }
92+ const d = new Date(val);
93+ if (isNaN(d.valueOf())) {
94+ return invalidValue(l("Date"), val, key, parent);
95+ }
96+ return d;
97+ }
98+
99+ function transformObject(props, additional, val) {
100+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
101+ return invalidValue(l(ref || "object"), val, key, parent);
102+ }
103+ const result = {};
104+ Object.getOwnPropertyNames(props).forEach(key => {
105+ const prop = props[key];
106+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
107+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
108+ });
109+ Object.getOwnPropertyNames(val).forEach(key => {
110+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
111+ result[key] = transform(val[key], additional, getProps, key, ref);
112+ }
113+ });
114+ return result;
115+ }
116+
117+ if (typ === "any") return val;
118+ if (typ === null) {
119+ if (val === null) return val;
120+ return invalidValue(typ, val, key, parent);
121+ }
122+ if (typ === false) return invalidValue(typ, val, key, parent);
123+ let ref = undefined;
124+ while (typeof typ === "object" && typ.ref !== undefined) {
125+ ref = typ.ref;
126+ typ = typeMap[typ.ref];
127+ }
128+ if (Array.isArray(typ)) return transformEnum(typ, val);
129+ if (typeof typ === "object") {
130+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
131+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
132+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
133+ : invalidValue(typ, val, key, parent);
134+ }
135+ // Numbers can be parsed by Date but shouldn't be.
136+ if (typ === Date && typeof val !== "number") return transformDate(val);
137+ return transformPrimitive(typ, val);
138+}
139+
140+function cast(val, typ) {
141+ return transform(val, typ, jsonToJSProps);
142+}
143+
144+function uncast(val, typ) {
145+ return transform(val, typ, jsToJSONProps);
146+}
147+
148+function l(typ) {
149+ return { literal: typ };
150+}
151+
152+function a(typ) {
153+ return { arrayItems: typ };
154+}
155+
156+function u(...typs) {
157+ return { unionMembers: typs };
158+}
159+
160+function o(props, additional) {
161+ return { props, additional };
162+}
163+
164+function m(additional) {
165+ const props = [];
166+ return { props, additional };
167+}
168+
169+function r(name) {
170+ return { ref: name };
171+}
172+
173+const typeMap = {
174+ "TopLevel": o([
175+ { json: "name", js: "name", typ: "" },
176+ { json: "surname", js: "surname", typ: "" },
177+ ], "any"),
178+};
179+
180+module.exports = {
181+ "topLevelToJson": topLevelToJson,
182+ "toTopLevel": toTopLevel,
183+};
Aschema-kotlin-jacksondefault / TopLevel.kt+39 −0
@@ -0,0 +1,39 @@
1+// To parse the JSON, install jackson-module-kotlin and do:
2+//
3+// val topLevel = TopLevel.fromJson(jsonString)
4+
5+package quicktype
6+
7+import com.fasterxml.jackson.annotation.*
8+import com.fasterxml.jackson.core.*
9+import com.fasterxml.jackson.databind.*
10+import com.fasterxml.jackson.databind.deser.std.StdDeserializer
11+import com.fasterxml.jackson.databind.module.SimpleModule
12+import com.fasterxml.jackson.databind.node.*
13+import com.fasterxml.jackson.databind.ser.std.StdSerializer
14+import com.fasterxml.jackson.module.kotlin.*
15+
16+val mapper = jacksonObjectMapper().apply {
17+ propertyNamingStrategy = PropertyNamingStrategy.LOWER_CAMEL_CASE
18+ setSerializationInclusion(JsonInclude.Include.NON_NULL)
19+}
20+
21+data class TopLevel (
22+ /**
23+ * name description
24+ */
25+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
26+ val name: String,
27+
28+ /**
29+ * surname description
30+ */
31+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
32+ val surname: String
33+) {
34+ fun toJson() = mapper.writeValueAsString(this)
35+
36+ companion object {
37+ fun fromJson(json: String) = mapper.readValue<TopLevel>(json)
38+ }
39+}
Aschema-kotlindefault / TopLevel.kt+27 −0
@@ -0,0 +1,27 @@
1+// To parse the JSON, install Klaxon and do:
2+//
3+// val topLevel = TopLevel.fromJson(jsonString)
4+
5+package quicktype
6+
7+import com.beust.klaxon.*
8+
9+private val klaxon = Klaxon()
10+
11+data class TopLevel (
12+ /**
13+ * name description
14+ */
15+ val name: String,
16+
17+ /**
18+ * surname description
19+ */
20+ val surname: String
21+) {
22+ public fun toJson() = klaxon.toJsonString(this)
23+
24+ companion object {
25+ public fun fromJson(json: String) = klaxon.parse<TopLevel>(json)
26+ }
27+}
Aschema-kotlinxdefault / TopLevel.kt+24 −0
@@ -0,0 +1,24 @@
1+// To parse the JSON, install kotlin's serialization plugin and do:
2+//
3+// val json = Json { allowStructuredMapKeys = true }
4+// val topLevel = json.parse(TopLevel.serializer(), jsonString)
5+
6+package quicktype
7+
8+import kotlinx.serialization.*
9+import kotlinx.serialization.json.*
10+import kotlinx.serialization.descriptors.*
11+import kotlinx.serialization.encoding.*
12+
13+@Serializable
14+data class TopLevel (
15+ /**
16+ * name description
17+ */
18+ val name: String,
19+
20+ /**
21+ * surname description
22+ */
23+ val surname: String
24+)
Aschema-phpdefault / TopLevel.php+174 −0
@@ -0,0 +1,174 @@
1+<?php
2+declare(strict_types=1);
3+
4+// This is an autogenerated file:TopLevel
5+
6+class TopLevel {
7+ private string $name; // json:name Required
8+ private string $surname; // json:surname Required
9+
10+ /**
11+ * @param string $name
12+ * @param string $surname
13+ */
14+ public function __construct(string $name, string $surname) {
15+ $this->name = $name;
16+ $this->surname = $surname;
17+ }
18+
19+ /**
20+ * name description
21+ *
22+ * @param string $value
23+ * @throws Exception
24+ * @return string
25+ */
26+ public static function fromName(string $value): string {
27+ return $value; /*string*/
28+ }
29+
30+ /**
31+ * name description
32+ *
33+ * @throws Exception
34+ * @return string
35+ */
36+ public function toName(): string {
37+ if (TopLevel::validateName($this->name)) {
38+ return $this->name; /*string*/
39+ }
40+ throw new Exception('never get to this TopLevel::name');
41+ }
42+
43+ /**
44+ * name description
45+ *
46+ * @param string
47+ * @return bool
48+ * @throws Exception
49+ */
50+ public static function validateName(string $value): bool {
51+ return true;
52+ }
53+
54+ /**
55+ * name description
56+ *
57+ * @throws Exception
58+ * @return string
59+ */
60+ public function getName(): string {
61+ if (TopLevel::validateName($this->name)) {
62+ return $this->name;
63+ }
64+ throw new Exception('never get to getName TopLevel::name');
65+ }
66+
67+ /**
68+ * name description
69+ *
70+ * @return string
71+ */
72+ public static function sampleName(): string {
73+ return 'TopLevel::name::31'; /*31:name*/
74+ }
75+
76+ /**
77+ * surname description
78+ *
79+ * @param string $value
80+ * @throws Exception
81+ * @return string
82+ */
83+ public static function fromSurname(string $value): string {
84+ return $value; /*string*/
85+ }
86+
87+ /**
88+ * surname description
89+ *
90+ * @throws Exception
91+ * @return string
92+ */
93+ public function toSurname(): string {
94+ if (TopLevel::validateSurname($this->surname)) {
95+ return $this->surname; /*string*/
96+ }
97+ throw new Exception('never get to this TopLevel::surname');
98+ }
99+
100+ /**
101+ * surname description
102+ *
103+ * @param string
104+ * @return bool
105+ * @throws Exception
106+ */
107+ public static function validateSurname(string $value): bool {
108+ return true;
109+ }
110+
111+ /**
112+ * surname description
113+ *
114+ * @throws Exception
115+ * @return string
116+ */
117+ public function getSurname(): string {
118+ if (TopLevel::validateSurname($this->surname)) {
119+ return $this->surname;
120+ }
121+ throw new Exception('never get to getSurname TopLevel::surname');
122+ }
123+
124+ /**
125+ * surname description
126+ *
127+ * @return string
128+ */
129+ public static function sampleSurname(): string {
130+ return 'TopLevel::surname::32'; /*32:surname*/
131+ }
132+
133+ /**
134+ * @throws Exception
135+ * @return bool
136+ */
137+ public function validate(): bool {
138+ return TopLevel::validateName($this->name)
139+ || TopLevel::validateSurname($this->surname);
140+ }
141+
142+ /**
143+ * @return stdClass
144+ * @throws Exception
145+ */
146+ public function to(): stdClass {
147+ $out = new stdClass();
148+ $out->{'name'} = $this->toName();
149+ $out->{'surname'} = $this->toSurname();
150+ return $out;
151+ }
152+
153+ /**
154+ * @param stdClass $obj
155+ * @return TopLevel
156+ * @throws Exception
157+ */
158+ public static function from(stdClass $obj): TopLevel {
159+ return new TopLevel(
160+ TopLevel::fromName($obj->{'name'})
161+ ,TopLevel::fromSurname($obj->{'surname'})
162+ );
163+ }
164+
165+ /**
166+ * @return TopLevel
167+ */
168+ public static function sample(): TopLevel {
169+ return new TopLevel(
170+ TopLevel::sampleName()
171+ ,TopLevel::sampleSurname()
172+ );
173+ }
174+}
Aschema-pikedefault / TopLevel.pmod+36 −0
@@ -0,0 +1,36 @@
1+// This source has been automatically generated by quicktype.
2+// ( https://github.com/quicktype/quicktype )
3+//
4+// To use this code, simply import it into your project as a Pike module.
5+// To JSON-encode your object, you can pass it to `Standards.JSON.encode`
6+// or call `encode_json` on it.
7+//
8+// To decode a JSON string, first pass it to `Standards.JSON.decode`,
9+// and then pass the result to `<YourClass>_from_JSON`.
10+// It will return an instance of <YourClass>.
11+// Bear in mind that these functions have unexpected behavior,
12+// and will likely throw an error, if the JSON string does not
13+// match the expected interface, even if the JSON itself is valid.
14+
15+class TopLevel {
16+ string name; // json: "name"
17+ string surname; // json: "surname"
18+
19+ string encode_json() {
20+ mapping(string:mixed) json = ([
21+ "name" : name,
22+ "surname" : surname,
23+ ]);
24+
25+ return Standards.JSON.encode(json);
26+ }
27+}
28+
29+TopLevel TopLevel_from_JSON(mixed json) {
30+ TopLevel retval = TopLevel();
31+
32+ retval.name = json["name"];
33+ retval.surname = json["surname"];
34+
35+ return retval;
36+}
Aschema-pythondefault / quicktype.py+45 −0
@@ -0,0 +1,45 @@
1+from dataclasses import dataclass
2+from typing import Any, TypeVar, Type, cast
3+
4+
5+T = TypeVar("T")
6+
7+
8+def from_str(x: Any) -> str:
9+ assert isinstance(x, str)
10+ return x
11+
12+
13+def to_class(c: Type[T], x: Any) -> dict:
14+ assert isinstance(x, c)
15+ return cast(Any, x).to_dict()
16+
17+
18+@dataclass
19+class TopLevel:
20+ name: str
21+ """name description"""
22+
23+ surname: str
24+ """surname description"""
25+
26+ @staticmethod
27+ def from_dict(obj: Any) -> 'TopLevel':
28+ assert isinstance(obj, dict)
29+ name = from_str(obj.get("name"))
30+ surname = from_str(obj.get("surname"))
31+ return TopLevel(name, surname)
32+
33+ def to_dict(self) -> dict:
34+ result: dict = {}
35+ result["name"] = from_str(self.name)
36+ result["surname"] = from_str(self.surname)
37+ return result
38+
39+
40+def top_level_from_dict(s: Any) -> TopLevel:
41+ return TopLevel.from_dict(s)
42+
43+
44+def top_level_to_dict(x: TopLevel) -> Any:
45+ return to_class(TopLevel, x)
Aschema-rubydefault / TopLevel.rb+52 −0
@@ -0,0 +1,52 @@
1+# This code may look unusually verbose for Ruby (and it is), but
2+# it performs some subtle and complex validation of JSON data.
3+#
4+# To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
5+#
6+# top_level = TopLevel.from_json! "{…}"
7+# puts top_level.top_level_name
8+#
9+# If from_json! succeeds, the value returned matches the schema.
10+
11+require 'json'
12+require 'dry-types'
13+require 'dry-struct'
14+
15+module Types
16+ include Dry.Types(default: :nominal)
17+
18+ Hash = Strict::Hash
19+ String = Strict::String
20+end
21+
22+class TopLevel < Dry::Struct
23+
24+ # name description
25+ attribute :top_level_name, Types::String
26+
27+ # surname description
28+ attribute :surname, Types::String
29+
30+ def self.from_dynamic!(d)
31+ d = Types::Hash[d]
32+ new(
33+ top_level_name: d.fetch("name"),
34+ surname: d.fetch("surname"),
35+ )
36+ end
37+
38+ def self.from_json!(json)
39+ from_dynamic!(JSON.parse(json))
40+ end
41+
42+ def to_dynamic
43+ {
44+ "name" => top_level_name,
45+ "surname" => surname,
46+ }
47+ end
48+
49+ def to_json(options = nil)
50+ JSON.generate(to_dynamic, options)
51+ end
52+end
Aschema-rustdefault / module_under_test.rs+23 −0
@@ -0,0 +1,23 @@
1+// Example code that deserializes and serializes the model.
2+// extern crate serde;
3+// #[macro_use]
4+// extern crate serde_derive;
5+// extern crate serde_json;
6+//
7+// use generated_module::TopLevel;
8+//
9+// fn main() {
10+// let json = r#"{"answer": 42}"#;
11+// let model: TopLevel = serde_json::from_str(&json).unwrap();
12+// }
13+
14+use serde::{Serialize, Deserialize};
15+
16+#[derive(Debug, Clone, Serialize, Deserialize)]
17+pub struct TopLevel {
18+ /// name description
19+ pub name: String,
20+
21+ /// surname description
22+ pub surname: String,
23+}
Aschema-scala3-upickledefault / TopLevel.scala+78 −0
@@ -0,0 +1,78 @@
1+package quicktype
2+
3+// Custom pickler so that missing keys and JSON nulls both read as None,
4+// and None is left out when writing (upickle's default for Option is a
5+// JSON array).
6+object OptionPickler extends upickle.AttributeTagged:
7+ import upickle.default.Writer
8+ import upickle.default.Reader
9+ override implicit def OptionWriter[T: Writer]: Writer[Option[T]] =
10+ implicitly[Writer[T]].comap[Option[T]] {
11+ case None => null.asInstanceOf[T]
12+ case Some(x) => x
13+ }
14+
15+ override implicit def OptionReader[T: Reader]: Reader[Option[T]] = {
16+ new Reader.Delegate[Any, Option[T]](implicitly[Reader[T]].map(Some(_))){
17+ override def visitNull(index: Int) = None
18+ }
19+ }
20+end OptionPickler
21+
22+// If a union has a null in, then we'll need this too...
23+type NullValue = None.type
24+given OptionPickler.ReadWriter[NullValue] = OptionPickler.readwriter[ujson.Value].bimap[NullValue](
25+ _ => ujson.Null,
26+ json => if json.isNull then None else throw new upickle.core.Abort("not null")
27+)
28+
29+object JsonExt:
30+ val valueReader = OptionPickler.readwriter[ujson.Value]
31+
32+ // upickle's built-in primitive readers are lenient -- the numeric and
33+ // boolean readers accept strings, and the string reader accepts
34+ // numbers and booleans -- so untagged unions need strict readers to
35+ // pick the right member.
36+ val strictString: OptionPickler.Reader[String] = valueReader.map {
37+ case ujson.Str(s) => s
38+ case json => throw new upickle.core.Abort("expected string, got " + json)
39+ }
40+ val strictLong: OptionPickler.Reader[Long] = valueReader.map {
41+ case ujson.Num(n) if n.isWhole => n.toLong
42+ case json => throw new upickle.core.Abort("expected integer, got " + json)
43+ }
44+ val strictDouble: OptionPickler.Reader[Double] = valueReader.map {
45+ case ujson.Num(n) => n
46+ case json => throw new upickle.core.Abort("expected number, got " + json)
47+ }
48+ val strictBoolean: OptionPickler.Reader[Boolean] = valueReader.map {
49+ case ujson.Bool(b) => b
50+ case json => throw new upickle.core.Abort("expected boolean, got " + json)
51+ }
52+
53+ def badMerge[T](r1: => OptionPickler.Reader[?], rest: OptionPickler.Reader[?]*): OptionPickler.Reader[T] = valueReader.map { json =>
54+ var t: T | Null = null
55+ val stack = Vector.newBuilder[Throwable]
56+ (r1 +: rest).foreach { reader =>
57+ if t == null then
58+ try
59+ t = OptionPickler.read[T](json, trace = true)(using reader.asInstanceOf[OptionPickler.Reader[T]])
60+ catch
61+ case exc => stack += exc
62+ }
63+ if t != null then t.nn else throw new Exception(json.toString(), stack.result().headOption.getOrElse(null))
64+ }
65+end JsonExt
66+
67+
68+case class TopLevel (
69+ /**
70+ * name description
71+ */
72+ val name : String,
73+
74+ /**
75+ * surname description
76+ */
77+ val surname : String
78+) derives OptionPickler.ReadWriter
Aschema-scala3default / TopLevel.scala+20 −0
@@ -0,0 +1,20 @@
1+package quicktype
2+
3+import io.circe.syntax._
4+import io.circe._
5+import cats.syntax.functor._
6+
7+// If a union has a null in, then we'll need this too...
8+type NullValue = None.type
9+
10+case class TopLevel (
11+ /**
12+ * name description
13+ */
14+ val name : String,
15+
16+ /**
17+ * surname description
18+ */
19+ val surname : String
20+) derives Encoder.AsObject, Decoder
Aschema-schemadefault / TopLevel.schema+25 −0
@@ -0,0 +1,25 @@
1+{
2+ "$schema": "http://json-schema.org/draft-06/schema#",
3+ "$ref": "#/definitions/TopLevel",
4+ "definitions": {
5+ "TopLevel": {
6+ "type": "object",
7+ "additionalProperties": {},
8+ "properties": {
9+ "name": {
10+ "type": "string",
11+ "description": "name description"
12+ },
13+ "surname": {
14+ "type": "string",
15+ "description": "surname description"
16+ }
17+ },
18+ "required": [
19+ "name",
20+ "surname"
21+ ],
22+ "title": "TopLevel"
23+ }
24+ }
25+}
Aschema-typescriptdefault / TopLevel.ts+192 −0
@@ -0,0 +1,192 @@
1+// To parse this data:
2+//
3+// import { Convert, TopLevel } from "./TopLevel";
4+//
5+// const topLevel = Convert.toTopLevel(json);
6+//
7+// These functions will throw an error if the JSON doesn't
8+// match the expected interface, even if the JSON is valid.
9+
10+export interface TopLevel {
11+ /**
12+ * name description
13+ */
14+ name: string;
15+ /**
16+ * surname description
17+ */
18+ surname: string;
19+ [property: string]: unknown;
20+}
21+
22+// Converts JSON strings to/from your types
23+// and asserts the results of JSON.parse at runtime
24+export class Convert {
25+ public static toTopLevel(json: string): TopLevel {
26+ return cast(JSON.parse(json), r("TopLevel"));
27+ }
28+
29+ public static topLevelToJson(value: TopLevel): string {
30+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
31+ }
32+}
33+
34+function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
35+ const prettyTyp = prettyTypeName(typ);
36+ const parentText = parent ? ` on ${parent}` : '';
37+ const keyText = key ? ` for key "${key}"` : '';
38+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
39+}
40+
41+function prettyTypeName(typ: any): string {
42+ if (Array.isArray(typ)) {
43+ if (typ.length === 2 && typ[0] === undefined) {
44+ return `an optional ${prettyTypeName(typ[1])}`;
45+ } else {
46+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
47+ }
48+ } else if (typeof typ === "object" && typ.literal !== undefined) {
49+ return typ.literal;
50+ } else {
51+ return typeof typ;
52+ }
53+}
54+
55+function jsonToJSProps(typ: any): any {
56+ if (typ.jsonToJS === undefined) {
57+ const map: any = {};
58+ typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
59+ typ.jsonToJS = map;
60+ }
61+ return typ.jsonToJS;
62+}
63+
64+function jsToJSONProps(typ: any): any {
65+ if (typ.jsToJSON === undefined) {
66+ const map: any = {};
67+ typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
68+ typ.jsToJSON = map;
69+ }
70+ return typ.jsToJSON;
71+}
72+
73+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
74+ function transformPrimitive(typ: string, val: any): any {
75+ if (typeof typ === typeof val) return val;
76+ return invalidValue(typ, val, key, parent);
77+ }
78+
79+ function transformUnion(typs: any[], val: any): any {
80+ // val must validate against one typ in typs
81+ const l = typs.length;
82+ for (let i = 0; i < l; i++) {
83+ const typ = typs[i];
84+ try {
85+ return transform(val, typ, getProps);
86+ } catch (_) {}
87+ }
88+ return invalidValue(typs, val, key, parent);
89+ }
90+
91+ function transformEnum(cases: string[], val: any): any {
92+ if (cases.indexOf(val) !== -1) return val;
93+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
94+ }
95+
96+ function transformArray(typ: any, val: any): any {
97+ // val must be an array with no invalid elements
98+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
99+ return val.map(el => transform(el, typ, getProps));
100+ }
101+
102+ function transformDate(val: any): any {
103+ if (val === null) {
104+ return null;
105+ }
106+ const d = new Date(val);
107+ if (isNaN(d.valueOf())) {
108+ return invalidValue(l("Date"), val, key, parent);
109+ }
110+ return d;
111+ }
112+
113+ function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
114+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
115+ return invalidValue(l(ref || "object"), val, key, parent);
116+ }
117+ const result: any = {};
118+ Object.getOwnPropertyNames(props).forEach(key => {
119+ const prop = props[key];
120+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
121+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
122+ });
123+ Object.getOwnPropertyNames(val).forEach(key => {
124+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
125+ result[key] = transform(val[key], additional, getProps, key, ref);
126+ }
127+ });
128+ return result;
129+ }
130+
131+ if (typ === "any") return val;
132+ if (typ === null) {
133+ if (val === null) return val;
134+ return invalidValue(typ, val, key, parent);
135+ }
136+ if (typ === false) return invalidValue(typ, val, key, parent);
137+ let ref: any = undefined;
138+ while (typeof typ === "object" && typ.ref !== undefined) {
139+ ref = typ.ref;
140+ typ = typeMap[typ.ref];
141+ }
142+ if (Array.isArray(typ)) return transformEnum(typ, val);
143+ if (typeof typ === "object") {
144+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
145+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
146+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
147+ : invalidValue(typ, val, key, parent);
148+ }
149+ // Numbers can be parsed by Date but shouldn't be.
150+ if (typ === Date && typeof val !== "number") return transformDate(val);
151+ return transformPrimitive(typ, val);
152+}
153+
154+function cast<T>(val: any, typ: any): T {
155+ return transform(val, typ, jsonToJSProps);
156+}
157+
158+function uncast<T>(val: T, typ: any): any {
159+ return transform(val, typ, jsToJSONProps);
160+}
161+
162+function l(typ: any) {
163+ return { literal: typ };
164+}
165+
166+function a(typ: any) {
167+ return { arrayItems: typ };
168+}
169+
170+function u(...typs: any[]) {
171+ return { unionMembers: typs };
172+}
173+
174+function o(props: any[], additional: any) {
175+ return { props, additional };
176+}
177+
178+function m(additional: any) {
179+ const props: any[] = [];
180+ return { props, additional };
181+}
182+
183+function r(name: string) {
184+ return { ref: name };
185+}
186+
187+const typeMap: any = {
188+ "TopLevel": o([
189+ { json: "name", js: "name", typ: "" },
190+ { json: "surname", js: "surname", typ: "" },
191+ ], "any"),
192+};
Test case

test/inputs/schema/list.schema

24 generated files · +69 −3
Mschema-cjsondefault / TopLevel.h+3 −0
@@ -38,6 +38,9 @@ extern "C" {
3838 * A recursive class type
3939 */
4040 struct TopLevel {
41+ /**
42+ * A recursive class type
43+ */
4144 struct TopLevel * next;
4245 };
Mschema-cplusplusdefault / quicktype.hpp+3 −0
@@ -100,6 +100,9 @@ namespace quicktype {
100100 std::shared_ptr<TopLevel> next;
101101
102102 public:
103+ /**
104+ * A recursive class type
105+ */
103106 const std::shared_ptr<TopLevel> & get_next() const { return next; }
104107 std::shared_ptr<TopLevel> & get_mutable_next() { return next; }
105108 void set_next(const std::shared_ptr<TopLevel> & value) { this->next = value; }
Mschema-csharp-recordsdefault / QuickType.cs+3 −0
@@ -28,6 +28,9 @@ namespace QuickType
2828 /// </summary>
2929 public partial record TopLevel
3030 {
31+ /// <summary>
32+ /// A recursive class type
33+ /// </summary>
3134 [JsonProperty("next", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3235 public TopLevel? Next { get; set; }
3336 }
Mschema-csharp-SystemTextJsondefault / QuickType.cs+3 −0
@@ -25,6 +25,9 @@ namespace QuickType
2525 /// </summary>
2626 public partial class TopLevel
2727 {
28+ /// <summary>
29+ /// A recursive class type
30+ /// </summary>
2831 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2932 [JsonPropertyName("next")]
3033 public TopLevel? Next { get; set; }
Mschema-csharpdefault / QuickType.cs+3 −0
@@ -28,6 +28,9 @@ namespace QuickType
2828 /// </summary>
2929 public partial class TopLevel
3030 {
31+ /// <summary>
32+ /// A recursive class type
33+ /// </summary>
3134 [JsonProperty("next", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3235 public TopLevel? Next { get; set; }
3336 }
Mschema-elixirdefault / QuickType.ex+1 −0
@@ -8,6 +8,7 @@
88 defmodule TopLevel do
99 @moduledoc """
1010 A recursive class type
11+ - `:next` - A recursive class type
1112 """
1213
1314 defstruct [:next]
Mschema-flowdefault / TopLevel.js+3 −0
@@ -13,6 +13,9 @@
1313 * A recursive class type
1414 */
1515 export type TopLevel = {
16+ /**
17+ * A recursive class type
18+ */
1619 next?: TopLevel;
1720 [property: string]: mixed;
1821 };
Mschema-golangdefault / quicktype.go+2 −1
@@ -20,5 +20,6 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2020
2121 // A recursive class type
2222 type TopLevel struct {
23- Next *TopLevel `json:"next,omitempty"`
23+ // A recursive class type
24+ Next *TopLevel `json:"next,omitempty"`
2425 }
Mschema-haskelldefault / QuickType.hs+4 −1
@@ -12,8 +12,11 @@ import Data.ByteString.Lazy (ByteString)
1212 import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
15-{-| A recursive class type -}
15+{-| A recursive class type
1616
17+next:
18+A recursive class type
19+-}
1720 data QuickType = QuickType
1821 { nextQuickType :: Maybe QuickType
1922 } deriving (Show)
Mschema-java-datetime-legacydefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-java-lombokdefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-javadefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-kotlin-jacksondefault / TopLevel.kt+3 −0
@@ -22,6 +22,9 @@ val mapper = jacksonObjectMapper().apply {
2222 * A recursive class type
2323 */
2424 data class TopLevel (
25+ /**
26+ * A recursive class type
27+ */
2528 val next: TopLevel? = null
2629 ) {
2730 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlindefault / TopLevel.kt+3 −0
@@ -12,6 +12,9 @@ private val klaxon = Klaxon()
1212 * A recursive class type
1313 */
1414 data class TopLevel (
15+ /**
16+ * A recursive class type
17+ */
1518 val next: TopLevel? = null
1619 ) {
1720 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlinxdefault / TopLevel.kt+3 −0
@@ -15,5 +15,8 @@ import kotlinx.serialization.encoding.*
1515 */
1616 @Serializable
1717 data class TopLevel (
18+ /**
19+ * A recursive class type
20+ */
1821 val next: TopLevel? = null
1922 )
Mschema-phpdefault / TopLevel.php+10 −0
@@ -14,6 +14,8 @@ class TopLevel {
1414 }
1515
1616 /**
17+ * A recursive class type
18+ *
1719 * @param ?stdClass $value
1820 * @throws Exception
1921 * @return ?TopLevel
@@ -27,6 +29,8 @@ class TopLevel {
2729 }
2830
2931 /**
32+ * A recursive class type
33+ *
3034 * @throws Exception
3135 * @return ?stdClass
3236 */
@@ -42,6 +46,8 @@ class TopLevel {
4246 }
4347
4448 /**
49+ * A recursive class type
50+ *
4551 * @param TopLevel|null
4652 * @return bool
4753 * @throws Exception
@@ -54,6 +60,8 @@ class TopLevel {
5460 }
5561
5662 /**
63+ * A recursive class type
64+ *
5765 * @throws Exception
5866 * @return ?TopLevel
5967 */
@@ -65,6 +73,8 @@ class TopLevel {
6573 }
6674
6775 /**
76+ * A recursive class type
77+ *
6878 * @return ?TopLevel
6979 */
7080 public static function sampleNext(): ?TopLevel {
Mschema-pythondefault / quicktype.py+1 −0
@@ -29,6 +29,7 @@ class TopLevel:
2929 """A recursive class type"""
3030
3131 next: 'TopLevel | None' = None
32+ """A recursive class type"""
3233
3334 @staticmethod
3435 def from_dict(obj: Any) -> 'TopLevel':
Mschema-rubydefault / TopLevel.rb+2 −0
@@ -20,6 +20,8 @@ end
2020
2121 # A recursive class type
2222 class TopLevel < Dry::Struct
23+
24+ # A recursive class type
2325 attribute :top_level_next, TopLevel.optional
2426
2527 def self.from_dynamic!(d)
Mschema-rustdefault / module_under_test.rs+1 −0
@@ -16,5 +16,6 @@ use serde::{Serialize, Deserialize};
1616 /// A recursive class type
1717 #[derive(Debug, Clone, Serialize, Deserialize)]
1818 pub struct TopLevel {
19+ /// A recursive class type
1920 pub next: Option<Box<TopLevel>>,
2021 }
Mschema-scala3-upickledefault / TopLevel.scala+3 −0
@@ -69,5 +69,8 @@ end JsonExt
6969 * A recursive class type
7070 */
7171 case class TopLevel (
72+ /**
73+ * A recursive class type
74+ */
7275 val next : Option[TopLevel] = None
7376 ) derives OptionPickler.ReadWriter
Mschema-scala3default / TopLevel.scala+3 −0
@@ -11,5 +11,8 @@ type NullValue = None.type
1111 * A recursive class type
1212 */
1313 case class TopLevel (
14+ /**
15+ * A recursive class type
16+ */
1417 val next : Option[TopLevel] = None
1518 ) derives Encoder.AsObject, Decoder
Mschema-schemadefault / TopLevel.schema+2 −1
@@ -7,7 +7,8 @@
77 "additionalProperties": {},
88 "properties": {
99 "next": {
10- "$ref": "#/definitions/TopLevel"
10+ "$ref": "#/definitions/TopLevel",
11+ "description": "A recursive class type"
1112 }
1213 },
1314 "required": [],
Mschema-swiftdefault / quicktype.swift+1 −0
@@ -8,6 +8,7 @@ import Foundation
88 /// A recursive class type
99 // MARK: - TopLevel
1010 class TopLevel: Codable {
11+ /// A recursive class type
1112 let next: TopLevel?
1213
1314 enum CodingKeys: String, CodingKey {
Mschema-typescriptdefault / TopLevel.ts+3 −0
@@ -11,6 +11,9 @@
1111 * A recursive class type
1212 */
1313 export interface TopLevel {
14+ /**
15+ * A recursive class type
16+ */
1417 next?: TopLevel;
1518 [property: string]: unknown;
1619 }
Test case

test/inputs/schema/ref-remote.schema

24 generated files · +69 −3
Mschema-cjsondefault / TopLevel.h+3 −0
@@ -38,6 +38,9 @@ extern "C" {
3838 * A recursive class type
3939 */
4040 struct TopLevel {
41+ /**
42+ * A recursive class type
43+ */
4144 struct TopLevel * next;
4245 };
Mschema-cplusplusdefault / quicktype.hpp+3 −0
@@ -100,6 +100,9 @@ namespace quicktype {
100100 std::shared_ptr<TopLevel> next;
101101
102102 public:
103+ /**
104+ * A recursive class type
105+ */
103106 const std::shared_ptr<TopLevel> & get_next() const { return next; }
104107 std::shared_ptr<TopLevel> & get_mutable_next() { return next; }
105108 void set_next(const std::shared_ptr<TopLevel> & value) { this->next = value; }
Mschema-csharp-recordsdefault / QuickType.cs+3 −0
@@ -28,6 +28,9 @@ namespace QuickType
2828 /// </summary>
2929 public partial record TopLevel
3030 {
31+ /// <summary>
32+ /// A recursive class type
33+ /// </summary>
3134 [JsonProperty("next", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3235 public TopLevel? Next { get; set; }
3336 }
Mschema-csharp-SystemTextJsondefault / QuickType.cs+3 −0
@@ -25,6 +25,9 @@ namespace QuickType
2525 /// </summary>
2626 public partial class TopLevel
2727 {
28+ /// <summary>
29+ /// A recursive class type
30+ /// </summary>
2831 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2932 [JsonPropertyName("next")]
3033 public TopLevel? Next { get; set; }
Mschema-csharpdefault / QuickType.cs+3 −0
@@ -28,6 +28,9 @@ namespace QuickType
2828 /// </summary>
2929 public partial class TopLevel
3030 {
31+ /// <summary>
32+ /// A recursive class type
33+ /// </summary>
3134 [JsonProperty("next", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3235 public TopLevel? Next { get; set; }
3336 }
Mschema-elixirdefault / QuickType.ex+1 −0
@@ -8,6 +8,7 @@
88 defmodule TopLevel do
99 @moduledoc """
1010 A recursive class type
11+ - `:next` - A recursive class type
1112 """
1213
1314 defstruct [:next]
Mschema-flowdefault / TopLevel.js+3 −0
@@ -13,6 +13,9 @@
1313 * A recursive class type
1414 */
1515 export type TopLevel = {
16+ /**
17+ * A recursive class type
18+ */
1619 next?: TopLevel;
1720 [property: string]: mixed;
1821 };
Mschema-golangdefault / quicktype.go+2 −1
@@ -20,5 +20,6 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2020
2121 // A recursive class type
2222 type TopLevel struct {
23- Next *TopLevel `json:"next,omitempty"`
23+ // A recursive class type
24+ Next *TopLevel `json:"next,omitempty"`
2425 }
Mschema-haskelldefault / QuickType.hs+4 −1
@@ -12,8 +12,11 @@ import Data.ByteString.Lazy (ByteString)
1212 import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
15-{-| A recursive class type -}
15+{-| A recursive class type
1616
17+next:
18+A recursive class type
19+-}
1720 data QuickType = QuickType
1821 { nextQuickType :: Maybe QuickType
1922 } deriving (Show)
Mschema-java-datetime-legacydefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-java-lombokdefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-javadefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-kotlin-jacksondefault / TopLevel.kt+3 −0
@@ -22,6 +22,9 @@ val mapper = jacksonObjectMapper().apply {
2222 * A recursive class type
2323 */
2424 data class TopLevel (
25+ /**
26+ * A recursive class type
27+ */
2528 val next: TopLevel? = null
2629 ) {
2730 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlindefault / TopLevel.kt+3 −0
@@ -12,6 +12,9 @@ private val klaxon = Klaxon()
1212 * A recursive class type
1313 */
1414 data class TopLevel (
15+ /**
16+ * A recursive class type
17+ */
1518 val next: TopLevel? = null
1619 ) {
1720 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlinxdefault / TopLevel.kt+3 −0
@@ -15,5 +15,8 @@ import kotlinx.serialization.encoding.*
1515 */
1616 @Serializable
1717 data class TopLevel (
18+ /**
19+ * A recursive class type
20+ */
1821 val next: TopLevel? = null
1922 )
Mschema-phpdefault / TopLevel.php+10 −0
@@ -14,6 +14,8 @@ class TopLevel {
1414 }
1515
1616 /**
17+ * A recursive class type
18+ *
1719 * @param ?stdClass $value
1820 * @throws Exception
1921 * @return ?TopLevel
@@ -27,6 +29,8 @@ class TopLevel {
2729 }
2830
2931 /**
32+ * A recursive class type
33+ *
3034 * @throws Exception
3135 * @return ?stdClass
3236 */
@@ -42,6 +46,8 @@ class TopLevel {
4246 }
4347
4448 /**
49+ * A recursive class type
50+ *
4551 * @param TopLevel|null
4652 * @return bool
4753 * @throws Exception
@@ -54,6 +60,8 @@ class TopLevel {
5460 }
5561
5662 /**
63+ * A recursive class type
64+ *
5765 * @throws Exception
5866 * @return ?TopLevel
5967 */
@@ -65,6 +73,8 @@ class TopLevel {
6573 }
6674
6775 /**
76+ * A recursive class type
77+ *
6878 * @return ?TopLevel
6979 */
7080 public static function sampleNext(): ?TopLevel {
Mschema-pythondefault / quicktype.py+1 −0
@@ -29,6 +29,7 @@ class TopLevel:
2929 """A recursive class type"""
3030
3131 next: 'TopLevel | None' = None
32+ """A recursive class type"""
3233
3334 @staticmethod
3435 def from_dict(obj: Any) -> 'TopLevel':
Mschema-rubydefault / TopLevel.rb+2 −0
@@ -20,6 +20,8 @@ end
2020
2121 # A recursive class type
2222 class TopLevel < Dry::Struct
23+
24+ # A recursive class type
2325 attribute :top_level_next, TopLevel.optional
2426
2527 def self.from_dynamic!(d)
Mschema-rustdefault / module_under_test.rs+1 −0
@@ -16,5 +16,6 @@ use serde::{Serialize, Deserialize};
1616 /// A recursive class type
1717 #[derive(Debug, Clone, Serialize, Deserialize)]
1818 pub struct TopLevel {
19+ /// A recursive class type
1920 pub next: Option<Box<TopLevel>>,
2021 }
Mschema-scala3-upickledefault / TopLevel.scala+3 −0
@@ -69,5 +69,8 @@ end JsonExt
6969 * A recursive class type
7070 */
7171 case class TopLevel (
72+ /**
73+ * A recursive class type
74+ */
7275 val next : Option[TopLevel] = None
7376 ) derives OptionPickler.ReadWriter
Mschema-scala3default / TopLevel.scala+3 −0
@@ -11,5 +11,8 @@ type NullValue = None.type
1111 * A recursive class type
1212 */
1313 case class TopLevel (
14+ /**
15+ * A recursive class type
16+ */
1417 val next : Option[TopLevel] = None
1518 ) derives Encoder.AsObject, Decoder
Mschema-schemadefault / TopLevel.schema+2 −1
@@ -7,7 +7,8 @@
77 "additionalProperties": {},
88 "properties": {
99 "next": {
10- "$ref": "#/definitions/TopLevel"
10+ "$ref": "#/definitions/TopLevel",
11+ "description": "A recursive class type"
1112 }
1213 },
1314 "required": [],
Mschema-swiftdefault / quicktype.swift+1 −0
@@ -8,6 +8,7 @@ import Foundation
88 /// A recursive class type
99 // MARK: - TopLevel
1010 class TopLevel: Codable {
11+ /// A recursive class type
1112 let next: TopLevel?
1213
1314 enum CodingKeys: String, CodingKey {
Mschema-typescriptdefault / TopLevel.ts+3 −0
@@ -11,6 +11,9 @@
1111 * A recursive class type
1212 */
1313 export interface TopLevel {
14+ /**
15+ * A recursive class type
16+ */
1417 next?: TopLevel;
1518 [property: string]: unknown;
1619 }
Test case

test/inputs/schema/simple-ref.schema

24 generated files · +69 −3
Mschema-cjsondefault / TopLevel.h+3 −0
@@ -38,6 +38,9 @@ extern "C" {
3838 * A recursive class type
3939 */
4040 struct TopLevel {
41+ /**
42+ * A recursive class type
43+ */
4144 struct TopLevel * next;
4245 };
Mschema-cplusplusdefault / quicktype.hpp+3 −0
@@ -100,6 +100,9 @@ namespace quicktype {
100100 std::shared_ptr<TopLevel> next;
101101
102102 public:
103+ /**
104+ * A recursive class type
105+ */
103106 const std::shared_ptr<TopLevel> & get_next() const { return next; }
104107 std::shared_ptr<TopLevel> & get_mutable_next() { return next; }
105108 void set_next(const std::shared_ptr<TopLevel> & value) { this->next = value; }
Mschema-csharp-recordsdefault / QuickType.cs+3 −0
@@ -28,6 +28,9 @@ namespace QuickType
2828 /// </summary>
2929 public partial record TopLevel
3030 {
31+ /// <summary>
32+ /// A recursive class type
33+ /// </summary>
3134 [JsonProperty("next", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3235 public TopLevel? Next { get; set; }
3336 }
Mschema-csharp-SystemTextJsondefault / QuickType.cs+3 −0
@@ -25,6 +25,9 @@ namespace QuickType
2525 /// </summary>
2626 public partial class TopLevel
2727 {
28+ /// <summary>
29+ /// A recursive class type
30+ /// </summary>
2831 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2932 [JsonPropertyName("next")]
3033 public TopLevel? Next { get; set; }
Mschema-csharpdefault / QuickType.cs+3 −0
@@ -28,6 +28,9 @@ namespace QuickType
2828 /// </summary>
2929 public partial class TopLevel
3030 {
31+ /// <summary>
32+ /// A recursive class type
33+ /// </summary>
3134 [JsonProperty("next", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3235 public TopLevel? Next { get; set; }
3336 }
Mschema-elixirdefault / QuickType.ex+1 −0
@@ -8,6 +8,7 @@
88 defmodule TopLevel do
99 @moduledoc """
1010 A recursive class type
11+ - `:next` - A recursive class type
1112 """
1213
1314 defstruct [:next]
Mschema-flowdefault / TopLevel.js+3 −0
@@ -13,6 +13,9 @@
1313 * A recursive class type
1414 */
1515 export type TopLevel = {
16+ /**
17+ * A recursive class type
18+ */
1619 next?: TopLevel;
1720 [property: string]: mixed;
1821 };
Mschema-golangdefault / quicktype.go+2 −1
@@ -20,5 +20,6 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2020
2121 // A recursive class type
2222 type TopLevel struct {
23- Next *TopLevel `json:"next,omitempty"`
23+ // A recursive class type
24+ Next *TopLevel `json:"next,omitempty"`
2425 }
Mschema-haskelldefault / QuickType.hs+4 −1
@@ -12,8 +12,11 @@ import Data.ByteString.Lazy (ByteString)
1212 import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
15-{-| A recursive class type -}
15+{-| A recursive class type
1616
17+next:
18+A recursive class type
19+-}
1720 data QuickType = QuickType
1821 { nextQuickType :: Maybe QuickType
1922 } deriving (Show)
Mschema-java-datetime-legacydefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-java-lombokdefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-javadefault / src / main / java / io / quicktype / TopLevel.java+3 −0
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.annotation.*;
88 public class TopLevel {
99 private TopLevel next;
1010
11+ /**
12+ * A recursive class type
13+ */
1114 @JsonProperty("next")
1215 public TopLevel getNext() { return next; }
1316 @JsonProperty("next")
Mschema-kotlin-jacksondefault / TopLevel.kt+3 −0
@@ -22,6 +22,9 @@ val mapper = jacksonObjectMapper().apply {
2222 * A recursive class type
2323 */
2424 data class TopLevel (
25+ /**
26+ * A recursive class type
27+ */
2528 val next: TopLevel? = null
2629 ) {
2730 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlindefault / TopLevel.kt+3 −0
@@ -12,6 +12,9 @@ private val klaxon = Klaxon()
1212 * A recursive class type
1313 */
1414 data class TopLevel (
15+ /**
16+ * A recursive class type
17+ */
1518 val next: TopLevel? = null
1619 ) {
1720 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlinxdefault / TopLevel.kt+3 −0
@@ -15,5 +15,8 @@ import kotlinx.serialization.encoding.*
1515 */
1616 @Serializable
1717 data class TopLevel (
18+ /**
19+ * A recursive class type
20+ */
1821 val next: TopLevel? = null
1922 )
Mschema-phpdefault / TopLevel.php+10 −0
@@ -14,6 +14,8 @@ class TopLevel {
1414 }
1515
1616 /**
17+ * A recursive class type
18+ *
1719 * @param ?stdClass $value
1820 * @throws Exception
1921 * @return ?TopLevel
@@ -27,6 +29,8 @@ class TopLevel {
2729 }
2830
2931 /**
32+ * A recursive class type
33+ *
3034 * @throws Exception
3135 * @return ?stdClass
3236 */
@@ -42,6 +46,8 @@ class TopLevel {
4246 }
4347
4448 /**
49+ * A recursive class type
50+ *
4551 * @param TopLevel|null
4652 * @return bool
4753 * @throws Exception
@@ -54,6 +60,8 @@ class TopLevel {
5460 }
5561
5662 /**
63+ * A recursive class type
64+ *
5765 * @throws Exception
5866 * @return ?TopLevel
5967 */
@@ -65,6 +73,8 @@ class TopLevel {
6573 }
6674
6775 /**
76+ * A recursive class type
77+ *
6878 * @return ?TopLevel
6979 */
7080 public static function sampleNext(): ?TopLevel {
Mschema-pythondefault / quicktype.py+1 −0
@@ -29,6 +29,7 @@ class TopLevel:
2929 """A recursive class type"""
3030
3131 next: 'TopLevel | None' = None
32+ """A recursive class type"""
3233
3334 @staticmethod
3435 def from_dict(obj: Any) -> 'TopLevel':
Mschema-rubydefault / TopLevel.rb+2 −0
@@ -20,6 +20,8 @@ end
2020
2121 # A recursive class type
2222 class TopLevel < Dry::Struct
23+
24+ # A recursive class type
2325 attribute :top_level_next, TopLevel.optional
2426
2527 def self.from_dynamic!(d)
Mschema-rustdefault / module_under_test.rs+1 −0
@@ -16,5 +16,6 @@ use serde::{Serialize, Deserialize};
1616 /// A recursive class type
1717 #[derive(Debug, Clone, Serialize, Deserialize)]
1818 pub struct TopLevel {
19+ /// A recursive class type
1920 pub next: Option<Box<TopLevel>>,
2021 }
Mschema-scala3-upickledefault / TopLevel.scala+3 −0
@@ -69,5 +69,8 @@ end JsonExt
6969 * A recursive class type
7070 */
7171 case class TopLevel (
72+ /**
73+ * A recursive class type
74+ */
7275 val next : Option[TopLevel] = None
7376 ) derives OptionPickler.ReadWriter
Mschema-scala3default / TopLevel.scala+3 −0
@@ -11,5 +11,8 @@ type NullValue = None.type
1111 * A recursive class type
1212 */
1313 case class TopLevel (
14+ /**
15+ * A recursive class type
16+ */
1417 val next : Option[TopLevel] = None
1518 ) derives Encoder.AsObject, Decoder
Mschema-schemadefault / TopLevel.schema+2 −1
@@ -7,7 +7,8 @@
77 "additionalProperties": {},
88 "properties": {
99 "next": {
10- "$ref": "#/definitions/TopLevel"
10+ "$ref": "#/definitions/TopLevel",
11+ "description": "A recursive class type"
1112 }
1213 },
1314 "required": [],
Mschema-swiftdefault / quicktype.swift+1 −0
@@ -8,6 +8,7 @@ import Foundation
88 /// A recursive class type
99 // MARK: - TopLevel
1010 class TopLevel: Codable {
11+ /// A recursive class type
1112 let next: TopLevel?
1213
1314 enum CodingKeys: String, CodingKey {
Mschema-typescriptdefault / TopLevel.ts+3 −0
@@ -11,6 +11,9 @@
1111 * A recursive class type
1212 */
1313 export interface TopLevel {
14+ /**
15+ * A recursive class type
16+ */
1417 next?: TopLevel;
1518 [property: string]: unknown;
1619 }
Test case

test/inputs/schema/vega-lite.schema

1 generated file · +5 −5
Mschema-schemadefault / TopLevel.schema+5 −5
@@ -270,7 +270,7 @@
270270 "additionalProperties": {
271271 "$ref": "#/definitions/VGMarkConfig"
272272 },
273- "description": "An object hash that defines key-value mappings to determine default properties for marks with a given [style](mark.html#mark-def). The keys represent styles names; the value are valid [mark configuration objects](mark.html#config). "
273+ "description": "An object hash that defines key-value mappings to determine default properties for marks\nwith a given [style](mark.html#mark-def). The keys represent styles names; the value are\nvalid [mark configuration objects](mark.html#config)."
274274 },
275275 "text": {
276276 "$ref": "#/definitions/TextConfig",
@@ -2871,7 +2871,7 @@
28712871 "type": "null"
28722872 }
28732873 ],
2874- "description": "The sort order. One of `\"ascending\"` (default) or `\"descending\"`.\nSort order for a facet field.\nThis can be `\"ascending\"`, `\"descending\"`."
2874+ "description": "The sort order. One of `\"ascending\"` (default) or `\"descending\"`."
28752875 }
28762876 },
28772877 "required": [
@@ -2908,7 +2908,7 @@
29082908 "type": "null"
29092909 }
29102910 ],
2911- "description": "The sort order. One of `\"ascending\"` (default) or `\"descending\"`.\nSort order for a facet field.\nThis can be `\"ascending\"`, `\"descending\"`."
2911+ "description": "Sort order for a facet field.\nThis can be `\"ascending\"`, `\"descending\"`."
29122912 },
29132913 "timeUnit": {
29142914 "$ref": "#/definitions/TimeUnit",
@@ -3087,7 +3087,7 @@
30873087 "type": "null"
30883088 }
30893089 ],
3090- "description": "The sort order. One of `\"ascending\"` (default) or `\"descending\"`.\nSort order for a facet field.\nThis can be `\"ascending\"`, `\"descending\"`."
3090+ "description": "The sort order. One of `\"ascending\"` (default) or `\"descending\"`."
30913091 },
30923092 "timeUnit": {
30933093 "$ref": "#/definitions/TimeUnit",
@@ -3231,7 +3231,7 @@
32313231 "type": "null"
32323232 }
32333233 ],
3234- "description": "Type of stacking offset if the field should be stacked.\n`stack` is only applicable for `x` and `y` channels with continuous domains.\nFor example, `stack` of `y` can be used to customize stacking for a vertical bar chart.\n\n`stack` can be one of the following values:\n\n- `\"zero\"`: stacking with baseline offset at zero value of the scale (for creating typical stacked [bar](stack.html#bar) and [area](stack.html#area) chart).\n- `\"normalize\"` - stacking with normalized domain (for creating [normalized stacked bar and area charts](stack.html#normalized). <br/>\n- `\"center\"` - stacking with center baseline (for [streamgraph](stack.html#streamgraph)).\n- `null` - No-stacking. This will produce layered [bar](stack.html#layered-bar-chart) and area chart.\n\n__Default value:__ `zero` for plots with all of the following conditions are true:\n\n1. The mark is `bar` or `area`;\n2. The stacked measure channel (x or y) has a linear scale;\n3. At least one of non-position channels mapped to an unaggregated field that is different from x and y. Otherwise, `null` by default."
3234+ "description": "Type of stacking offset if the field should be stacked.\n`stack` is only applicable for `x` and `y` channels with continuous domains.\nFor example, `stack` of `y` can be used to customize stacking for a vertical bar chart.\n\n`stack` can be one of the following values:\n\n- `\"zero\"`: stacking with baseline offset at zero value of the scale (for creating\ntypical stacked [bar](stack.html#bar) and [area](stack.html#area) chart).\n- `\"normalize\"` - stacking with normalized domain (for creating [normalized stacked bar\nand area charts](stack.html#normalized). <br/>\n- `\"center\"` - stacking with center baseline (for [streamgraph](stack.html#streamgraph)).\n- `null` - No-stacking. This will produce layered [bar](stack.html#layered-bar-chart) and\narea chart.\n\n__Default value:__ `zero` for plots with all of the following conditions are true:\n\n1. The mark is `bar` or `area`;\n2. The stacked measure channel (x or y) has a linear scale;\n3. At least one of non-position channels mapped to an unaggregated field that is\ndifferent from x and y. Otherwise, `null` by default."
32353235 },
32363236 "timeUnit": {
32373237 "$ref": "#/definitions/TimeUnit",
No generated files match these filters.