Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
66test cases
66files differ
66modified
0new
0deleted
2,944changed lines
+2,573 −371insertions / deletions
Base 645f27f9243d1d896ac7bb5534fae9bd63c5b0d4 · PR merge b4e9404a33a0dd360d24a85615489a41841a56be · Head 32029f6aa1ca60cd4eb6e2ef0cfe96ef08ed3460 · raw patch
Test case

test/inputs/graphql/github6.graphql

1 generated file · +7 −1
Mgraphql-elixirdefault / QuickType.ex+7 −1
@@ -20,10 +20,16 @@ defmodule UniformResourceLocatable do
2020 def encode_url(value) when is_binary(value), do: value
2121 def encode_url(_), do: {:error, "Unexpected type when encoding UniformResourceLocatable.url"}
2222
23+ def decode_login(value) when is_binary(value), do: value
24+ def decode_login(_), do: {:error, "Unexpected type when decoding UniformResourceLocatable.login"}
25+
26+ def encode_login(value) when is_binary(value), do: value
27+ def encode_login(_), do: {:error, "Unexpected type when encoding UniformResourceLocatable.login"}
28+
2329 def from_map(m) do
2430 %UniformResourceLocatable{
2531 url: decode_url(m["url"]),
26- login: m["login"],
32+ login: m["login"] && decode_login(m["login"]),
2733 }
2834 end
Test case

test/inputs/graphql/github8.graphql

1 generated file · +7 −1
Mgraphql-elixirdefault / QuickType.ex+7 −1
@@ -60,9 +60,15 @@ defmodule IssueOrPullRequest do
6060 merged: boolean() | nil
6161 }
6262
63+ def decode_title(value) when is_binary(value), do: value
64+ def decode_title(_), do: {:error, "Unexpected type when decoding IssueOrPullRequest.title"}
65+
66+ def encode_title(value) when is_binary(value), do: value
67+ def encode_title(_), do: {:error, "Unexpected type when encoding IssueOrPullRequest.title"}
68+
6369 def from_map(m) do
6470 %IssueOrPullRequest{
65- title: m["title"],
71+ title: m["title"] && decode_title(m["title"]),
6672 state: m["state"] && IssueState.decode(m["state"]),
6773 merged: m["merged"],
6874 }
Test case

test/inputs/json/misc/0a91a.json

1 generated file · +56 −8
Melixirdefault / QuickType.ex+56 −8
@@ -24,6 +24,12 @@ defmodule Actor do
2424 def encode_avatar_url(value) when is_binary(value), do: value
2525 def encode_avatar_url(_), do: {:error, "Unexpected type when encoding Actor.avatar_url"}
2626
27+ def decode_display_login(value) when is_binary(value), do: value
28+ def decode_display_login(_), do: {:error, "Unexpected type when decoding Actor.display_login"}
29+
30+ def encode_display_login(value) when is_binary(value), do: value
31+ def encode_display_login(_), do: {:error, "Unexpected type when encoding Actor.display_login"}
32+
2733 def decode_gravatar_id(value) when is_binary(value), do: value
2834 def decode_gravatar_id(_), do: {:error, "Unexpected type when decoding Actor.gravatar_id"}
2935
@@ -51,7 +57,7 @@ defmodule Actor do
5157 def from_map(m) do
5258 %Actor{
5359 avatar_url: decode_avatar_url(m["avatar_url"]),
54- display_login: m["display_login"],
60+ display_login: m["display_login"] && decode_display_login(m["display_login"]),
5561 gravatar_id: decode_gravatar_id(m["gravatar_id"]),
5662 id: decode_id(m["id"]),
5763 login: decode_login(m["login"]),
@@ -1573,21 +1579,63 @@ defmodule Payload do
15731579 size: integer() | nil
15741580 }
15751581
1582+ def decode_action(value) when is_binary(value), do: value
1583+ def decode_action(_), do: {:error, "Unexpected type when decoding Payload.action"}
1584+
1585+ def encode_action(value) when is_binary(value), do: value
1586+ def encode_action(_), do: {:error, "Unexpected type when encoding Payload.action"}
1587+
1588+ def decode_before(value) when is_binary(value), do: value
1589+ def decode_before(_), do: {:error, "Unexpected type when decoding Payload.before"}
1590+
1591+ def encode_before(value) when is_binary(value), do: value
1592+ def encode_before(_), do: {:error, "Unexpected type when encoding Payload.before"}
1593+
1594+ def decode_head(value) when is_binary(value), do: value
1595+ def decode_head(_), do: {:error, "Unexpected type when decoding Payload.head"}
1596+
1597+ def encode_head(value) when is_binary(value), do: value
1598+ def encode_head(_), do: {:error, "Unexpected type when encoding Payload.head"}
1599+
1600+ def decode_master_branch(value) when is_binary(value), do: value
1601+ def decode_master_branch(_), do: {:error, "Unexpected type when decoding Payload.master_branch"}
1602+
1603+ def encode_master_branch(value) when is_binary(value), do: value
1604+ def encode_master_branch(_), do: {:error, "Unexpected type when encoding Payload.master_branch"}
1605+
1606+ def decode_pusher_type(value) when is_binary(value), do: value
1607+ def decode_pusher_type(_), do: {:error, "Unexpected type when decoding Payload.pusher_type"}
1608+
1609+ def encode_pusher_type(value) when is_binary(value), do: value
1610+ def encode_pusher_type(_), do: {:error, "Unexpected type when encoding Payload.pusher_type"}
1611+
1612+ def decode_ref(value) when is_binary(value), do: value
1613+ def decode_ref(_), do: {:error, "Unexpected type when decoding Payload.ref"}
1614+
1615+ def encode_ref(value) when is_binary(value), do: value
1616+ def encode_ref(_), do: {:error, "Unexpected type when encoding Payload.ref"}
1617+
1618+ def decode_ref_type(value) when is_binary(value), do: value
1619+ def decode_ref_type(_), do: {:error, "Unexpected type when decoding Payload.ref_type"}
1620+
1621+ def encode_ref_type(value) when is_binary(value), do: value
1622+ def encode_ref_type(_), do: {:error, "Unexpected type when encoding Payload.ref_type"}
1623+
15761624 def from_map(m) do
15771625 %Payload{
1578- action: m["action"],
1579- before: m["before"],
1626+ action: m["action"] && decode_action(m["action"]),
1627+ before: m["before"] && decode_before(m["before"]),
15801628 commits: m["commits"] && Enum.map(m["commits"], &Commit.from_map/1),
15811629 description: m["description"],
15821630 distinct_size: m["distinct_size"],
1583- head: m["head"],
1584- master_branch: m["master_branch"],
1631+ head: m["head"] && decode_head(m["head"]),
1632+ master_branch: m["master_branch"] && decode_master_branch(m["master_branch"]),
15851633 number: m["number"],
15861634 pull_request: m["pull_request"] && PullRequest.from_map(m["pull_request"]),
15871635 push_id: m["push_id"],
1588- pusher_type: m["pusher_type"],
1589- ref: m["ref"],
1590- ref_type: m["ref_type"],
1636+ pusher_type: m["pusher_type"] && decode_pusher_type(m["pusher_type"]),
1637+ ref: m["ref"] && decode_ref(m["ref"]),
1638+ ref_type: m["ref_type"] && decode_ref_type(m["ref_type"]),
15911639 size: m["size"],
15921640 }
15931641 end
Test case

test/inputs/json/misc/0cffa.json

1 generated file · +35 −5
Melixirdefault / QuickType.ex+35 −5
@@ -22,6 +22,12 @@ defmodule The480_WStill do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding The480_WStill.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding The480_WStill.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding The480_WStill.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding The480_WStill.url"}
2733
@@ -37,7 +43,7 @@ defmodule The480_WStill do
3743 def from_map(m) do
3844 %The480_WStill{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -148,12 +154,36 @@ defmodule FixedHeight do
148154 width: String.t()
149155 }
150156
157+ def decode_frames(value) when is_binary(value), do: value
158+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
159+
160+ def encode_frames(value) when is_binary(value), do: value
161+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
162+
163+ def decode_hash(value) when is_binary(value), do: value
164+ def decode_hash(_), do: {:error, "Unexpected type when decoding FixedHeight.hash"}
165+
166+ def encode_hash(value) when is_binary(value), do: value
167+ def encode_hash(_), do: {:error, "Unexpected type when encoding FixedHeight.hash"}
168+
151169 def decode_height(value) when is_binary(value), do: value
152170 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
153171
154172 def encode_height(value) when is_binary(value), do: value
155173 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
156174
175+ def decode_mp4(value) when is_binary(value), do: value
176+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
177+
178+ def encode_mp4(value) when is_binary(value), do: value
179+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
180+
181+ def decode_mp4_size(value) when is_binary(value), do: value
182+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
183+
184+ def encode_mp4_size(value) when is_binary(value), do: value
185+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
186+
157187 def decode_size(value) when is_binary(value), do: value
158188 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
159189
@@ -186,11 +216,11 @@ defmodule FixedHeight do
186216
187217 def from_map(m) do
188218 %FixedHeight{
189- frames: m["frames"],
190- hash: m["hash"],
219+ frames: m["frames"] && decode_frames(m["frames"]),
220+ hash: m["hash"] && decode_hash(m["hash"]),
191221 height: decode_height(m["height"]),
192- mp4: m["mp4"],
193- mp4_size: m["mp4_size"],
222+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
223+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
194224 size: decode_size(m["size"]),
195225 url: decode_url(m["url"]),
196226 webp: decode_webp(m["webp"]),
Test case

test/inputs/json/misc/127a1.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -22,6 +22,12 @@ defmodule The480_WStill do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding The480_WStill.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding The480_WStill.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding The480_WStill.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding The480_WStill.url"}
2733
@@ -37,7 +43,7 @@ defmodule The480_WStill do
3743 def from_map(m) do
3844 %The480_WStill{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -148,12 +154,36 @@ defmodule FixedHeight do
148154 width: String.t()
149155 }
150156
157+ def decode_frames(value) when is_binary(value), do: value
158+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
159+
160+ def encode_frames(value) when is_binary(value), do: value
161+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
162+
163+ def decode_hash(value) when is_binary(value), do: value
164+ def decode_hash(_), do: {:error, "Unexpected type when decoding FixedHeight.hash"}
165+
166+ def encode_hash(value) when is_binary(value), do: value
167+ def encode_hash(_), do: {:error, "Unexpected type when encoding FixedHeight.hash"}
168+
151169 def decode_height(value) when is_binary(value), do: value
152170 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
153171
154172 def encode_height(value) when is_binary(value), do: value
155173 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
156174
175+ def decode_mp4(value) when is_binary(value), do: value
176+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
177+
178+ def encode_mp4(value) when is_binary(value), do: value
179+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
180+
181+ def decode_mp4_size(value) when is_binary(value), do: value
182+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
183+
184+ def encode_mp4_size(value) when is_binary(value), do: value
185+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
186+
157187 def decode_size(value) when is_binary(value), do: value
158188 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
159189
@@ -186,11 +216,11 @@ defmodule FixedHeight do
186216
187217 def from_map(m) do
188218 %FixedHeight{
189- frames: m["frames"],
190- hash: m["hash"],
219+ frames: m["frames"] && decode_frames(m["frames"]),
220+ hash: m["hash"] && decode_hash(m["hash"]),
191221 height: decode_height(m["height"]),
192- mp4: m["mp4"],
193- mp4_size: m["mp4_size"],
222+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
223+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
194224 size: decode_size(m["size"]),
195225 url: decode_url(m["url"]),
196226 webp: decode_webp(m["webp"]),
@@ -549,13 +579,19 @@ defmodule User do
549579 def encode_profile_url(value) when is_binary(value), do: value
550580 def encode_profile_url(_), do: {:error, "Unexpected type when encoding User.profile_url"}
551581
582+ def decode_twitter(value) when is_binary(value), do: value
583+ def decode_twitter(_), do: {:error, "Unexpected type when decoding User.twitter"}
584+
585+ def encode_twitter(value) when is_binary(value), do: value
586+ def encode_twitter(_), do: {:error, "Unexpected type when encoding User.twitter"}
587+
552588 def from_map(m) do
553589 %User{
554590 avatar_url: decode_avatar_url(m["avatar_url"]),
555591 banner_url: decode_banner_url(m["banner_url"]),
556592 display_name: decode_display_name(m["display_name"]),
557593 profile_url: decode_profile_url(m["profile_url"]),
558- twitter: m["twitter"],
594+ twitter: m["twitter"] && decode_twitter(m["twitter"]),
559595 username: Username.decode(m["username"]),
560596 }
561597 end
Test case

test/inputs/json/misc/176f1.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -13,10 +13,22 @@ defmodule Footnote do
1313 text: String.t() | nil
1414 }
1515
16+ def decode_code(value) when is_binary(value), do: value
17+ def decode_code(_), do: {:error, "Unexpected type when decoding Footnote.code"}
18+
19+ def encode_code(value) when is_binary(value), do: value
20+ def encode_code(_), do: {:error, "Unexpected type when encoding Footnote.code"}
21+
22+ def decode_text(value) when is_binary(value), do: value
23+ def decode_text(_), do: {:error, "Unexpected type when decoding Footnote.text"}
24+
25+ def encode_text(value) when is_binary(value), do: value
26+ def encode_text(_), do: {:error, "Unexpected type when encoding Footnote.text"}
27+
1628 def from_map(m) do
1729 %Footnote{
18- code: m["code"],
19- text: m["text"],
30+ code: m["code"] && decode_code(m["code"]),
31+ text: m["text"] && decode_text(m["text"]),
2032 }
2133 end
Test case

test/inputs/json/misc/1b409.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -80,19 +80,31 @@ defmodule Extra do
8080 def encode_address(value) when is_binary(value), do: value
8181 def encode_address(_), do: {:error, "Unexpected type when encoding Extra.address"}
8282
83+ def decode_contact_form(value) when is_binary(value), do: value
84+ def decode_contact_form(_), do: {:error, "Unexpected type when decoding Extra.contact_form"}
85+
86+ def encode_contact_form(value) when is_binary(value), do: value
87+ def encode_contact_form(_), do: {:error, "Unexpected type when encoding Extra.contact_form"}
88+
8389 def decode_office(value) when is_binary(value), do: value
8490 def decode_office(_), do: {:error, "Unexpected type when decoding Extra.office"}
8591
8692 def encode_office(value) when is_binary(value), do: value
8793 def encode_office(_), do: {:error, "Unexpected type when encoding Extra.office"}
8894
95+ def decode_rss_url(value) when is_binary(value), do: value
96+ def decode_rss_url(_), do: {:error, "Unexpected type when decoding Extra.rss_url"}
97+
98+ def encode_rss_url(value) when is_binary(value), do: value
99+ def encode_rss_url(_), do: {:error, "Unexpected type when encoding Extra.rss_url"}
100+
89101 def from_map(m) do
90102 %Extra{
91103 address: decode_address(m["address"]),
92- contact_form: m["contact_form"],
104+ contact_form: m["contact_form"] && decode_contact_form(m["contact_form"]),
93105 fax: m["fax"],
94106 office: decode_office(m["office"]),
95- rss_url: m["rss_url"],
107+ rss_url: m["rss_url"] && decode_rss_url(m["rss_url"]),
96108 }
97109 end
Test case

test/inputs/json/misc/26b49.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -22,6 +22,12 @@ defmodule The480_WStill do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding The480_WStill.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding The480_WStill.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding The480_WStill.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding The480_WStill.url"}
2733
@@ -37,7 +43,7 @@ defmodule The480_WStill do
3743 def from_map(m) do
3844 %The480_WStill{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -148,12 +154,36 @@ defmodule FixedHeight do
148154 width: String.t()
149155 }
150156
157+ def decode_frames(value) when is_binary(value), do: value
158+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
159+
160+ def encode_frames(value) when is_binary(value), do: value
161+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
162+
163+ def decode_hash(value) when is_binary(value), do: value
164+ def decode_hash(_), do: {:error, "Unexpected type when decoding FixedHeight.hash"}
165+
166+ def encode_hash(value) when is_binary(value), do: value
167+ def encode_hash(_), do: {:error, "Unexpected type when encoding FixedHeight.hash"}
168+
151169 def decode_height(value) when is_binary(value), do: value
152170 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
153171
154172 def encode_height(value) when is_binary(value), do: value
155173 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
156174
175+ def decode_mp4(value) when is_binary(value), do: value
176+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
177+
178+ def encode_mp4(value) when is_binary(value), do: value
179+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
180+
181+ def decode_mp4_size(value) when is_binary(value), do: value
182+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
183+
184+ def encode_mp4_size(value) when is_binary(value), do: value
185+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
186+
157187 def decode_size(value) when is_binary(value), do: value
158188 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
159189
@@ -186,11 +216,11 @@ defmodule FixedHeight do
186216
187217 def from_map(m) do
188218 %FixedHeight{
189- frames: m["frames"],
190- hash: m["hash"],
219+ frames: m["frames"] && decode_frames(m["frames"]),
220+ hash: m["hash"] && decode_hash(m["hash"]),
191221 height: decode_height(m["height"]),
192- mp4: m["mp4"],
193- mp4_size: m["mp4_size"],
222+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
223+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
194224 size: decode_size(m["size"]),
195225 url: decode_url(m["url"]),
196226 webp: decode_webp(m["webp"]),
@@ -507,6 +537,12 @@ defmodule User do
507537 def encode_profile_url(value) when is_binary(value), do: value
508538 def encode_profile_url(_), do: {:error, "Unexpected type when encoding User.profile_url"}
509539
540+ def decode_twitter(value) when is_binary(value), do: value
541+ def decode_twitter(_), do: {:error, "Unexpected type when decoding User.twitter"}
542+
543+ def encode_twitter(value) when is_binary(value), do: value
544+ def encode_twitter(_), do: {:error, "Unexpected type when encoding User.twitter"}
545+
510546 def decode_username(value) when is_binary(value), do: value
511547 def decode_username(_), do: {:error, "Unexpected type when decoding User.username"}
512548
@@ -519,7 +555,7 @@ defmodule User do
519555 banner_url: decode_banner_url(m["banner_url"]),
520556 display_name: decode_display_name(m["display_name"]),
521557 profile_url: decode_profile_url(m["profile_url"]),
522- twitter: m["twitter"],
558+ twitter: m["twitter"] && decode_twitter(m["twitter"]),
523559 username: decode_username(m["username"]),
524560 }
525561 end
Test case

test/inputs/json/misc/26c9c.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -67,6 +67,12 @@ defmodule CachedContents do
6767 top: [Top.t()]
6868 }
6969
70+ def decode_average(value) when is_binary(value), do: value
71+ def decode_average(_), do: {:error, "Unexpected type when decoding CachedContents.average"}
72+
73+ def encode_average(value) when is_binary(value), do: value
74+ def encode_average(_), do: {:error, "Unexpected type when encoding CachedContents.average"}
75+
7076 def decode_largest(value) when is_binary(value), do: value
7177 def decode_largest(_), do: {:error, "Unexpected type when decoding CachedContents.largest"}
7278
@@ -91,6 +97,12 @@ defmodule CachedContents do
9197 def encode_smallest(value) when is_binary(value), do: value
9298 def encode_smallest(_), do: {:error, "Unexpected type when encoding CachedContents.smallest"}
9399
100+ def decode_sum(value) when is_binary(value), do: value
101+ def decode_sum(_), do: {:error, "Unexpected type when decoding CachedContents.sum"}
102+
103+ def encode_sum(value) when is_binary(value), do: value
104+ def encode_sum(_), do: {:error, "Unexpected type when encoding CachedContents.sum"}
105+
94106 def decode_top(value) when is_list(value), do: value
95107 def decode_top(_), do: {:error, "Unexpected type when decoding CachedContents.top"}
96108
@@ -99,12 +111,12 @@ defmodule CachedContents do
99111
100112 def from_map(m) do
101113 %CachedContents{
102- average: m["average"],
114+ average: m["average"] && decode_average(m["average"]),
103115 largest: decode_largest(m["largest"]),
104116 non_null: decode_non_null(m["non_null"]),
105117 null: decode_null(m["null"]),
106118 smallest: decode_smallest(m["smallest"]),
107- sum: m["sum"],
119+ sum: m["sum"] && decode_sum(m["sum"]),
108120 top: Enum.map(m["top"], &Top.from_map/1),
109121 }
110122 end
@@ -144,12 +156,36 @@ defmodule Format do
144156 view: String.t() | nil
145157 }
146158
159+ def decode_align(value) when is_binary(value), do: value
160+ def decode_align(_), do: {:error, "Unexpected type when decoding Format.align"}
161+
162+ def encode_align(value) when is_binary(value), do: value
163+ def encode_align(_), do: {:error, "Unexpected type when encoding Format.align"}
164+
165+ def decode_no_commas(value) when is_binary(value), do: value
166+ def decode_no_commas(_), do: {:error, "Unexpected type when decoding Format.no_commas"}
167+
168+ def encode_no_commas(value) when is_binary(value), do: value
169+ def encode_no_commas(_), do: {:error, "Unexpected type when encoding Format.no_commas"}
170+
171+ def decode_precision_style(value) when is_binary(value), do: value
172+ def decode_precision_style(_), do: {:error, "Unexpected type when decoding Format.precision_style"}
173+
174+ def encode_precision_style(value) when is_binary(value), do: value
175+ def encode_precision_style(_), do: {:error, "Unexpected type when encoding Format.precision_style"}
176+
177+ def decode_view(value) when is_binary(value), do: value
178+ def decode_view(_), do: {:error, "Unexpected type when decoding Format.view"}
179+
180+ def encode_view(value) when is_binary(value), do: value
181+ def encode_view(_), do: {:error, "Unexpected type when encoding Format.view"}
182+
147183 def from_map(m) do
148184 %Format{
149- align: m["align"],
150- no_commas: m["noCommas"],
151- precision_style: m["precisionStyle"],
152- view: m["view"],
185+ align: m["align"] && decode_align(m["align"]),
186+ no_commas: m["noCommas"] && decode_no_commas(m["noCommas"]),
187+ precision_style: m["precisionStyle"] && decode_precision_style(m["precisionStyle"]),
188+ view: m["view"] && decode_view(m["view"]),
153189 }
154190 end
Test case

test/inputs/json/misc/27332.json

1 generated file · +7 −1
Melixirdefault / QuickType.ex+7 −1
@@ -237,9 +237,15 @@ defmodule MediaEmbed do
237237 width: integer() | nil
238238 }
239239
240+ def decode_content(value) when is_binary(value), do: value
241+ def decode_content(_), do: {:error, "Unexpected type when decoding MediaEmbed.content"}
242+
243+ def encode_content(value) when is_binary(value), do: value
244+ def encode_content(_), do: {:error, "Unexpected type when encoding MediaEmbed.content"}
245+
240246 def from_map(m) do
241247 %MediaEmbed{
242- content: m["content"],
248+ content: m["content"] && decode_content(m["content"]),
243249 height: m["height"],
244250 scrolling: m["scrolling"],
245251 width: m["width"],
Test case

test/inputs/json/misc/2d4e2.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -133,19 +133,31 @@ defmodule Extra do
133133 def encode_contact_form(value) when is_binary(value), do: value
134134 def encode_contact_form(_), do: {:error, "Unexpected type when encoding Extra.contact_form"}
135135
136+ def decode_fax(value) when is_binary(value), do: value
137+ def decode_fax(_), do: {:error, "Unexpected type when decoding Extra.fax"}
138+
139+ def encode_fax(value) when is_binary(value), do: value
140+ def encode_fax(_), do: {:error, "Unexpected type when encoding Extra.fax"}
141+
136142 def decode_office(value) when is_binary(value), do: value
137143 def decode_office(_), do: {:error, "Unexpected type when decoding Extra.office"}
138144
139145 def encode_office(value) when is_binary(value), do: value
140146 def encode_office(_), do: {:error, "Unexpected type when encoding Extra.office"}
141147
148+ def decode_rss_url(value) when is_binary(value), do: value
149+ def decode_rss_url(_), do: {:error, "Unexpected type when decoding Extra.rss_url"}
150+
151+ def encode_rss_url(value) when is_binary(value), do: value
152+ def encode_rss_url(_), do: {:error, "Unexpected type when encoding Extra.rss_url"}
153+
142154 def from_map(m) do
143155 %Extra{
144156 address: decode_address(m["address"]),
145157 contact_form: decode_contact_form(m["contact_form"]),
146- fax: m["fax"],
158+ fax: m["fax"] && decode_fax(m["fax"]),
147159 office: decode_office(m["office"]),
148- rss_url: m["rss_url"],
160+ rss_url: m["rss_url"] && decode_rss_url(m["rss_url"]),
149161 }
150162 end
Test case

test/inputs/json/misc/33d2e.json

1 generated file · +105 −15
Melixirdefault / QuickType.ex+105 −15
@@ -61,11 +61,29 @@ defmodule AffiliationClass do
6161 name: String.t() | nil
6262 }
6363
64+ def decode_city(value) when is_binary(value), do: value
65+ def decode_city(_), do: {:error, "Unexpected type when decoding AffiliationClass.city"}
66+
67+ def encode_city(value) when is_binary(value), do: value
68+ def encode_city(_), do: {:error, "Unexpected type when encoding AffiliationClass.city"}
69+
70+ def decode_country(value) when is_binary(value), do: value
71+ def decode_country(_), do: {:error, "Unexpected type when decoding AffiliationClass.country"}
72+
73+ def encode_country(value) when is_binary(value), do: value
74+ def encode_country(_), do: {:error, "Unexpected type when encoding AffiliationClass.country"}
75+
76+ def decode_name(value) when is_binary(value), do: value
77+ def decode_name(_), do: {:error, "Unexpected type when decoding AffiliationClass.name"}
78+
79+ def encode_name(value) when is_binary(value), do: value
80+ def encode_name(_), do: {:error, "Unexpected type when encoding AffiliationClass.name"}
81+
6482 def from_map(m) do
6583 %AffiliationClass{
66- city: m["city"],
67- country: m["country"],
68- name: m["name"],
84+ city: m["city"] && decode_city(m["city"]),
85+ country: m["country"] && decode_country(m["country"]),
86+ name: m["name"] && decode_name(m["name"]),
6987 }
7088 end
7189
@@ -167,14 +185,38 @@ defmodule Prize do
167185 def encode_affiliations_element(value) when is_list(value), do: value
168186 def encode_affiliations_element(_), do: {:error, "Unexpected type when encoding Prize.affiliations"}
169187
188+ def decode_motivation(value) when is_binary(value), do: value
189+ def decode_motivation(_), do: {:error, "Unexpected type when decoding Prize.motivation"}
190+
191+ def encode_motivation(value) when is_binary(value), do: value
192+ def encode_motivation(_), do: {:error, "Unexpected type when encoding Prize.motivation"}
193+
194+ def decode_overall_motivation(value) when is_binary(value), do: value
195+ def decode_overall_motivation(_), do: {:error, "Unexpected type when decoding Prize.overall_motivation"}
196+
197+ def encode_overall_motivation(value) when is_binary(value), do: value
198+ def encode_overall_motivation(_), do: {:error, "Unexpected type when encoding Prize.overall_motivation"}
199+
200+ def decode_share(value) when is_binary(value), do: value
201+ def decode_share(_), do: {:error, "Unexpected type when decoding Prize.share"}
202+
203+ def encode_share(value) when is_binary(value), do: value
204+ def encode_share(_), do: {:error, "Unexpected type when encoding Prize.share"}
205+
206+ def decode_year(value) when is_binary(value), do: value
207+ def decode_year(_), do: {:error, "Unexpected type when decoding Prize.year"}
208+
209+ def encode_year(value) when is_binary(value), do: value
210+ def encode_year(_), do: {:error, "Unexpected type when encoding Prize.year"}
211+
170212 def from_map(m) do
171213 %Prize{
172214 affiliations: Enum.map(m["affiliations"], &decode_affiliations_element/1),
173215 category: m["category"] && Category.decode(m["category"]),
174- motivation: m["motivation"],
175- overall_motivation: m["overallMotivation"],
176- share: m["share"],
177- year: m["year"],
216+ motivation: m["motivation"] && decode_motivation(m["motivation"]),
217+ overall_motivation: m["overallMotivation"] && decode_overall_motivation(m["overallMotivation"]),
218+ share: m["share"] && decode_share(m["share"]),
219+ year: m["year"] && decode_year(m["year"]),
178220 }
179221 end
180222
@@ -228,12 +270,54 @@ defmodule Laureate do
228270 def encode_born(value) when is_binary(value), do: value
229271 def encode_born(_), do: {:error, "Unexpected type when encoding Laureate.born"}
230272
273+ def decode_born_city(value) when is_binary(value), do: value
274+ def decode_born_city(_), do: {:error, "Unexpected type when decoding Laureate.born_city"}
275+
276+ def encode_born_city(value) when is_binary(value), do: value
277+ def encode_born_city(_), do: {:error, "Unexpected type when encoding Laureate.born_city"}
278+
279+ def decode_born_country(value) when is_binary(value), do: value
280+ def decode_born_country(_), do: {:error, "Unexpected type when decoding Laureate.born_country"}
281+
282+ def encode_born_country(value) when is_binary(value), do: value
283+ def encode_born_country(_), do: {:error, "Unexpected type when encoding Laureate.born_country"}
284+
285+ def decode_born_country_code(value) when is_binary(value), do: value
286+ def decode_born_country_code(_), do: {:error, "Unexpected type when decoding Laureate.born_country_code"}
287+
288+ def encode_born_country_code(value) when is_binary(value), do: value
289+ def encode_born_country_code(_), do: {:error, "Unexpected type when encoding Laureate.born_country_code"}
290+
231291 def decode_died(value) when is_binary(value), do: value
232292 def decode_died(_), do: {:error, "Unexpected type when decoding Laureate.died"}
233293
234294 def encode_died(value) when is_binary(value), do: value
235295 def encode_died(_), do: {:error, "Unexpected type when encoding Laureate.died"}
236296
297+ def decode_died_city(value) when is_binary(value), do: value
298+ def decode_died_city(_), do: {:error, "Unexpected type when decoding Laureate.died_city"}
299+
300+ def encode_died_city(value) when is_binary(value), do: value
301+ def encode_died_city(_), do: {:error, "Unexpected type when encoding Laureate.died_city"}
302+
303+ def decode_died_country(value) when is_binary(value), do: value
304+ def decode_died_country(_), do: {:error, "Unexpected type when decoding Laureate.died_country"}
305+
306+ def encode_died_country(value) when is_binary(value), do: value
307+ def encode_died_country(_), do: {:error, "Unexpected type when encoding Laureate.died_country"}
308+
309+ def decode_died_country_code(value) when is_binary(value), do: value
310+ def decode_died_country_code(_), do: {:error, "Unexpected type when decoding Laureate.died_country_code"}
311+
312+ def encode_died_country_code(value) when is_binary(value), do: value
313+ def encode_died_country_code(_), do: {:error, "Unexpected type when encoding Laureate.died_country_code"}
314+
315+ def decode_firstname(value) when is_binary(value), do: value
316+ def decode_firstname(_), do: {:error, "Unexpected type when decoding Laureate.firstname"}
317+
318+ def encode_firstname(value) when is_binary(value), do: value
319+ def encode_firstname(_), do: {:error, "Unexpected type when encoding Laureate.firstname"}
320+
237321 def decode_id(value) when is_binary(value), do: value
238322 def decode_id(_), do: {:error, "Unexpected type when decoding Laureate.id"}
239323
@@ -246,21 +330,27 @@ defmodule Laureate do
246330 def encode_prizes(value) when is_list(value), do: value
247331 def encode_prizes(_), do: {:error, "Unexpected type when encoding Laureate.prizes"}
248332
333+ def decode_surname(value) when is_binary(value), do: value
334+ def decode_surname(_), do: {:error, "Unexpected type when decoding Laureate.surname"}
335+
336+ def encode_surname(value) when is_binary(value), do: value
337+ def encode_surname(_), do: {:error, "Unexpected type when encoding Laureate.surname"}
338+
249339 def from_map(m) do
250340 %Laureate{
251341 born: decode_born(m["born"]),
252- born_city: m["bornCity"],
253- born_country: m["bornCountry"],
254- born_country_code: m["bornCountryCode"],
342+ born_city: m["bornCity"] && decode_born_city(m["bornCity"]),
343+ born_country: m["bornCountry"] && decode_born_country(m["bornCountry"]),
344+ born_country_code: m["bornCountryCode"] && decode_born_country_code(m["bornCountryCode"]),
255345 died: decode_died(m["died"]),
256- died_city: m["diedCity"],
257- died_country: m["diedCountry"],
258- died_country_code: m["diedCountryCode"],
259- firstname: m["firstname"],
346+ died_city: m["diedCity"] && decode_died_city(m["diedCity"]),
347+ died_country: m["diedCountry"] && decode_died_country(m["diedCountry"]),
348+ died_country_code: m["diedCountryCode"] && decode_died_country_code(m["diedCountryCode"]),
349+ firstname: m["firstname"] && decode_firstname(m["firstname"]),
260350 gender: Gender.decode(m["gender"]),
261351 id: decode_id(m["id"]),
262352 prizes: Enum.map(m["prizes"], &Prize.from_map/1),
263- surname: m["surname"],
353+ surname: m["surname"] && decode_surname(m["surname"]),
264354 }
265355 end
Test case

test/inputs/json/misc/3e9a3.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -13,10 +13,22 @@ defmodule Footnote do
1313 text: String.t() | nil
1414 }
1515
16+ def decode_code(value) when is_binary(value), do: value
17+ def decode_code(_), do: {:error, "Unexpected type when decoding Footnote.code"}
18+
19+ def encode_code(value) when is_binary(value), do: value
20+ def encode_code(_), do: {:error, "Unexpected type when encoding Footnote.code"}
21+
22+ def decode_text(value) when is_binary(value), do: value
23+ def decode_text(_), do: {:error, "Unexpected type when decoding Footnote.text"}
24+
25+ def encode_text(value) when is_binary(value), do: value
26+ def encode_text(_), do: {:error, "Unexpected type when encoding Footnote.text"}
27+
1628 def from_map(m) do
1729 %Footnote{
18- code: m["code"],
19- text: m["text"],
30+ code: m["code"] && decode_code(m["code"]),
31+ text: m["text"] && decode_text(m["text"]),
2032 }
2133 end
Test case

test/inputs/json/misc/421d4.json

1 generated file · +28 −4
Melixirdefault / QuickType.ex+28 −4
@@ -67,6 +67,18 @@ defmodule CachedContents do
6767 top: [Top.t()] | nil
6868 }
6969
70+ def decode_average(value) when is_binary(value), do: value
71+ def decode_average(_), do: {:error, "Unexpected type when decoding CachedContents.average"}
72+
73+ def encode_average(value) when is_binary(value), do: value
74+ def encode_average(_), do: {:error, "Unexpected type when encoding CachedContents.average"}
75+
76+ def decode_largest(value) when is_binary(value), do: value
77+ def decode_largest(_), do: {:error, "Unexpected type when decoding CachedContents.largest"}
78+
79+ def encode_largest(value) when is_binary(value), do: value
80+ def encode_largest(_), do: {:error, "Unexpected type when encoding CachedContents.largest"}
81+
7082 def decode_non_null(value) when is_integer(value), do: value
7183 def decode_non_null(_), do: {:error, "Unexpected type when decoding CachedContents.non_null"}
7284
@@ -79,14 +91,26 @@ defmodule CachedContents do
7991 def encode_null(value) when is_integer(value), do: value
8092 def encode_null(_), do: {:error, "Unexpected type when encoding CachedContents.null"}
8193
94+ def decode_smallest(value) when is_binary(value), do: value
95+ def decode_smallest(_), do: {:error, "Unexpected type when decoding CachedContents.smallest"}
96+
97+ def encode_smallest(value) when is_binary(value), do: value
98+ def encode_smallest(_), do: {:error, "Unexpected type when encoding CachedContents.smallest"}
99+
100+ def decode_sum(value) when is_binary(value), do: value
101+ def decode_sum(_), do: {:error, "Unexpected type when decoding CachedContents.sum"}
102+
103+ def encode_sum(value) when is_binary(value), do: value
104+ def encode_sum(_), do: {:error, "Unexpected type when encoding CachedContents.sum"}
105+
82106 def from_map(m) do
83107 %CachedContents{
84- average: m["average"],
85- largest: m["largest"],
108+ average: m["average"] && decode_average(m["average"]),
109+ largest: m["largest"] && decode_largest(m["largest"]),
86110 non_null: decode_non_null(m["non_null"]),
87111 null: decode_null(m["null"]),
88- smallest: m["smallest"],
89- sum: m["sum"],
112+ smallest: m["smallest"] && decode_smallest(m["smallest"]),
113+ sum: m["sum"] && decode_sum(m["sum"]),
90114 top: m["top"] && Enum.map(m["top"], &Top.from_map/1),
91115 }
92116 end
Test case

test/inputs/json/misc/437e7.json

1 generated file · +28 −4
Melixirdefault / QuickType.ex+28 −4
@@ -22,6 +22,12 @@ defmodule Downsized do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding Downsized.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding Downsized.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding Downsized.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding Downsized.url"}
2733
@@ -37,7 +43,7 @@ defmodule Downsized do
3743 def from_map(m) do
3844 %Downsized{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -147,12 +153,30 @@ defmodule FixedHeight do
147153 width: String.t()
148154 }
149155
156+ def decode_frames(value) when is_binary(value), do: value
157+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
158+
159+ def encode_frames(value) when is_binary(value), do: value
160+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
161+
150162 def decode_height(value) when is_binary(value), do: value
151163 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
152164
153165 def encode_height(value) when is_binary(value), do: value
154166 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
155167
168+ def decode_mp4(value) when is_binary(value), do: value
169+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
170+
171+ def encode_mp4(value) when is_binary(value), do: value
172+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
173+
174+ def decode_mp4_size(value) when is_binary(value), do: value
175+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
176+
177+ def encode_mp4_size(value) when is_binary(value), do: value
178+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
179+
156180 def decode_size(value) when is_binary(value), do: value
157181 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
158182
@@ -185,10 +209,10 @@ defmodule FixedHeight do
185209
186210 def from_map(m) do
187211 %FixedHeight{
188- frames: m["frames"],
212+ frames: m["frames"] && decode_frames(m["frames"]),
189213 height: decode_height(m["height"]),
190- mp4: m["mp4"],
191- mp4_size: m["mp4_size"],
214+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
215+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
192216 size: decode_size(m["size"]),
193217 url: decode_url(m["url"]),
194218 webp: decode_webp(m["webp"]),
Test case

test/inputs/json/misc/4d6fb.json

1 generated file · +7 −1
Melixirdefault / QuickType.ex+7 −1
@@ -204,9 +204,15 @@ defmodule MediaEmbed do
204204 width: integer() | nil
205205 }
206206
207+ def decode_content(value) when is_binary(value), do: value
208+ def decode_content(_), do: {:error, "Unexpected type when decoding MediaEmbed.content"}
209+
210+ def encode_content(value) when is_binary(value), do: value
211+ def encode_content(_), do: {:error, "Unexpected type when encoding MediaEmbed.content"}
212+
207213 def from_map(m) do
208214 %MediaEmbed{
209- content: m["content"],
215+ content: m["content"] && decode_content(m["content"]),
210216 height: m["height"],
211217 scrolling: m["scrolling"],
212218 width: m["width"],
Test case

test/inputs/json/misc/5f7fe.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -183,10 +183,22 @@ defmodule Format do
183183 view: String.t() | nil
184184 }
185185
186+ def decode_align(value) when is_binary(value), do: value
187+ def decode_align(_), do: {:error, "Unexpected type when decoding Format.align"}
188+
189+ def encode_align(value) when is_binary(value), do: value
190+ def encode_align(_), do: {:error, "Unexpected type when encoding Format.align"}
191+
192+ def decode_view(value) when is_binary(value), do: value
193+ def decode_view(_), do: {:error, "Unexpected type when decoding Format.view"}
194+
195+ def encode_view(value) when is_binary(value), do: value
196+ def encode_view(_), do: {:error, "Unexpected type when encoding Format.view"}
197+
186198 def from_map(m) do
187199 %Format{
188- align: m["align"],
189- view: m["view"],
200+ align: m["align"] && decode_align(m["align"]),
201+ view: m["view"] && decode_view(m["view"]),
190202 }
191203 end
Test case

test/inputs/json/misc/617e8.json

1 generated file · +21 −3
Melixirdefault / QuickType.ex+21 −3
@@ -183,10 +183,22 @@ defmodule Format do
183183 view: String.t() | nil
184184 }
185185
186+ def decode_align(value) when is_binary(value), do: value
187+ def decode_align(_), do: {:error, "Unexpected type when decoding Format.align"}
188+
189+ def encode_align(value) when is_binary(value), do: value
190+ def encode_align(_), do: {:error, "Unexpected type when encoding Format.align"}
191+
192+ def decode_view(value) when is_binary(value), do: value
193+ def decode_view(_), do: {:error, "Unexpected type when decoding Format.view"}
194+
195+ def encode_view(value) when is_binary(value), do: value
196+ def encode_view(_), do: {:error, "Unexpected type when encoding Format.view"}
197+
186198 def from_map(m) do
187199 %Format{
188- align: m["align"],
189- view: m["view"],
200+ align: m["align"] && decode_align(m["align"]),
201+ view: m["view"] && decode_view(m["view"]),
190202 }
191203 end
192204
@@ -229,6 +241,12 @@ defmodule Column do
229241 width: integer() | nil
230242 }
231243
244+ def decode_description(value) when is_binary(value), do: value
245+ def decode_description(_), do: {:error, "Unexpected type when decoding Column.description"}
246+
247+ def encode_description(value) when is_binary(value), do: value
248+ def encode_description(_), do: {:error, "Unexpected type when encoding Column.description"}
249+
232250 def decode_field_name(value) when is_binary(value), do: value
233251 def decode_field_name(_), do: {:error, "Unexpected type when decoding Column.field_name"}
234252
@@ -257,7 +275,7 @@ defmodule Column do
257275 %Column{
258276 cached_contents: m["cachedContents"] && CachedContents.from_map(m["cachedContents"]),
259277 data_type_name: TypeName.decode(m["dataTypeName"]),
260- description: m["description"],
278+ description: m["description"] && decode_description(m["description"]),
261279 field_name: decode_field_name(m["fieldName"]),
262280 flags: m["flags"],
263281 format: Format.from_map(m["format"]),
Test case

test/inputs/json/misc/65dec.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -430,6 +430,12 @@ defmodule Card do
430430 def encode_cmc(value) when is_integer(value), do: value
431431 def encode_cmc(_), do: {:error, "Unexpected type when encoding Card.cmc"}
432432
433+ def decode_flavor(value) when is_binary(value), do: value
434+ def decode_flavor(_), do: {:error, "Unexpected type when decoding Card.flavor"}
435+
436+ def encode_flavor(value) when is_binary(value), do: value
437+ def encode_flavor(_), do: {:error, "Unexpected type when encoding Card.flavor"}
438+
433439 def decode_id(value) when is_binary(value), do: value
434440 def decode_id(_), do: {:error, "Unexpected type when decoding Card.id"}
435441
@@ -448,6 +454,18 @@ defmodule Card do
448454 def encode_legalities(value) when is_list(value), do: value
449455 def encode_legalities(_), do: {:error, "Unexpected type when encoding Card.legalities"}
450456
457+ def decode_mana_cost(value) when is_binary(value), do: value
458+ def decode_mana_cost(_), do: {:error, "Unexpected type when decoding Card.mana_cost"}
459+
460+ def encode_mana_cost(value) when is_binary(value), do: value
461+ def encode_mana_cost(_), do: {:error, "Unexpected type when encoding Card.mana_cost"}
462+
463+ def decode_mci_number(value) when is_binary(value), do: value
464+ def decode_mci_number(_), do: {:error, "Unexpected type when decoding Card.mci_number"}
465+
466+ def encode_mci_number(value) when is_binary(value), do: value
467+ def encode_mci_number(_), do: {:error, "Unexpected type when encoding Card.mci_number"}
468+
451469 def decode_multiverseid(value) when is_integer(value), do: value
452470 def decode_multiverseid(_), do: {:error, "Unexpected type when decoding Card.multiverseid"}
453471
@@ -472,12 +490,30 @@ defmodule Card do
472490 def encode_original_type(value) when is_binary(value), do: value
473491 def encode_original_type(_), do: {:error, "Unexpected type when encoding Card.original_type"}
474492
493+ def decode_power(value) when is_binary(value), do: value
494+ def decode_power(_), do: {:error, "Unexpected type when decoding Card.power"}
495+
496+ def encode_power(value) when is_binary(value), do: value
497+ def encode_power(_), do: {:error, "Unexpected type when encoding Card.power"}
498+
475499 def decode_printings(value) when is_list(value), do: value
476500 def decode_printings(_), do: {:error, "Unexpected type when decoding Card.printings"}
477501
478502 def encode_printings(value) when is_list(value), do: value
479503 def encode_printings(_), do: {:error, "Unexpected type when encoding Card.printings"}
480504
505+ def decode_text(value) when is_binary(value), do: value
506+ def decode_text(_), do: {:error, "Unexpected type when decoding Card.text"}
507+
508+ def encode_text(value) when is_binary(value), do: value
509+ def encode_text(_), do: {:error, "Unexpected type when encoding Card.text"}
510+
511+ def decode_toughness(value) when is_binary(value), do: value
512+ def decode_toughness(_), do: {:error, "Unexpected type when decoding Card.toughness"}
513+
514+ def encode_toughness(value) when is_binary(value), do: value
515+ def encode_toughness(_), do: {:error, "Unexpected type when encoding Card.toughness"}
516+
481517 def decode_type(value) when is_binary(value), do: value
482518 def decode_type(_), do: {:error, "Unexpected type when decoding Card.type"}
483519
@@ -496,26 +532,26 @@ defmodule Card do
496532 cmc: decode_cmc(m["cmc"]),
497533 color_identity: m["colorIdentity"] && Enum.map(m["colorIdentity"], &ColorIdentity.decode/1),
498534 colors: m["colors"] && Enum.map(m["colors"], &Watermark.decode/1),
499- flavor: m["flavor"],
535+ flavor: m["flavor"] && decode_flavor(m["flavor"]),
500536 id: decode_id(m["id"]),
501537 image_name: decode_image_name(m["imageName"]),
502538 layout: Layout.decode(m["layout"]),
503539 legalities: Enum.map(m["legalities"], &LegalityElement.from_map/1),
504- mana_cost: m["manaCost"],
505- mci_number: m["mciNumber"],
540+ mana_cost: m["manaCost"] && decode_mana_cost(m["manaCost"]),
541+ mci_number: m["mciNumber"] && decode_mci_number(m["mciNumber"]),
506542 multiverseid: decode_multiverseid(m["multiverseid"]),
507543 name: decode_name(m["name"]),
508544 original_text: decode_original_text(m["originalText"]),
509545 original_type: decode_original_type(m["originalType"]),
510- power: m["power"],
546+ power: m["power"] && decode_power(m["power"]),
511547 printings: decode_printings(m["printings"]),
512548 rarity: Rarity.decode(m["rarity"]),
513549 reserved: m["reserved"],
514550 rulings: m["rulings"] && Enum.map(m["rulings"], &Ruling.from_map/1),
515551 subtypes: m["subtypes"],
516552 supertypes: m["supertypes"],
517- text: m["text"],
518- toughness: m["toughness"],
553+ text: m["text"] && decode_text(m["text"]),
554+ toughness: m["toughness"] && decode_toughness(m["toughness"]),
519555 type: decode_type(m["type"]),
520556 types: Enum.map(m["types"], &Type.decode/1),
521557 variations: m["variations"],
Test case

test/inputs/json/misc/6de06.json

1 generated file · +7 −1
Melixirdefault / QuickType.ex+7 −1
@@ -195,9 +195,15 @@ defmodule MediaEmbed do
195195 width: integer() | nil
196196 }
197197
198+ def decode_content(value) when is_binary(value), do: value
199+ def decode_content(_), do: {:error, "Unexpected type when decoding MediaEmbed.content"}
200+
201+ def encode_content(value) when is_binary(value), do: value
202+ def encode_content(_), do: {:error, "Unexpected type when encoding MediaEmbed.content"}
203+
198204 def from_map(m) do
199205 %MediaEmbed{
200- content: m["content"],
206+ content: m["content"] && decode_content(m["content"]),
201207 height: m["height"],
202208 scrolling: m["scrolling"],
203209 width: m["width"],
Test case

test/inputs/json/misc/734ad.json

1 generated file · +28 −4
Melixirdefault / QuickType.ex+28 −4
@@ -187,6 +187,30 @@ defmodule Result do
187187 def encode_activity_relevant_comm(value) when is_binary(value), do: value
188188 def encode_activity_relevant_comm(_), do: {:error, "Unexpected type when encoding Result.activity_relevant_comm"}
189189
190+ def decode_be_office_country(value) when is_binary(value), do: value
191+ def decode_be_office_country(_), do: {:error, "Unexpected type when decoding Result.be_office_country"}
192+
193+ def encode_be_office_country(value) when is_binary(value), do: value
194+ def encode_be_office_country(_), do: {:error, "Unexpected type when encoding Result.be_office_country"}
195+
196+ def decode_be_office_phone(value) when is_binary(value), do: value
197+ def decode_be_office_phone(_), do: {:error, "Unexpected type when decoding Result.be_office_phone"}
198+
199+ def encode_be_office_phone(value) when is_binary(value), do: value
200+ def encode_be_office_phone(_), do: {:error, "Unexpected type when encoding Result.be_office_phone"}
201+
202+ def decode_be_office_street(value) when is_binary(value), do: value
203+ def decode_be_office_street(_), do: {:error, "Unexpected type when decoding Result.be_office_street"}
204+
205+ def encode_be_office_street(value) when is_binary(value), do: value
206+ def encode_be_office_street(_), do: {:error, "Unexpected type when encoding Result.be_office_street"}
207+
208+ def decode_be_office_town(value) when is_binary(value), do: value
209+ def decode_be_office_town(_), do: {:error, "Unexpected type when decoding Result.be_office_town"}
210+
211+ def encode_be_office_town(value) when is_binary(value), do: value
212+ def encode_be_office_town(_), do: {:error, "Unexpected type when encoding Result.be_office_town"}
213+
190214 def decode_code_of_conduct(value) when is_binary(value), do: value
191215 def decode_code_of_conduct(_), do: {:error, "Unexpected type when decoding Result.code_of_conduct"}
192216
@@ -368,14 +392,14 @@ defmodule Result do
368392 activity_inter_groups: decode_activity_inter_groups(m["activity_inter_groups"]),
369393 activity_other: Map.fetch!(m, "activity_other"),
370394 activity_relevant_comm: decode_activity_relevant_comm(m["activity_relevant_comm"]),
371- be_office_country: m["be_office_country"],
395+ be_office_country: m["be_office_country"] && decode_be_office_country(m["be_office_country"]),
372396 be_office_lat: m["be_office_lat"],
373397 be_office_lon: m["be_office_lon"],
374- be_office_phone: m["be_office_phone"],
398+ be_office_phone: m["be_office_phone"] && decode_be_office_phone(m["be_office_phone"]),
375399 be_office_post_code: m["be_office_post_code"],
376400 be_office_postbox: m["be_office_postbox"],
377- be_office_street: m["be_office_street"],
378- be_office_town: m["be_office_town"],
401+ be_office_street: m["be_office_street"] && decode_be_office_street(m["be_office_street"]),
402+ be_office_town: m["be_office_town"] && decode_be_office_town(m["be_office_town"]),
379403 code_of_conduct: decode_code_of_conduct(m["code_of_conduct"]),
380404 contact_country: decode_contact_country(m["contact_country"]),
381405 created_at: decode_created_at(m["created_at"]),
Test case

test/inputs/json/misc/7681c.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -22,6 +22,12 @@ defmodule The480_WStill do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding The480_WStill.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding The480_WStill.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding The480_WStill.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding The480_WStill.url"}
2733
@@ -37,7 +43,7 @@ defmodule The480_WStill do
3743 def from_map(m) do
3844 %The480_WStill{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -148,12 +154,36 @@ defmodule FixedHeight do
148154 width: String.t()
149155 }
150156
157+ def decode_frames(value) when is_binary(value), do: value
158+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
159+
160+ def encode_frames(value) when is_binary(value), do: value
161+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
162+
163+ def decode_hash(value) when is_binary(value), do: value
164+ def decode_hash(_), do: {:error, "Unexpected type when decoding FixedHeight.hash"}
165+
166+ def encode_hash(value) when is_binary(value), do: value
167+ def encode_hash(_), do: {:error, "Unexpected type when encoding FixedHeight.hash"}
168+
151169 def decode_height(value) when is_binary(value), do: value
152170 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
153171
154172 def encode_height(value) when is_binary(value), do: value
155173 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
156174
175+ def decode_mp4(value) when is_binary(value), do: value
176+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
177+
178+ def encode_mp4(value) when is_binary(value), do: value
179+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
180+
181+ def decode_mp4_size(value) when is_binary(value), do: value
182+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
183+
184+ def encode_mp4_size(value) when is_binary(value), do: value
185+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
186+
157187 def decode_size(value) when is_binary(value), do: value
158188 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
159189
@@ -186,11 +216,11 @@ defmodule FixedHeight do
186216
187217 def from_map(m) do
188218 %FixedHeight{
189- frames: m["frames"],
190- hash: m["hash"],
219+ frames: m["frames"] && decode_frames(m["frames"]),
220+ hash: m["hash"] && decode_hash(m["hash"]),
191221 height: decode_height(m["height"]),
192- mp4: m["mp4"],
193- mp4_size: m["mp4_size"],
222+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
223+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
194224 size: decode_size(m["size"]),
195225 url: decode_url(m["url"]),
196226 webp: decode_webp(m["webp"]),
@@ -503,6 +533,12 @@ defmodule User do
503533 def encode_profile_url(value) when is_binary(value), do: value
504534 def encode_profile_url(_), do: {:error, "Unexpected type when encoding User.profile_url"}
505535
536+ def decode_twitter(value) when is_binary(value), do: value
537+ def decode_twitter(_), do: {:error, "Unexpected type when decoding User.twitter"}
538+
539+ def encode_twitter(value) when is_binary(value), do: value
540+ def encode_twitter(_), do: {:error, "Unexpected type when encoding User.twitter"}
541+
506542 def decode_username(value) when is_binary(value), do: value
507543 def decode_username(_), do: {:error, "Unexpected type when decoding User.username"}
508544
@@ -515,7 +551,7 @@ defmodule User do
515551 banner_url: decode_banner_url(m["banner_url"]),
516552 display_name: decode_display_name(m["display_name"]),
517553 profile_url: decode_profile_url(m["profile_url"]),
518- twitter: m["twitter"],
554+ twitter: m["twitter"] && decode_twitter(m["twitter"]),
519555 username: decode_username(m["username"]),
520556 }
521557 end
Test case

test/inputs/json/misc/77392.json

1 generated file · +21 −3
Melixirdefault / QuickType.ex+21 −3
@@ -134,6 +134,12 @@ defmodule TopLevelElement do
134134 def encode_discovery_date(value) when is_binary(value), do: value
135135 def encode_discovery_date(_), do: {:error, "Unexpected type when encoding TopLevelElement.discovery_date"}
136136
137+ def decode_h_mag(value) when is_binary(value), do: value
138+ def decode_h_mag(_), do: {:error, "Unexpected type when decoding TopLevelElement.h_mag"}
139+
140+ def encode_h_mag(value) when is_binary(value), do: value
141+ def encode_h_mag(_), do: {:error, "Unexpected type when encoding TopLevelElement.h_mag"}
142+
137143 def decode_i_deg(value) when is_binary(value), do: value
138144 def decode_i_deg(_), do: {:error, "Unexpected type when decoding TopLevelElement.i_deg"}
139145
@@ -146,24 +152,36 @@ defmodule TopLevelElement do
146152 def encode_moid_au(value) when is_binary(value), do: value
147153 def encode_moid_au(_), do: {:error, "Unexpected type when encoding TopLevelElement.moid_au"}
148154
155+ def decode_period_yr(value) when is_binary(value), do: value
156+ def decode_period_yr(_), do: {:error, "Unexpected type when decoding TopLevelElement.period_yr"}
157+
158+ def encode_period_yr(value) when is_binary(value), do: value
159+ def encode_period_yr(_), do: {:error, "Unexpected type when encoding TopLevelElement.period_yr"}
160+
149161 def decode_q_au_1(value) when is_binary(value), do: value
150162 def decode_q_au_1(_), do: {:error, "Unexpected type when decoding TopLevelElement.q_au_1"}
151163
152164 def encode_q_au_1(value) when is_binary(value), do: value
153165 def encode_q_au_1(_), do: {:error, "Unexpected type when encoding TopLevelElement.q_au_1"}
154166
167+ def decode_q_au_2(value) when is_binary(value), do: value
168+ def decode_q_au_2(_), do: {:error, "Unexpected type when decoding TopLevelElement.q_au_2"}
169+
170+ def encode_q_au_2(value) when is_binary(value), do: value
171+ def encode_q_au_2(_), do: {:error, "Unexpected type when encoding TopLevelElement.q_au_2"}
172+
155173 def from_map(m) do
156174 %TopLevelElement{
157175 designation: decode_designation(m["designation"]),
158176 discovery_date: decode_discovery_date(m["discovery_date"]),
159- h_mag: m["h_mag"],
177+ h_mag: m["h_mag"] && decode_h_mag(m["h_mag"]),
160178 i_deg: decode_i_deg(m["i_deg"]),
161179 moid_au: decode_moid_au(m["moid_au"]),
162180 orbit_class: OrbitClass.decode(m["orbit_class"]),
163- period_yr: m["period_yr"],
181+ period_yr: m["period_yr"] && decode_period_yr(m["period_yr"]),
164182 pha: Pha.decode(m["pha"]),
165183 q_au_1: decode_q_au_1(m["q_au_1"]),
166- q_au_2: m["q_au_2"],
184+ q_au_2: m["q_au_2"] && decode_q_au_2(m["q_au_2"]),
167185 }
168186 end
Test case

test/inputs/json/misc/a3d8c.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -67,6 +67,12 @@ defmodule CachedContents do
6767 top: [Top.t()]
6868 }
6969
70+ def decode_average(value) when is_binary(value), do: value
71+ def decode_average(_), do: {:error, "Unexpected type when decoding CachedContents.average"}
72+
73+ def encode_average(value) when is_binary(value), do: value
74+ def encode_average(_), do: {:error, "Unexpected type when encoding CachedContents.average"}
75+
7076 def decode_largest(value) when is_binary(value), do: value
7177 def decode_largest(_), do: {:error, "Unexpected type when decoding CachedContents.largest"}
7278
@@ -91,6 +97,12 @@ defmodule CachedContents do
9197 def encode_smallest(value) when is_binary(value), do: value
9298 def encode_smallest(_), do: {:error, "Unexpected type when encoding CachedContents.smallest"}
9399
100+ def decode_sum(value) when is_binary(value), do: value
101+ def decode_sum(_), do: {:error, "Unexpected type when decoding CachedContents.sum"}
102+
103+ def encode_sum(value) when is_binary(value), do: value
104+ def encode_sum(_), do: {:error, "Unexpected type when encoding CachedContents.sum"}
105+
94106 def decode_top(value) when is_list(value), do: value
95107 def decode_top(_), do: {:error, "Unexpected type when decoding CachedContents.top"}
96108
@@ -99,12 +111,12 @@ defmodule CachedContents do
99111
100112 def from_map(m) do
101113 %CachedContents{
102- average: m["average"],
114+ average: m["average"] && decode_average(m["average"]),
103115 largest: decode_largest(m["largest"]),
104116 non_null: decode_non_null(m["non_null"]),
105117 null: decode_null(m["null"]),
106118 smallest: decode_smallest(m["smallest"]),
107- sum: m["sum"],
119+ sum: m["sum"] && decode_sum(m["sum"]),
108120 top: Enum.map(m["top"], &Top.from_map/1),
109121 }
110122 end
Test case

test/inputs/json/misc/b4865.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -202,12 +202,30 @@ defmodule TopLevelElement do
202202 year: String.t() | nil
203203 }
204204
205+ def decode_computed_region_cbhk_fwbd(value) when is_binary(value), do: value
206+ def decode_computed_region_cbhk_fwbd(_), do: {:error, "Unexpected type when decoding TopLevelElement.computed_region_cbhk_fwbd"}
207+
208+ def encode_computed_region_cbhk_fwbd(value) when is_binary(value), do: value
209+ def encode_computed_region_cbhk_fwbd(_), do: {:error, "Unexpected type when encoding TopLevelElement.computed_region_cbhk_fwbd"}
210+
211+ def decode_computed_region_nnqa_25_f4(value) when is_binary(value), do: value
212+ def decode_computed_region_nnqa_25_f4(_), do: {:error, "Unexpected type when decoding TopLevelElement.computed_region_nnqa_25_f4"}
213+
214+ def encode_computed_region_nnqa_25_f4(value) when is_binary(value), do: value
215+ def encode_computed_region_nnqa_25_f4(_), do: {:error, "Unexpected type when encoding TopLevelElement.computed_region_nnqa_25_f4"}
216+
205217 def decode_id(value) when is_binary(value), do: value
206218 def decode_id(_), do: {:error, "Unexpected type when decoding TopLevelElement.id"}
207219
208220 def encode_id(value) when is_binary(value), do: value
209221 def encode_id(_), do: {:error, "Unexpected type when encoding TopLevelElement.id"}
210222
223+ def decode_mass(value) when is_binary(value), do: value
224+ def decode_mass(_), do: {:error, "Unexpected type when decoding TopLevelElement.mass"}
225+
226+ def encode_mass(value) when is_binary(value), do: value
227+ def encode_mass(_), do: {:error, "Unexpected type when encoding TopLevelElement.mass"}
228+
211229 def decode_name(value) when is_binary(value), do: value
212230 def decode_name(_), do: {:error, "Unexpected type when decoding TopLevelElement.name"}
213231
@@ -220,20 +238,38 @@ defmodule TopLevelElement do
220238 def encode_recclass(value) when is_binary(value), do: value
221239 def encode_recclass(_), do: {:error, "Unexpected type when encoding TopLevelElement.recclass"}
222240
241+ def decode_reclat(value) when is_binary(value), do: value
242+ def decode_reclat(_), do: {:error, "Unexpected type when decoding TopLevelElement.reclat"}
243+
244+ def encode_reclat(value) when is_binary(value), do: value
245+ def encode_reclat(_), do: {:error, "Unexpected type when encoding TopLevelElement.reclat"}
246+
247+ def decode_reclong(value) when is_binary(value), do: value
248+ def decode_reclong(_), do: {:error, "Unexpected type when decoding TopLevelElement.reclong"}
249+
250+ def encode_reclong(value) when is_binary(value), do: value
251+ def encode_reclong(_), do: {:error, "Unexpected type when encoding TopLevelElement.reclong"}
252+
253+ def decode_year(value) when is_binary(value), do: value
254+ def decode_year(_), do: {:error, "Unexpected type when decoding TopLevelElement.year"}
255+
256+ def encode_year(value) when is_binary(value), do: value
257+ def encode_year(_), do: {:error, "Unexpected type when encoding TopLevelElement.year"}
258+
223259 def from_map(m) do
224260 %TopLevelElement{
225- computed_region_cbhk_fwbd: m[":@computed_region_cbhk_fwbd"],
226- computed_region_nnqa_25_f4: m[":@computed_region_nnqa_25f4"],
261+ computed_region_cbhk_fwbd: m[":@computed_region_cbhk_fwbd"] && decode_computed_region_cbhk_fwbd(m[":@computed_region_cbhk_fwbd"]),
262+ computed_region_nnqa_25_f4: m[":@computed_region_nnqa_25f4"] && decode_computed_region_nnqa_25_f4(m[":@computed_region_nnqa_25f4"]),
227263 fall: Fall.decode(m["fall"]),
228264 geolocation: m["geolocation"] && Geolocation.from_map(m["geolocation"]),
229265 id: decode_id(m["id"]),
230- mass: m["mass"],
266+ mass: m["mass"] && decode_mass(m["mass"]),
231267 name: decode_name(m["name"]),
232268 nametype: Nametype.decode(m["nametype"]),
233269 recclass: decode_recclass(m["recclass"]),
234- reclat: m["reclat"],
235- reclong: m["reclong"],
236- year: m["year"],
270+ reclat: m["reclat"] && decode_reclat(m["reclat"]),
271+ reclong: m["reclong"] && decode_reclong(m["reclong"]),
272+ year: m["year"] && decode_year(m["year"]),
237273 }
238274 end
Test case

test/inputs/json/misc/be234.json

1 generated file · +7 −1
Melixirdefault / QuickType.ex+7 −1
@@ -238,9 +238,15 @@ defmodule MediaEmbed do
238238 width: integer() | nil
239239 }
240240
241+ def decode_content(value) when is_binary(value), do: value
242+ def decode_content(_), do: {:error, "Unexpected type when decoding MediaEmbed.content"}
243+
244+ def encode_content(value) when is_binary(value), do: value
245+ def encode_content(_), do: {:error, "Unexpected type when encoding MediaEmbed.content"}
246+
241247 def from_map(m) do
242248 %MediaEmbed{
243- content: m["content"],
249+ content: m["content"] && decode_content(m["content"]),
244250 height: m["height"],
245251 scrolling: m["scrolling"],
246252 width: m["width"],
Test case

test/inputs/json/misc/c3303.json

1 generated file · +35 −5
Melixirdefault / QuickType.ex+35 −5
@@ -22,6 +22,12 @@ defmodule The480_WStill do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding The480_WStill.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding The480_WStill.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding The480_WStill.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding The480_WStill.url"}
2733
@@ -37,7 +43,7 @@ defmodule The480_WStill do
3743 def from_map(m) do
3844 %The480_WStill{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -148,12 +154,36 @@ defmodule FixedHeight do
148154 width: String.t()
149155 }
150156
157+ def decode_frames(value) when is_binary(value), do: value
158+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
159+
160+ def encode_frames(value) when is_binary(value), do: value
161+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
162+
163+ def decode_hash(value) when is_binary(value), do: value
164+ def decode_hash(_), do: {:error, "Unexpected type when decoding FixedHeight.hash"}
165+
166+ def encode_hash(value) when is_binary(value), do: value
167+ def encode_hash(_), do: {:error, "Unexpected type when encoding FixedHeight.hash"}
168+
151169 def decode_height(value) when is_binary(value), do: value
152170 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
153171
154172 def encode_height(value) when is_binary(value), do: value
155173 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
156174
175+ def decode_mp4(value) when is_binary(value), do: value
176+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
177+
178+ def encode_mp4(value) when is_binary(value), do: value
179+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
180+
181+ def decode_mp4_size(value) when is_binary(value), do: value
182+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
183+
184+ def encode_mp4_size(value) when is_binary(value), do: value
185+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
186+
157187 def decode_size(value) when is_binary(value), do: value
158188 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
159189
@@ -186,11 +216,11 @@ defmodule FixedHeight do
186216
187217 def from_map(m) do
188218 %FixedHeight{
189- frames: m["frames"],
190- hash: m["hash"],
219+ frames: m["frames"] && decode_frames(m["frames"]),
220+ hash: m["hash"] && decode_hash(m["hash"]),
191221 height: decode_height(m["height"]),
192- mp4: m["mp4"],
193- mp4_size: m["mp4_size"],
222+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
223+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
194224 size: decode_size(m["size"]),
195225 url: decode_url(m["url"]),
196226 webp: decode_webp(m["webp"]),
Test case

test/inputs/json/misc/cb0cc.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -79,6 +79,12 @@ defmodule Laureate do
7979 def encode_id(value) when is_binary(value), do: value
8080 def encode_id(_), do: {:error, "Unexpected type when encoding Laureate.id"}
8181
82+ def decode_motivation(value) when is_binary(value), do: value
83+ def decode_motivation(_), do: {:error, "Unexpected type when decoding Laureate.motivation"}
84+
85+ def encode_motivation(value) when is_binary(value), do: value
86+ def encode_motivation(_), do: {:error, "Unexpected type when encoding Laureate.motivation"}
87+
8288 def decode_share(value) when is_binary(value), do: value
8389 def decode_share(_), do: {:error, "Unexpected type when decoding Laureate.share"}
8490
@@ -95,7 +101,7 @@ defmodule Laureate do
95101 %Laureate{
96102 firstname: decode_firstname(m["firstname"]),
97103 id: decode_id(m["id"]),
98- motivation: m["motivation"],
104+ motivation: m["motivation"] && decode_motivation(m["motivation"]),
99105 share: decode_share(m["share"]),
100106 surname: decode_surname(m["surname"]),
101107 }
@@ -141,6 +147,12 @@ defmodule Prize do
141147 def encode_laureates(value) when is_list(value), do: value
142148 def encode_laureates(_), do: {:error, "Unexpected type when encoding Prize.laureates"}
143149
150+ def decode_overall_motivation(value) when is_binary(value), do: value
151+ def decode_overall_motivation(_), do: {:error, "Unexpected type when decoding Prize.overall_motivation"}
152+
153+ def encode_overall_motivation(value) when is_binary(value), do: value
154+ def encode_overall_motivation(_), do: {:error, "Unexpected type when encoding Prize.overall_motivation"}
155+
144156 def decode_year(value) when is_binary(value), do: value
145157 def decode_year(_), do: {:error, "Unexpected type when decoding Prize.year"}
146158
@@ -151,7 +163,7 @@ defmodule Prize do
151163 %Prize{
152164 category: Category.decode(m["category"]),
153165 laureates: Enum.map(m["laureates"], &Laureate.from_map/1),
154- overall_motivation: m["overallMotivation"],
166+ overall_motivation: m["overallMotivation"] && decode_overall_motivation(m["overallMotivation"]),
155167 year: decode_year(m["year"]),
156168 }
157169 end
Test case

test/inputs/json/misc/dc44f.json

1 generated file · +49 −7
Melixirdefault / QuickType.ex+49 −7
@@ -589,6 +589,12 @@ defmodule Card do
589589 def encode_cmc(value) when is_integer(value), do: value
590590 def encode_cmc(_), do: {:error, "Unexpected type when encoding Card.cmc"}
591591
592+ def decode_flavor(value) when is_binary(value), do: value
593+ def decode_flavor(_), do: {:error, "Unexpected type when decoding Card.flavor"}
594+
595+ def encode_flavor(value) when is_binary(value), do: value
596+ def encode_flavor(_), do: {:error, "Unexpected type when encoding Card.flavor"}
597+
592598 def decode_id(value) when is_binary(value), do: value
593599 def decode_id(_), do: {:error, "Unexpected type when decoding Card.id"}
594600
@@ -607,6 +613,18 @@ defmodule Card do
607613 def encode_legalities(value) when is_list(value), do: value
608614 def encode_legalities(_), do: {:error, "Unexpected type when encoding Card.legalities"}
609615
616+ def decode_mana_cost(value) when is_binary(value), do: value
617+ def decode_mana_cost(_), do: {:error, "Unexpected type when decoding Card.mana_cost"}
618+
619+ def encode_mana_cost(value) when is_binary(value), do: value
620+ def encode_mana_cost(_), do: {:error, "Unexpected type when encoding Card.mana_cost"}
621+
622+ def decode_mci_number(value) when is_binary(value), do: value
623+ def decode_mci_number(_), do: {:error, "Unexpected type when decoding Card.mci_number"}
624+
625+ def encode_mci_number(value) when is_binary(value), do: value
626+ def encode_mci_number(_), do: {:error, "Unexpected type when encoding Card.mci_number"}
627+
610628 def decode_multiverseid(value) when is_integer(value), do: value
611629 def decode_multiverseid(_), do: {:error, "Unexpected type when decoding Card.multiverseid"}
612630
@@ -619,18 +637,42 @@ defmodule Card do
619637 def encode_name(value) when is_binary(value), do: value
620638 def encode_name(_), do: {:error, "Unexpected type when encoding Card.name"}
621639
640+ def decode_original_text(value) when is_binary(value), do: value
641+ def decode_original_text(_), do: {:error, "Unexpected type when decoding Card.original_text"}
642+
643+ def encode_original_text(value) when is_binary(value), do: value
644+ def encode_original_text(_), do: {:error, "Unexpected type when encoding Card.original_text"}
645+
622646 def decode_original_type(value) when is_binary(value), do: value
623647 def decode_original_type(_), do: {:error, "Unexpected type when decoding Card.original_type"}
624648
625649 def encode_original_type(value) when is_binary(value), do: value
626650 def encode_original_type(_), do: {:error, "Unexpected type when encoding Card.original_type"}
627651
652+ def decode_power(value) when is_binary(value), do: value
653+ def decode_power(_), do: {:error, "Unexpected type when decoding Card.power"}
654+
655+ def encode_power(value) when is_binary(value), do: value
656+ def encode_power(_), do: {:error, "Unexpected type when encoding Card.power"}
657+
628658 def decode_printings(value) when is_list(value), do: value
629659 def decode_printings(_), do: {:error, "Unexpected type when decoding Card.printings"}
630660
631661 def encode_printings(value) when is_list(value), do: value
632662 def encode_printings(_), do: {:error, "Unexpected type when encoding Card.printings"}
633663
664+ def decode_text(value) when is_binary(value), do: value
665+ def decode_text(_), do: {:error, "Unexpected type when decoding Card.text"}
666+
667+ def encode_text(value) when is_binary(value), do: value
668+ def encode_text(_), do: {:error, "Unexpected type when encoding Card.text"}
669+
670+ def decode_toughness(value) when is_binary(value), do: value
671+ def decode_toughness(_), do: {:error, "Unexpected type when decoding Card.toughness"}
672+
673+ def encode_toughness(value) when is_binary(value), do: value
674+ def encode_toughness(_), do: {:error, "Unexpected type when encoding Card.toughness"}
675+
634676 def decode_type(value) when is_binary(value), do: value
635677 def decode_type(_), do: {:error, "Unexpected type when decoding Card.type"}
636678
@@ -649,26 +691,26 @@ defmodule Card do
649691 cmc: decode_cmc(m["cmc"]),
650692 color_identity: m["colorIdentity"] && Enum.map(m["colorIdentity"], &ColorIdentity.decode/1),
651693 colors: m["colors"] && Enum.map(m["colors"], &Color.decode/1),
652- flavor: m["flavor"],
694+ flavor: m["flavor"] && decode_flavor(m["flavor"]),
653695 id: decode_id(m["id"]),
654696 image_name: decode_image_name(m["imageName"]),
655697 layout: Layout.decode(m["layout"]),
656698 legalities: Enum.map(m["legalities"], &LegalityElement.from_map/1),
657- mana_cost: m["manaCost"],
658- mci_number: m["mciNumber"],
699+ mana_cost: m["manaCost"] && decode_mana_cost(m["manaCost"]),
700+ mci_number: m["mciNumber"] && decode_mci_number(m["mciNumber"]),
659701 multiverseid: decode_multiverseid(m["multiverseid"]),
660702 name: decode_name(m["name"]),
661- original_text: m["originalText"],
703+ original_text: m["originalText"] && decode_original_text(m["originalText"]),
662704 original_type: decode_original_type(m["originalType"]),
663- power: m["power"],
705+ power: m["power"] && decode_power(m["power"]),
664706 printings: decode_printings(m["printings"]),
665707 rarity: Rarity.decode(m["rarity"]),
666708 reserved: m["reserved"],
667709 rulings: m["rulings"] && Enum.map(m["rulings"], &Ruling.from_map/1),
668710 subtypes: m["subtypes"],
669711 supertypes: m["supertypes"] && Enum.map(m["supertypes"], &Supertype.decode/1),
670- text: m["text"],
671- toughness: m["toughness"],
712+ text: m["text"] && decode_text(m["text"]),
713+ toughness: m["toughness"] && decode_toughness(m["toughness"]),
672714 type: decode_type(m["type"]),
673715 types: Enum.map(m["types"], &Type.decode/1),
674716 variations: m["variations"],
Test case

test/inputs/json/misc/dd1ce.json

1 generated file · +49 −7
Melixirdefault / QuickType.ex+49 −7
@@ -589,6 +589,12 @@ defmodule Card do
589589 def encode_cmc(value) when is_integer(value), do: value
590590 def encode_cmc(_), do: {:error, "Unexpected type when encoding Card.cmc"}
591591
592+ def decode_flavor(value) when is_binary(value), do: value
593+ def decode_flavor(_), do: {:error, "Unexpected type when decoding Card.flavor"}
594+
595+ def encode_flavor(value) when is_binary(value), do: value
596+ def encode_flavor(_), do: {:error, "Unexpected type when encoding Card.flavor"}
597+
592598 def decode_id(value) when is_binary(value), do: value
593599 def decode_id(_), do: {:error, "Unexpected type when decoding Card.id"}
594600
@@ -607,6 +613,18 @@ defmodule Card do
607613 def encode_legalities(value) when is_list(value), do: value
608614 def encode_legalities(_), do: {:error, "Unexpected type when encoding Card.legalities"}
609615
616+ def decode_mana_cost(value) when is_binary(value), do: value
617+ def decode_mana_cost(_), do: {:error, "Unexpected type when decoding Card.mana_cost"}
618+
619+ def encode_mana_cost(value) when is_binary(value), do: value
620+ def encode_mana_cost(_), do: {:error, "Unexpected type when encoding Card.mana_cost"}
621+
622+ def decode_mci_number(value) when is_binary(value), do: value
623+ def decode_mci_number(_), do: {:error, "Unexpected type when decoding Card.mci_number"}
624+
625+ def encode_mci_number(value) when is_binary(value), do: value
626+ def encode_mci_number(_), do: {:error, "Unexpected type when encoding Card.mci_number"}
627+
610628 def decode_multiverseid(value) when is_integer(value), do: value
611629 def decode_multiverseid(_), do: {:error, "Unexpected type when decoding Card.multiverseid"}
612630
@@ -619,18 +637,42 @@ defmodule Card do
619637 def encode_name(value) when is_binary(value), do: value
620638 def encode_name(_), do: {:error, "Unexpected type when encoding Card.name"}
621639
640+ def decode_original_text(value) when is_binary(value), do: value
641+ def decode_original_text(_), do: {:error, "Unexpected type when decoding Card.original_text"}
642+
643+ def encode_original_text(value) when is_binary(value), do: value
644+ def encode_original_text(_), do: {:error, "Unexpected type when encoding Card.original_text"}
645+
622646 def decode_original_type(value) when is_binary(value), do: value
623647 def decode_original_type(_), do: {:error, "Unexpected type when decoding Card.original_type"}
624648
625649 def encode_original_type(value) when is_binary(value), do: value
626650 def encode_original_type(_), do: {:error, "Unexpected type when encoding Card.original_type"}
627651
652+ def decode_power(value) when is_binary(value), do: value
653+ def decode_power(_), do: {:error, "Unexpected type when decoding Card.power"}
654+
655+ def encode_power(value) when is_binary(value), do: value
656+ def encode_power(_), do: {:error, "Unexpected type when encoding Card.power"}
657+
628658 def decode_printings(value) when is_list(value), do: value
629659 def decode_printings(_), do: {:error, "Unexpected type when decoding Card.printings"}
630660
631661 def encode_printings(value) when is_list(value), do: value
632662 def encode_printings(_), do: {:error, "Unexpected type when encoding Card.printings"}
633663
664+ def decode_text(value) when is_binary(value), do: value
665+ def decode_text(_), do: {:error, "Unexpected type when decoding Card.text"}
666+
667+ def encode_text(value) when is_binary(value), do: value
668+ def encode_text(_), do: {:error, "Unexpected type when encoding Card.text"}
669+
670+ def decode_toughness(value) when is_binary(value), do: value
671+ def decode_toughness(_), do: {:error, "Unexpected type when decoding Card.toughness"}
672+
673+ def encode_toughness(value) when is_binary(value), do: value
674+ def encode_toughness(_), do: {:error, "Unexpected type when encoding Card.toughness"}
675+
634676 def decode_type(value) when is_binary(value), do: value
635677 def decode_type(_), do: {:error, "Unexpected type when decoding Card.type"}
636678
@@ -649,26 +691,26 @@ defmodule Card do
649691 cmc: decode_cmc(m["cmc"]),
650692 color_identity: m["colorIdentity"] && Enum.map(m["colorIdentity"], &ColorIdentity.decode/1),
651693 colors: m["colors"] && Enum.map(m["colors"], &Color.decode/1),
652- flavor: m["flavor"],
694+ flavor: m["flavor"] && decode_flavor(m["flavor"]),
653695 id: decode_id(m["id"]),
654696 image_name: decode_image_name(m["imageName"]),
655697 layout: Layout.decode(m["layout"]),
656698 legalities: Enum.map(m["legalities"], &LegalityElement.from_map/1),
657- mana_cost: m["manaCost"],
658- mci_number: m["mciNumber"],
699+ mana_cost: m["manaCost"] && decode_mana_cost(m["manaCost"]),
700+ mci_number: m["mciNumber"] && decode_mci_number(m["mciNumber"]),
659701 multiverseid: decode_multiverseid(m["multiverseid"]),
660702 name: decode_name(m["name"]),
661- original_text: m["originalText"],
703+ original_text: m["originalText"] && decode_original_text(m["originalText"]),
662704 original_type: decode_original_type(m["originalType"]),
663- power: m["power"],
705+ power: m["power"] && decode_power(m["power"]),
664706 printings: decode_printings(m["printings"]),
665707 rarity: Rarity.decode(m["rarity"]),
666708 reserved: m["reserved"],
667709 rulings: m["rulings"] && Enum.map(m["rulings"], &Ruling.from_map/1),
668710 subtypes: m["subtypes"],
669711 supertypes: m["supertypes"] && Enum.map(m["supertypes"], &Supertype.decode/1),
670- text: m["text"],
671- toughness: m["toughness"],
712+ text: m["text"] && decode_text(m["text"]),
713+ toughness: m["toughness"] && decode_toughness(m["toughness"]),
672714 type: decode_type(m["type"]),
673715 types: Enum.map(m["types"], &Type.decode/1),
674716 variations: m["variations"],
Test case

test/inputs/json/misc/e0ac7.json

1 generated file · +35 −5
Melixirdefault / QuickType.ex+35 −5
@@ -22,6 +22,12 @@ defmodule Downsized do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding Downsized.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding Downsized.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding Downsized.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding Downsized.url"}
2733
@@ -37,7 +43,7 @@ defmodule Downsized do
3743 def from_map(m) do
3844 %Downsized{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -148,12 +154,36 @@ defmodule FixedHeight do
148154 width: String.t()
149155 }
150156
157+ def decode_frames(value) when is_binary(value), do: value
158+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
159+
160+ def encode_frames(value) when is_binary(value), do: value
161+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
162+
163+ def decode_hash(value) when is_binary(value), do: value
164+ def decode_hash(_), do: {:error, "Unexpected type when decoding FixedHeight.hash"}
165+
166+ def encode_hash(value) when is_binary(value), do: value
167+ def encode_hash(_), do: {:error, "Unexpected type when encoding FixedHeight.hash"}
168+
151169 def decode_height(value) when is_binary(value), do: value
152170 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
153171
154172 def encode_height(value) when is_binary(value), do: value
155173 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
156174
175+ def decode_mp4(value) when is_binary(value), do: value
176+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
177+
178+ def encode_mp4(value) when is_binary(value), do: value
179+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
180+
181+ def decode_mp4_size(value) when is_binary(value), do: value
182+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
183+
184+ def encode_mp4_size(value) when is_binary(value), do: value
185+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
186+
157187 def decode_size(value) when is_binary(value), do: value
158188 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
159189
@@ -186,11 +216,11 @@ defmodule FixedHeight do
186216
187217 def from_map(m) do
188218 %FixedHeight{
189- frames: m["frames"],
190- hash: m["hash"],
219+ frames: m["frames"] && decode_frames(m["frames"]),
220+ hash: m["hash"] && decode_hash(m["hash"]),
191221 height: decode_height(m["height"]),
192- mp4: m["mp4"],
193- mp4_size: m["mp4_size"],
222+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
223+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
194224 size: decode_size(m["size"]),
195225 url: decode_url(m["url"]),
196226 webp: decode_webp(m["webp"]),
Test case

test/inputs/json/misc/e8b04.json

1 generated file · +98 −14
Melixirdefault / QuickType.ex+98 −14
@@ -450,6 +450,12 @@ defmodule Select do
450450 column_field_name: String.t()
451451 }
452452
453+ def decode_aggregate(value) when is_binary(value), do: value
454+ def decode_aggregate(_), do: {:error, "Unexpected type when decoding Select.aggregate"}
455+
456+ def encode_aggregate(value) when is_binary(value), do: value
457+ def encode_aggregate(_), do: {:error, "Unexpected type when encoding Select.aggregate"}
458+
453459 def decode_column_field_name(value) when is_binary(value), do: value
454460 def decode_column_field_name(_), do: {:error, "Unexpected type when decoding Select.column_field_name"}
455461
@@ -458,7 +464,7 @@ defmodule Select do
458464
459465 def from_map(m) do
460466 %Select{
461- aggregate: m["aggregate"],
467+ aggregate: m["aggregate"] && decode_aggregate(m["aggregate"]),
462468 column_field_name: decode_column_field_name(m["columnFieldName"]),
463469 }
464470 end
@@ -720,12 +726,18 @@ defmodule Child do
720726 value: String.t() | nil
721727 }
722728
729+ def decode_value(value) when is_binary(value), do: value
730+ def decode_value(_), do: {:error, "Unexpected type when decoding Child.value"}
731+
732+ def encode_value(value) when is_binary(value), do: value
733+ def encode_value(_), do: {:error, "Unexpected type when encoding Child.value"}
734+
723735 def from_map(m) do
724736 %Child{
725737 column_field_name: ChildColumnFieldName.decode(m["columnFieldName"]),
726738 metadata: m["metadata"] && ChildMetadata.from_map(m["metadata"]),
727739 operator: ChildOperator.decode(m["operator"]),
728- value: m["value"],
740+ value: m["value"] && decode_value(m["value"]),
729741 }
730742 end
731743
@@ -809,13 +821,19 @@ defmodule Where do
809821 value: String.t() | nil
810822 }
811823
824+ def decode_value(value) when is_binary(value), do: value
825+ def decode_value(_), do: {:error, "Unexpected type when decoding Where.value"}
826+
827+ def encode_value(value) when is_binary(value), do: value
828+ def encode_value(_), do: {:error, "Unexpected type when encoding Where.value"}
829+
812830 def from_map(m) do
813831 %Where{
814832 children: m["children"] && Enum.map(m["children"], &Child.from_map/1),
815833 column_field_name: m["columnFieldName"] && ChildColumnFieldName.decode(m["columnFieldName"]),
816834 metadata: m["metadata"] && ChildMetadata.from_map(m["metadata"]),
817835 operator: WhereOperator.decode(m["operator"]),
818- value: m["value"],
836+ value: m["value"] && decode_value(m["value"]),
819837 }
820838 end
821839
@@ -1445,17 +1463,41 @@ defmodule TopLevelMetadata do
14451463 v1_archived_properties: V1ArchivedProperties.t() | nil
14461464 }
14471465
1466+ def decode_rdf_class(value) when is_binary(value), do: value
1467+ def decode_rdf_class(_), do: {:error, "Unexpected type when decoding TopLevelMetadata.rdf_class"}
1468+
1469+ def encode_rdf_class(value) when is_binary(value), do: value
1470+ def encode_rdf_class(_), do: {:error, "Unexpected type when encoding TopLevelMetadata.rdf_class"}
1471+
1472+ def decode_rdf_subject(value) when is_binary(value), do: value
1473+ def decode_rdf_subject(_), do: {:error, "Unexpected type when decoding TopLevelMetadata.rdf_subject"}
1474+
1475+ def encode_rdf_subject(value) when is_binary(value), do: value
1476+ def encode_rdf_subject(_), do: {:error, "Unexpected type when encoding TopLevelMetadata.rdf_subject"}
1477+
1478+ def decode_row_identifier(value) when is_binary(value), do: value
1479+ def decode_row_identifier(_), do: {:error, "Unexpected type when decoding TopLevelMetadata.row_identifier"}
1480+
1481+ def encode_row_identifier(value) when is_binary(value), do: value
1482+ def encode_row_identifier(_), do: {:error, "Unexpected type when encoding TopLevelMetadata.row_identifier"}
1483+
1484+ def decode_row_label(value) when is_binary(value), do: value
1485+ def decode_row_label(_), do: {:error, "Unexpected type when decoding TopLevelMetadata.row_label"}
1486+
1487+ def encode_row_label(value) when is_binary(value), do: value
1488+ def encode_row_label(_), do: {:error, "Unexpected type when encoding TopLevelMetadata.row_label"}
1489+
14481490 def from_map(m) do
14491491 %TopLevelMetadata{
14501492 available_display_types: m["availableDisplayTypes"] && Enum.map(m["availableDisplayTypes"], &DisplayType.decode/1),
14511493 custom_fields: m["custom_fields"] && CustomFields.from_map(m["custom_fields"]),
14521494 json_query: m["jsonQuery"] && JSONQuery.from_map(m["jsonQuery"]),
1453- rdf_class: m["rdfClass"],
1454- rdf_subject: m["rdfSubject"],
1495+ rdf_class: m["rdfClass"] && decode_rdf_class(m["rdfClass"]),
1496+ rdf_subject: m["rdfSubject"] && decode_rdf_subject(m["rdfSubject"]),
14551497 render_type_config: m["renderTypeConfig"] && MetadataRenderTypeConfig.from_map(m["renderTypeConfig"]),
14561498 rich_renderer_configs: m["richRendererConfigs"] && RichRendererConfigs.from_map(m["richRendererConfigs"]),
1457- row_identifier: m["rowIdentifier"],
1458- row_label: m["rowLabel"],
1499+ row_identifier: m["rowIdentifier"] && decode_row_identifier(m["rowIdentifier"]),
1500+ row_label: m["rowLabel"] && decode_row_label(m["rowLabel"]),
14591501 v1_archived_properties: m["v1_archived_properties"] && V1ArchivedProperties.from_map(m["v1_archived_properties"]),
14601502 }
14611503 end
@@ -1608,6 +1650,24 @@ defmodule Owner do
16081650 def encode_id(value) when is_binary(value), do: value
16091651 def encode_id(_), do: {:error, "Unexpected type when encoding Owner.id"}
16101652
1653+ def decode_profile_image_url_large(value) when is_binary(value), do: value
1654+ def decode_profile_image_url_large(_), do: {:error, "Unexpected type when decoding Owner.profile_image_url_large"}
1655+
1656+ def encode_profile_image_url_large(value) when is_binary(value), do: value
1657+ def encode_profile_image_url_large(_), do: {:error, "Unexpected type when encoding Owner.profile_image_url_large"}
1658+
1659+ def decode_profile_image_url_medium(value) when is_binary(value), do: value
1660+ def decode_profile_image_url_medium(_), do: {:error, "Unexpected type when decoding Owner.profile_image_url_medium"}
1661+
1662+ def encode_profile_image_url_medium(value) when is_binary(value), do: value
1663+ def encode_profile_image_url_medium(_), do: {:error, "Unexpected type when encoding Owner.profile_image_url_medium"}
1664+
1665+ def decode_profile_image_url_small(value) when is_binary(value), do: value
1666+ def decode_profile_image_url_small(_), do: {:error, "Unexpected type when decoding Owner.profile_image_url_small"}
1667+
1668+ def encode_profile_image_url_small(value) when is_binary(value), do: value
1669+ def encode_profile_image_url_small(_), do: {:error, "Unexpected type when encoding Owner.profile_image_url_small"}
1670+
16111671 def decode_screen_name(value) when is_binary(value), do: value
16121672 def decode_screen_name(_), do: {:error, "Unexpected type when decoding Owner.screen_name"}
16131673
@@ -1620,9 +1680,9 @@ defmodule Owner do
16201680 flags: m["flags"],
16211681 id: decode_id(m["id"]),
16221682 last_notification_seen_at: m["lastNotificationSeenAt"],
1623- profile_image_url_large: m["profileImageUrlLarge"],
1624- profile_image_url_medium: m["profileImageUrlMedium"],
1625- profile_image_url_small: m["profileImageUrlSmall"],
1683+ profile_image_url_large: m["profileImageUrlLarge"] && decode_profile_image_url_large(m["profileImageUrlLarge"]),
1684+ profile_image_url_medium: m["profileImageUrlMedium"] && decode_profile_image_url_medium(m["profileImageUrlMedium"]),
1685+ profile_image_url_small: m["profileImageUrlSmall"] && decode_profile_image_url_small(m["profileImageUrlSmall"]),
16261686 rights: m["rights"],
16271687 role_name: m["roleName"] && RoleName.decode(m["roleName"]),
16281688 screen_name: decode_screen_name(m["screenName"]),
@@ -2040,12 +2100,24 @@ defmodule TopLevelElement do
20402100 def encode_average_rating(value) when is_integer(value), do: value
20412101 def encode_average_rating(_), do: {:error, "Unexpected type when encoding TopLevelElement.average_rating"}
20422102
2103+ def decode_category(value) when is_binary(value), do: value
2104+ def decode_category(_), do: {:error, "Unexpected type when decoding TopLevelElement.category"}
2105+
2106+ def encode_category(value) when is_binary(value), do: value
2107+ def encode_category(_), do: {:error, "Unexpected type when encoding TopLevelElement.category"}
2108+
20432109 def decode_created_at(value) when is_integer(value), do: value
20442110 def decode_created_at(_), do: {:error, "Unexpected type when decoding TopLevelElement.created_at"}
20452111
20462112 def encode_created_at(value) when is_integer(value), do: value
20472113 def encode_created_at(_), do: {:error, "Unexpected type when encoding TopLevelElement.created_at"}
20482114
2115+ def decode_description(value) when is_binary(value), do: value
2116+ def decode_description(_), do: {:error, "Unexpected type when decoding TopLevelElement.description"}
2117+
2118+ def encode_description(value) when is_binary(value), do: value
2119+ def encode_description(_), do: {:error, "Unexpected type when encoding TopLevelElement.description"}
2120+
20492121 def decode_download_count(value) when is_integer(value), do: value
20502122 def decode_download_count(_), do: {:error, "Unexpected type when decoding TopLevelElement.download_count"}
20512123
@@ -2118,12 +2190,24 @@ defmodule TopLevelElement do
21182190 def encode_publication_group(value) when is_integer(value), do: value
21192191 def encode_publication_group(_), do: {:error, "Unexpected type when encoding TopLevelElement.publication_group"}
21202192
2193+ def decode_resource_name(value) when is_binary(value), do: value
2194+ def decode_resource_name(_), do: {:error, "Unexpected type when decoding TopLevelElement.resource_name"}
2195+
2196+ def encode_resource_name(value) when is_binary(value), do: value
2197+ def encode_resource_name(_), do: {:error, "Unexpected type when encoding TopLevelElement.resource_name"}
2198+
21212199 def decode_rights(value) when is_list(value), do: value
21222200 def decode_rights(_), do: {:error, "Unexpected type when decoding TopLevelElement.rights"}
21232201
21242202 def encode_rights(value) when is_list(value), do: value
21252203 def encode_rights(_), do: {:error, "Unexpected type when encoding TopLevelElement.rights"}
21262204
2205+ def decode_row_class(value) when is_binary(value), do: value
2206+ def decode_row_class(_), do: {:error, "Unexpected type when decoding TopLevelElement.row_class"}
2207+
2208+ def encode_row_class(value) when is_binary(value), do: value
2209+ def encode_row_class(_), do: {:error, "Unexpected type when encoding TopLevelElement.row_class"}
2210+
21272211 def decode_table_id(value) when is_integer(value), do: value
21282212 def decode_table_id(_), do: {:error, "Unexpected type when decoding TopLevelElement.table_id"}
21292213
@@ -2151,9 +2235,9 @@ defmodule TopLevelElement do
21512235 def from_map(m) do
21522236 %TopLevelElement{
21532237 average_rating: decode_average_rating(m["averageRating"]),
2154- category: m["category"],
2238+ category: m["category"] && decode_category(m["category"]),
21552239 created_at: decode_created_at(m["createdAt"]),
2156- description: m["description"],
2240+ description: m["description"] && decode_description(m["description"]),
21572241 display_type: m["displayType"] && DisplayType.decode(m["displayType"]),
21582242 download_count: decode_download_count(m["downloadCount"]),
21592243 flags: m["flags"] && Enum.map(m["flags"], &TopLevelFlag.decode/1),
@@ -2177,9 +2261,9 @@ defmodule TopLevelElement do
21772261 publication_group: decode_publication_group(m["publicationGroup"]),
21782262 publication_stage: PublicationStage.decode(m["publicationStage"]),
21792263 ratings: m["ratings"] && Ratings.from_map(m["ratings"]),
2180- resource_name: m["resourceName"],
2264+ resource_name: m["resourceName"] && decode_resource_name(m["resourceName"]),
21812265 rights: Enum.map(m["rights"], &Right.decode/1),
2182- row_class: m["rowClass"],
2266+ row_class: m["rowClass"] && decode_row_class(m["rowClass"]),
21832267 row_identifier_column_id: m["rowIdentifierColumnId"],
21842268 rows_updated_at: m["rowsUpdatedAt"],
21852269 rows_updated_by: m["rowsUpdatedBy"] && RowsUpdatedBy.decode(m["rowsUpdatedBy"]),
Test case

test/inputs/json/misc/f6a65.json

1 generated file · +35 −5
Melixirdefault / QuickType.ex+35 −5
@@ -22,6 +22,12 @@ defmodule The480_WStill do
2222 def encode_height(value) when is_binary(value), do: value
2323 def encode_height(_), do: {:error, "Unexpected type when encoding The480_WStill.height"}
2424
25+ def decode_size(value) when is_binary(value), do: value
26+ def decode_size(_), do: {:error, "Unexpected type when decoding The480_WStill.size"}
27+
28+ def encode_size(value) when is_binary(value), do: value
29+ def encode_size(_), do: {:error, "Unexpected type when encoding The480_WStill.size"}
30+
2531 def decode_url(value) when is_binary(value), do: value
2632 def decode_url(_), do: {:error, "Unexpected type when decoding The480_WStill.url"}
2733
@@ -37,7 +43,7 @@ defmodule The480_WStill do
3743 def from_map(m) do
3844 %The480_WStill{
3945 height: decode_height(m["height"]),
40- size: m["size"],
46+ size: m["size"] && decode_size(m["size"]),
4147 url: decode_url(m["url"]),
4248 width: decode_width(m["width"]),
4349 }
@@ -148,12 +154,36 @@ defmodule FixedHeight do
148154 width: String.t()
149155 }
150156
157+ def decode_frames(value) when is_binary(value), do: value
158+ def decode_frames(_), do: {:error, "Unexpected type when decoding FixedHeight.frames"}
159+
160+ def encode_frames(value) when is_binary(value), do: value
161+ def encode_frames(_), do: {:error, "Unexpected type when encoding FixedHeight.frames"}
162+
163+ def decode_hash(value) when is_binary(value), do: value
164+ def decode_hash(_), do: {:error, "Unexpected type when decoding FixedHeight.hash"}
165+
166+ def encode_hash(value) when is_binary(value), do: value
167+ def encode_hash(_), do: {:error, "Unexpected type when encoding FixedHeight.hash"}
168+
151169 def decode_height(value) when is_binary(value), do: value
152170 def decode_height(_), do: {:error, "Unexpected type when decoding FixedHeight.height"}
153171
154172 def encode_height(value) when is_binary(value), do: value
155173 def encode_height(_), do: {:error, "Unexpected type when encoding FixedHeight.height"}
156174
175+ def decode_mp4(value) when is_binary(value), do: value
176+ def decode_mp4(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4"}
177+
178+ def encode_mp4(value) when is_binary(value), do: value
179+ def encode_mp4(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4"}
180+
181+ def decode_mp4_size(value) when is_binary(value), do: value
182+ def decode_mp4_size(_), do: {:error, "Unexpected type when decoding FixedHeight.mp4_size"}
183+
184+ def encode_mp4_size(value) when is_binary(value), do: value
185+ def encode_mp4_size(_), do: {:error, "Unexpected type when encoding FixedHeight.mp4_size"}
186+
157187 def decode_size(value) when is_binary(value), do: value
158188 def decode_size(_), do: {:error, "Unexpected type when decoding FixedHeight.size"}
159189
@@ -186,11 +216,11 @@ defmodule FixedHeight do
186216
187217 def from_map(m) do
188218 %FixedHeight{
189- frames: m["frames"],
190- hash: m["hash"],
219+ frames: m["frames"] && decode_frames(m["frames"]),
220+ hash: m["hash"] && decode_hash(m["hash"]),
191221 height: decode_height(m["height"]),
192- mp4: m["mp4"],
193- mp4_size: m["mp4_size"],
222+ mp4: m["mp4"] && decode_mp4(m["mp4"]),
223+ mp4_size: m["mp4_size"] && decode_mp4_size(m["mp4_size"]),
194224 size: decode_size(m["size"]),
195225 url: decode_url(m["url"]),
196226 webp: decode_webp(m["webp"]),
Test case

test/inputs/json/misc/f74d5.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -67,6 +67,12 @@ defmodule CachedContents do
6767 top: [Top.t()]
6868 }
6969
70+ def decode_average(value) when is_binary(value), do: value
71+ def decode_average(_), do: {:error, "Unexpected type when decoding CachedContents.average"}
72+
73+ def encode_average(value) when is_binary(value), do: value
74+ def encode_average(_), do: {:error, "Unexpected type when encoding CachedContents.average"}
75+
7076 def decode_largest(value) when is_binary(value), do: value
7177 def decode_largest(_), do: {:error, "Unexpected type when decoding CachedContents.largest"}
7278
@@ -91,6 +97,12 @@ defmodule CachedContents do
9197 def encode_smallest(value) when is_binary(value), do: value
9298 def encode_smallest(_), do: {:error, "Unexpected type when encoding CachedContents.smallest"}
9399
100+ def decode_sum(value) when is_binary(value), do: value
101+ def decode_sum(_), do: {:error, "Unexpected type when decoding CachedContents.sum"}
102+
103+ def encode_sum(value) when is_binary(value), do: value
104+ def encode_sum(_), do: {:error, "Unexpected type when encoding CachedContents.sum"}
105+
94106 def decode_top(value) when is_list(value), do: value
95107 def decode_top(_), do: {:error, "Unexpected type when decoding CachedContents.top"}
96108
@@ -99,12 +111,12 @@ defmodule CachedContents do
99111
100112 def from_map(m) do
101113 %CachedContents{
102- average: m["average"],
114+ average: m["average"] && decode_average(m["average"]),
103115 largest: decode_largest(m["largest"]),
104116 non_null: decode_non_null(m["non_null"]),
105117 null: decode_null(m["null"]),
106118 smallest: decode_smallest(m["smallest"]),
107- sum: m["sum"],
119+ sum: m["sum"] && decode_sum(m["sum"]),
108120 top: Enum.map(m["top"], &Top.from_map/1),
109121 }
110122 end
Test case

test/inputs/json/misc/fcca3.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -67,6 +67,12 @@ defmodule CachedContents do
6767 top: [Top.t()]
6868 }
6969
70+ def decode_average(value) when is_binary(value), do: value
71+ def decode_average(_), do: {:error, "Unexpected type when decoding CachedContents.average"}
72+
73+ def encode_average(value) when is_binary(value), do: value
74+ def encode_average(_), do: {:error, "Unexpected type when encoding CachedContents.average"}
75+
7076 def decode_largest(value) when is_binary(value), do: value
7177 def decode_largest(_), do: {:error, "Unexpected type when decoding CachedContents.largest"}
7278
@@ -91,6 +97,12 @@ defmodule CachedContents do
9197 def encode_smallest(value) when is_binary(value), do: value
9298 def encode_smallest(_), do: {:error, "Unexpected type when encoding CachedContents.smallest"}
9399
100+ def decode_sum(value) when is_binary(value), do: value
101+ def decode_sum(_), do: {:error, "Unexpected type when decoding CachedContents.sum"}
102+
103+ def encode_sum(value) when is_binary(value), do: value
104+ def encode_sum(_), do: {:error, "Unexpected type when encoding CachedContents.sum"}
105+
94106 def decode_top(value) when is_list(value), do: value
95107 def decode_top(_), do: {:error, "Unexpected type when decoding CachedContents.top"}
96108
@@ -99,12 +111,12 @@ defmodule CachedContents do
99111
100112 def from_map(m) do
101113 %CachedContents{
102- average: m["average"],
114+ average: m["average"] && decode_average(m["average"]),
103115 largest: decode_largest(m["largest"]),
104116 non_null: decode_non_null(m["non_null"]),
105117 null: decode_null(m["null"]),
106118 smallest: decode_smallest(m["smallest"]),
107- sum: m["sum"],
119+ sum: m["sum"] && decode_sum(m["sum"]),
108120 top: Enum.map(m["top"], &Top.from_map/1),
109121 }
110122 end
@@ -190,11 +202,29 @@ defmodule Format do
190202 precision_style: String.t() | nil
191203 }
192204
205+ def decode_align(value) when is_binary(value), do: value
206+ def decode_align(_), do: {:error, "Unexpected type when decoding Format.align"}
207+
208+ def encode_align(value) when is_binary(value), do: value
209+ def encode_align(_), do: {:error, "Unexpected type when encoding Format.align"}
210+
211+ def decode_no_commas(value) when is_binary(value), do: value
212+ def decode_no_commas(_), do: {:error, "Unexpected type when decoding Format.no_commas"}
213+
214+ def encode_no_commas(value) when is_binary(value), do: value
215+ def encode_no_commas(_), do: {:error, "Unexpected type when encoding Format.no_commas"}
216+
217+ def decode_precision_style(value) when is_binary(value), do: value
218+ def decode_precision_style(_), do: {:error, "Unexpected type when decoding Format.precision_style"}
219+
220+ def encode_precision_style(value) when is_binary(value), do: value
221+ def encode_precision_style(_), do: {:error, "Unexpected type when encoding Format.precision_style"}
222+
193223 def from_map(m) do
194224 %Format{
195- align: m["align"],
196- no_commas: m["noCommas"],
197- precision_style: m["precisionStyle"],
225+ align: m["align"] && decode_align(m["align"]),
226+ no_commas: m["noCommas"] && decode_no_commas(m["noCommas"]),
227+ precision_style: m["precisionStyle"] && decode_precision_style(m["precisionStyle"]),
198228 }
199229 end
200230
@@ -238,6 +268,12 @@ defmodule Column do
238268 width: integer() | nil
239269 }
240270
271+ def decode_description(value) when is_binary(value), do: value
272+ def decode_description(_), do: {:error, "Unexpected type when decoding Column.description"}
273+
274+ def encode_description(value) when is_binary(value), do: value
275+ def encode_description(_), do: {:error, "Unexpected type when encoding Column.description"}
276+
241277 def decode_field_name(value) when is_binary(value), do: value
242278 def decode_field_name(_), do: {:error, "Unexpected type when decoding Column.field_name"}
243279
@@ -266,7 +302,7 @@ defmodule Column do
266302 %Column{
267303 cached_contents: m["cachedContents"] && CachedContents.from_map(m["cachedContents"]),
268304 data_type_name: TypeName.decode(m["dataTypeName"]),
269- description: m["description"],
305+ description: m["description"] && decode_description(m["description"]),
270306 field_name: decode_field_name(m["fieldName"]),
271307 flags: m["flags"],
272308 format: Format.from_map(m["format"]),
Test case

test/inputs/json/priority/bug2521.json

1 generated file · +7 −1
Melixirdefault / QuickType.ex+7 −1
@@ -14,6 +14,12 @@ defmodule Option do
1414 name: String.t()
1515 }
1616
17+ def decode_foo(value) when is_binary(value), do: value
18+ def decode_foo(_), do: {:error, "Unexpected type when decoding Option.foo"}
19+
20+ def encode_foo(value) when is_binary(value), do: value
21+ def encode_foo(_), do: {:error, "Unexpected type when encoding Option.foo"}
22+
1723 def decode_name(value) when is_binary(value), do: value
1824 def decode_name(_), do: {:error, "Unexpected type when decoding Option.name"}
1925
@@ -22,7 +28,7 @@ defmodule Option do
2228
2329 def from_map(m) do
2430 %Option{
25- foo: m["foo"],
31+ foo: m["foo"] && decode_foo(m["foo"]),
2632 name: decode_name(m["name"]),
2733 }
2834 end
Test case

test/inputs/json/priority/bug427.json

1 generated file · +147 −21
Melixirdefault / QuickType.ex+147 −21
@@ -533,11 +533,29 @@ defmodule GetSignatureComment do
533533 text: String.t() | nil
534534 }
535535
536+ def decode_returns(value) when is_binary(value), do: value
537+ def decode_returns(_), do: {:error, "Unexpected type when decoding GetSignatureComment.returns"}
538+
539+ def encode_returns(value) when is_binary(value), do: value
540+ def encode_returns(_), do: {:error, "Unexpected type when encoding GetSignatureComment.returns"}
541+
542+ def decode_short_text(value) when is_binary(value), do: value
543+ def decode_short_text(_), do: {:error, "Unexpected type when decoding GetSignatureComment.short_text"}
544+
545+ def encode_short_text(value) when is_binary(value), do: value
546+ def encode_short_text(_), do: {:error, "Unexpected type when encoding GetSignatureComment.short_text"}
547+
548+ def decode_text(value) when is_binary(value), do: value
549+ def decode_text(_), do: {:error, "Unexpected type when decoding GetSignatureComment.text"}
550+
551+ def encode_text(value) when is_binary(value), do: value
552+ def encode_text(_), do: {:error, "Unexpected type when encoding GetSignatureComment.text"}
553+
536554 def from_map(m) do
537555 %GetSignatureComment{
538- returns: m["returns"],
539- short_text: m["shortText"],
540- text: m["text"],
556+ returns: m["returns"] && decode_returns(m["returns"]),
557+ short_text: m["shortText"] && decode_short_text(m["shortText"]),
558+ text: m["text"] && decode_text(m["text"]),
541559 }
542560 end
543561
@@ -627,10 +645,22 @@ defmodule Comment3 do
627645 text: String.t() | nil
628646 }
629647
648+ def decode_short_text(value) when is_binary(value), do: value
649+ def decode_short_text(_), do: {:error, "Unexpected type when decoding Comment3.short_text"}
650+
651+ def encode_short_text(value) when is_binary(value), do: value
652+ def encode_short_text(_), do: {:error, "Unexpected type when encoding Comment3.short_text"}
653+
654+ def decode_text(value) when is_binary(value), do: value
655+ def decode_text(_), do: {:error, "Unexpected type when decoding Comment3.text"}
656+
657+ def encode_text(value) when is_binary(value), do: value
658+ def encode_text(_), do: {:error, "Unexpected type when encoding Comment3.text"}
659+
630660 def from_map(m) do
631661 %Comment3{
632- short_text: m["shortText"],
633- text: m["text"],
662+ short_text: m["shortText"] && decode_short_text(m["shortText"]),
663+ text: m["text"] && decode_text(m["text"]),
634664 }
635665 end
636666
@@ -1100,6 +1130,12 @@ defmodule GetSignature do
11001130 type_parameter: [GetSignature.t()] | nil
11011131 }
11021132
1133+ def decode_default_value(value) when is_binary(value), do: value
1134+ def decode_default_value(_), do: {:error, "Unexpected type when decoding GetSignature.default_value"}
1135+
1136+ def encode_default_value(value) when is_binary(value), do: value
1137+ def encode_default_value(_), do: {:error, "Unexpected type when encoding GetSignature.default_value"}
1138+
11031139 def decode_id(value) when is_integer(value), do: value
11041140 def decode_id(_), do: {:error, "Unexpected type when decoding GetSignature.id"}
11051141
@@ -1128,7 +1164,7 @@ defmodule GetSignature do
11281164 %GetSignature{
11291165 children: m["children"] && Enum.map(m["children"], &GetSignatureChild.from_map/1),
11301166 comment: m["comment"] && GetSignatureComment.from_map(m["comment"]),
1131- default_value: m["defaultValue"],
1167+ default_value: m["defaultValue"] && decode_default_value(m["defaultValue"]),
11321168 flags: GetSignatureFlags.from_map(m["flags"]),
11331169 groups: m["groups"] && Enum.map(m["groups"], &Group.from_map/1),
11341170 id: decode_id(m["id"]),
@@ -1441,6 +1477,12 @@ defmodule Child3 do
14411477 type: TypeElement.t() | nil
14421478 }
14431479
1480+ def decode_default_value(value) when is_binary(value), do: value
1481+ def decode_default_value(_), do: {:error, "Unexpected type when decoding Child3.default_value"}
1482+
1483+ def encode_default_value(value) when is_binary(value), do: value
1484+ def encode_default_value(_), do: {:error, "Unexpected type when encoding Child3.default_value"}
1485+
14441486 def decode_id(value) when is_integer(value), do: value
14451487 def decode_id(_), do: {:error, "Unexpected type when decoding Child3.id"}
14461488
@@ -1468,7 +1510,7 @@ defmodule Child3 do
14681510 def from_map(m) do
14691511 %Child3{
14701512 comment: m["comment"] && Comment1.from_map(m["comment"]),
1471- default_value: m["defaultValue"],
1513+ default_value: m["defaultValue"] && decode_default_value(m["defaultValue"]),
14721514 flags: Flags1.from_map(m["flags"]),
14731515 id: decode_id(m["id"]),
14741516 kind: decode_kind(m["kind"]),
@@ -1566,12 +1608,30 @@ defmodule Comment4 do
15661608 text: String.t() | nil
15671609 }
15681610
1611+ def decode_returns(value) when is_binary(value), do: value
1612+ def decode_returns(_), do: {:error, "Unexpected type when decoding Comment4.returns"}
1613+
1614+ def encode_returns(value) when is_binary(value), do: value
1615+ def encode_returns(_), do: {:error, "Unexpected type when encoding Comment4.returns"}
1616+
1617+ def decode_short_text(value) when is_binary(value), do: value
1618+ def decode_short_text(_), do: {:error, "Unexpected type when decoding Comment4.short_text"}
1619+
1620+ def encode_short_text(value) when is_binary(value), do: value
1621+ def encode_short_text(_), do: {:error, "Unexpected type when encoding Comment4.short_text"}
1622+
1623+ def decode_text(value) when is_binary(value), do: value
1624+ def decode_text(_), do: {:error, "Unexpected type when decoding Comment4.text"}
1625+
1626+ def encode_text(value) when is_binary(value), do: value
1627+ def encode_text(_), do: {:error, "Unexpected type when encoding Comment4.text"}
1628+
15691629 def from_map(m) do
15701630 %Comment4{
1571- returns: m["returns"],
1572- short_text: m["shortText"],
1631+ returns: m["returns"] && decode_returns(m["returns"]),
1632+ short_text: m["shortText"] && decode_short_text(m["shortText"]),
15731633 tags: m["tags"] && Enum.map(m["tags"], &Tag.from_map/1),
1574- text: m["text"],
1634+ text: m["text"] && decode_text(m["text"]),
15751635 }
15761636 end
15771637
@@ -1748,6 +1808,12 @@ defmodule Type4 do
17481808 type_arguments: [ElementType.t()] | nil
17491809 }
17501810
1811+ def decode_name(value) when is_binary(value), do: value
1812+ def decode_name(_), do: {:error, "Unexpected type when decoding Type4.name"}
1813+
1814+ def encode_name(value) when is_binary(value), do: value
1815+ def encode_name(_), do: {:error, "Unexpected type when encoding Type4.name"}
1816+
17511817 def from_map(m) do
17521818 %Type4{
17531819 constraint: m["constraint"] && ExtendedBy.from_map(m["constraint"]),
@@ -1755,7 +1821,7 @@ defmodule Type4 do
17551821 element_type: m["elementType"] && ElementType.from_map(m["elementType"]),
17561822 elements: m["elements"] && Enum.map(m["elements"], &ExtendedBy.from_map/1),
17571823 id: m["id"],
1758- name: m["name"],
1824+ name: m["name"] && decode_name(m["name"]),
17591825 type: TypeEnum.decode(m["type"]),
17601826 type_arguments: m["typeArguments"] && Enum.map(m["typeArguments"], &ElementType.from_map/1),
17611827 }
@@ -2532,6 +2598,12 @@ defmodule Type5 do
25322598 types: [TypeElement.t()] | nil
25332599 }
25342600
2601+ def decode_name(value) when is_binary(value), do: value
2602+ def decode_name(_), do: {:error, "Unexpected type when decoding Type5.name"}
2603+
2604+ def encode_name(value) when is_binary(value), do: value
2605+ def encode_name(_), do: {:error, "Unexpected type when encoding Type5.name"}
2606+
25352607 def from_map(m) do
25362608 %Type5{
25372609 constraint: m["constraint"] && ExtendedBy.from_map(m["constraint"]),
@@ -2539,7 +2611,7 @@ defmodule Type5 do
25392611 element_type: m["elementType"] && ExtendedBy.from_map(m["elementType"]),
25402612 elements: m["elements"] && Enum.map(m["elements"], &ElementType.from_map/1),
25412613 id: m["id"],
2542- name: m["name"],
2614+ name: m["name"] && decode_name(m["name"]),
25432615 type: TypeEnum.decode(m["type"]),
25442616 type_arguments: m["typeArguments"] && Enum.map(m["typeArguments"], &TypeArgument1.from_map/1),
25452617 types: m["types"] && Enum.map(m["types"], &TypeElement.from_map/1),
@@ -2597,6 +2669,12 @@ defmodule Child2 do
25972669 type: Type5.t() | nil
25982670 }
25992671
2672+ def decode_default_value(value) when is_binary(value), do: value
2673+ def decode_default_value(_), do: {:error, "Unexpected type when decoding Child2.default_value"}
2674+
2675+ def encode_default_value(value) when is_binary(value), do: value
2676+ def encode_default_value(_), do: {:error, "Unexpected type when encoding Child2.default_value"}
2677+
26002678 def decode_id(value) when is_integer(value), do: value
26012679 def decode_id(_), do: {:error, "Unexpected type when decoding Child2.id"}
26022680
@@ -2625,7 +2703,7 @@ defmodule Child2 do
26252703 %Child2{
26262704 children: m["children"] && Enum.map(m["children"], &Child3.from_map/1),
26272705 comment: m["comment"] && Comment4.from_map(m["comment"]),
2628- default_value: m["defaultValue"],
2706+ default_value: m["defaultValue"] && decode_default_value(m["defaultValue"]),
26292707 flags: Flags4.from_map(m["flags"]),
26302708 get_signature: m["getSignature"] && GetSignature.from_map(m["getSignature"]),
26312709 groups: m["groups"] && Enum.map(m["groups"], &Group.from_map/1),
@@ -2796,6 +2874,12 @@ defmodule Child5 do
27962874 type: Type6.t()
27972875 }
27982876
2877+ def decode_default_value(value) when is_binary(value), do: value
2878+ def decode_default_value(_), do: {:error, "Unexpected type when decoding Child5.default_value"}
2879+
2880+ def encode_default_value(value) when is_binary(value), do: value
2881+ def encode_default_value(_), do: {:error, "Unexpected type when encoding Child5.default_value"}
2882+
27992883 def decode_id(value) when is_integer(value), do: value
28002884 def decode_id(_), do: {:error, "Unexpected type when decoding Child5.id"}
28012885
@@ -2823,7 +2907,7 @@ defmodule Child5 do
28232907 def from_map(m) do
28242908 %Child5{
28252909 comment: Comment2.from_map(m["comment"]),
2826- default_value: m["defaultValue"],
2910+ default_value: m["defaultValue"] && decode_default_value(m["defaultValue"]),
28272911 flags: Flags2.from_map(m["flags"]),
28282912 id: decode_id(m["id"]),
28292913 kind: decode_kind(m["kind"]),
@@ -2964,12 +3048,18 @@ defmodule Type8 do
29643048 type_arguments: [ElementType.t()] | nil
29653049 }
29663050
3051+ def decode_name(value) when is_binary(value), do: value
3052+ def decode_name(_), do: {:error, "Unexpected type when decoding Type8.name"}
3053+
3054+ def encode_name(value) when is_binary(value), do: value
3055+ def encode_name(_), do: {:error, "Unexpected type when encoding Type8.name"}
3056+
29673057 def from_map(m) do
29683058 %Type8{
29693059 declaration: m["declaration"] && Declaration3.from_map(m["declaration"]),
29703060 element_type: m["elementType"] && ElementType.from_map(m["elementType"]),
29713061 id: m["id"],
2972- name: m["name"],
3062+ name: m["name"] && decode_name(m["name"]),
29733063 type: TypeEnum.decode(m["type"]),
29743064 type_arguments: m["typeArguments"] && Enum.map(m["typeArguments"], &ElementType.from_map/1),
29753065 }
@@ -3015,6 +3105,12 @@ defmodule Parameter3 do
30153105 type: Type8.t()
30163106 }
30173107
3108+ def decode_default_value(value) when is_binary(value), do: value
3109+ def decode_default_value(_), do: {:error, "Unexpected type when decoding Parameter3.default_value"}
3110+
3111+ def encode_default_value(value) when is_binary(value), do: value
3112+ def encode_default_value(_), do: {:error, "Unexpected type when encoding Parameter3.default_value"}
3113+
30183114 def decode_id(value) when is_integer(value), do: value
30193115 def decode_id(_), do: {:error, "Unexpected type when decoding Parameter3.id"}
30203116
@@ -3033,16 +3129,22 @@ defmodule Parameter3 do
30333129 def encode_name(value) when is_binary(value), do: value
30343130 def encode_name(_), do: {:error, "Unexpected type when encoding Parameter3.name"}
30353131
3132+ def decode_original_name(value) when is_binary(value), do: value
3133+ def decode_original_name(_), do: {:error, "Unexpected type when decoding Parameter3.original_name"}
3134+
3135+ def encode_original_name(value) when is_binary(value), do: value
3136+ def encode_original_name(_), do: {:error, "Unexpected type when encoding Parameter3.original_name"}
3137+
30363138 def from_map(m) do
30373139 %Parameter3{
30383140 comment: m["comment"] && Comment3.from_map(m["comment"]),
3039- default_value: m["defaultValue"],
3141+ default_value: m["defaultValue"] && decode_default_value(m["defaultValue"]),
30403142 flags: Flags3.from_map(m["flags"]),
30413143 id: decode_id(m["id"]),
30423144 kind: decode_kind(m["kind"]),
30433145 kind_string: ParameterKindString.decode(m["kindString"]),
30443146 name: decode_name(m["name"]),
3045- original_name: m["originalName"],
3147+ original_name: m["originalName"] && decode_original_name(m["originalName"]),
30463148 type: Type8.from_map(m["type"]),
30473149 }
30483150 end
@@ -3546,17 +3648,29 @@ defmodule Type10 do
35463648 value: String.t() | nil
35473649 }
35483650
3651+ def decode_name(value) when is_binary(value), do: value
3652+ def decode_name(_), do: {:error, "Unexpected type when decoding Type10.name"}
3653+
3654+ def encode_name(value) when is_binary(value), do: value
3655+ def encode_name(_), do: {:error, "Unexpected type when encoding Type10.name"}
3656+
3657+ def decode_value(value) when is_binary(value), do: value
3658+ def decode_value(_), do: {:error, "Unexpected type when decoding Type10.value"}
3659+
3660+ def encode_value(value) when is_binary(value), do: value
3661+ def encode_value(_), do: {:error, "Unexpected type when encoding Type10.value"}
3662+
35493663 def from_map(m) do
35503664 %Type10{
35513665 declaration: m["declaration"] && Declaration4.from_map(m["declaration"]),
35523666 element_type: m["elementType"] && ElementType.from_map(m["elementType"]),
35533667 elements: m["elements"] && Enum.map(m["elements"], &ExtendedBy.from_map/1),
35543668 id: m["id"],
3555- name: m["name"],
3669+ name: m["name"] && decode_name(m["name"]),
35563670 type: TypeEnum.decode(m["type"]),
35573671 type_arguments: m["typeArguments"] && Enum.map(m["typeArguments"], &TypeArgument2.from_map/1),
35583672 types: m["types"] && Enum.map(m["types"], &ExtendedBy.from_map/1),
3559- value: m["value"],
3673+ value: m["value"] && decode_value(m["value"]),
35603674 }
35613675 end
35623676
@@ -3599,6 +3713,12 @@ defmodule Type12 do
35993713 type: String.t()
36003714 }
36013715
3716+ def decode_operator(value) when is_binary(value), do: value
3717+ def decode_operator(_), do: {:error, "Unexpected type when decoding Type12.operator"}
3718+
3719+ def encode_operator(value) when is_binary(value), do: value
3720+ def encode_operator(_), do: {:error, "Unexpected type when encoding Type12.operator"}
3721+
36023722 def decode_type(value) when is_binary(value), do: value
36033723 def decode_type(_), do: {:error, "Unexpected type when decoding Type12.type"}
36043724
@@ -3609,7 +3729,7 @@ defmodule Type12 do
36093729 %Type12{
36103730 id: m["id"],
36113731 name: m["name"] && Name.decode(m["name"]),
3612- operator: m["operator"],
3732+ operator: m["operator"] && decode_operator(m["operator"]),
36133733 target: m["target"] && ElementType.from_map(m["target"]),
36143734 type: decode_type(m["type"]),
36153735 }
@@ -3737,6 +3857,12 @@ defmodule Child1 do
37373857 type_parameter: [TypeParameter.t()] | nil
37383858 }
37393859
3860+ def decode_default_value(value) when is_binary(value), do: value
3861+ def decode_default_value(_), do: {:error, "Unexpected type when decoding Child1.default_value"}
3862+
3863+ def encode_default_value(value) when is_binary(value), do: value
3864+ def encode_default_value(_), do: {:error, "Unexpected type when encoding Child1.default_value"}
3865+
37403866 def decode_id(value) when is_integer(value), do: value
37413867 def decode_id(_), do: {:error, "Unexpected type when decoding Child1.id"}
37423868
@@ -3765,7 +3891,7 @@ defmodule Child1 do
37653891 %Child1{
37663892 children: m["children"] && Enum.map(m["children"], &Child2.from_map/1),
37673893 comment: m["comment"] && Comment4.from_map(m["comment"]),
3768- default_value: m["defaultValue"],
3894+ default_value: m["defaultValue"] && decode_default_value(m["defaultValue"]),
37693895 extended_by: m["extendedBy"] && Enum.map(m["extendedBy"], &ExtendedBy.from_map/1),
37703896 extended_types: m["extendedTypes"] && Enum.map(m["extendedTypes"], &ExtendedBy.from_map/1),
37713897 flags: Flags6.from_map(m["flags"]),
Test case

test/inputs/json/priority/combinations1.json

1 generated file · +21 −3
Melixirdefault / QuickType.ex+21 −3
@@ -246,6 +246,12 @@ defmodule ChemotherapeuticClass do
246246 unshy: nil | nil
247247 }
248248
249+ def decode_disdiapason(value) when is_binary(value), do: value
250+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding ChemotherapeuticClass.disdiapason"}
251+
252+ def encode_disdiapason(value) when is_binary(value), do: value
253+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding ChemotherapeuticClass.disdiapason"}
254+
249255 def from_map(m) do
250256 %ChemotherapeuticClass{
251257 angioneurotic: m["angioneurotic"],
@@ -255,7 +261,7 @@ defmodule ChemotherapeuticClass do
255261 caulis: m["caulis"],
256262 chalcus: m["chalcus"],
257263 chirotherium: m["Chirotherium"],
258- disdiapason: m["disdiapason"],
264+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
259265 enteradenological: m["enteradenological"],
260266 homocerc: m["homocerc"],
261267 imporosity: m["imporosity"],
@@ -427,13 +433,19 @@ defmodule CoadjustClass do
427433 unchargeable: nil | nil
428434 }
429435
436+ def decode_disdiapason(value) when is_binary(value), do: value
437+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding CoadjustClass.disdiapason"}
438+
439+ def encode_disdiapason(value) when is_binary(value), do: value
440+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding CoadjustClass.disdiapason"}
441+
430442 def from_map(m) do
431443 %CoadjustClass{
432444 amidosulphonal: m["amidosulphonal"],
433445 benny: m["Benny"],
434446 catharticalness: m["catharticalness"],
435447 chirotherium: m["Chirotherium"],
436- disdiapason: m["disdiapason"],
448+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
437449 ensnare: m["ensnare"],
438450 homocerc: m["homocerc"],
439451 hybridizer: m["hybridizer"],
@@ -2001,6 +2013,12 @@ defmodule HemocoeleClass do
20012013 walt: nil | nil
20022014 }
20032015
2016+ def decode_disdiapason(value) when is_binary(value), do: value
2017+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding HemocoeleClass.disdiapason"}
2018+
2019+ def encode_disdiapason(value) when is_binary(value), do: value
2020+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding HemocoeleClass.disdiapason"}
2021+
20042022 def from_map(m) do
20052023 %HemocoeleClass{
20062024 acrogamy: m["acrogamy"],
@@ -2009,7 +2027,7 @@ defmodule HemocoeleClass do
20092027 berat: m["berat"],
20102028 catharticalness: m["catharticalness"],
20112029 chirotherium: m["Chirotherium"],
2012- disdiapason: m["disdiapason"],
2030+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
20132031 disproportionably: m["disproportionably"],
20142032 erythrite: m["erythrite"],
20152033 graphic: m["graphic"],
Test case

test/inputs/json/priority/combinations2.json

1 generated file · +21 −3
Melixirdefault / QuickType.ex+21 −3
@@ -323,6 +323,12 @@ defmodule Amphithyron do
323323 undecimal: integer() | nil
324324 }
325325
326+ def decode_disdiapason(value) when is_binary(value), do: value
327+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding Amphithyron.disdiapason"}
328+
329+ def encode_disdiapason(value) when is_binary(value), do: value
330+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding Amphithyron.disdiapason"}
331+
326332 def from_map(m) do
327333 %Amphithyron{
328334 akroasis: m["akroasis"],
@@ -331,7 +337,7 @@ defmodule Amphithyron do
331337 catharticalness: m["catharticalness"],
332338 chirotherium: m["Chirotherium"],
333339 conductometric: m["conductometric"],
334- disdiapason: m["disdiapason"],
340+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
335341 ensilation: m["ensilation"],
336342 eyebolt: m["eyebolt"],
337343 fistulated: m["fistulated"],
@@ -1057,6 +1063,12 @@ defmodule DiscordiaClass do
10571063 wingle: integer() | nil
10581064 }
10591065
1066+ def decode_disdiapason(value) when is_binary(value), do: value
1067+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding DiscordiaClass.disdiapason"}
1068+
1069+ def encode_disdiapason(value) when is_binary(value), do: value
1070+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding DiscordiaClass.disdiapason"}
1071+
10601072 def from_map(m) do
10611073 %DiscordiaClass{
10621074 altaic: m["Altaic"],
@@ -1065,7 +1077,7 @@ defmodule DiscordiaClass do
10651077 catharticalness: m["catharticalness"],
10661078 chirotherium: m["Chirotherium"],
10671079 disciplinability: m["disciplinability"],
1068- disdiapason: m["disdiapason"],
1080+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
10691081 goofer: m["goofer"],
10701082 homocerc: m["homocerc"],
10711083 laryngograph: m["laryngograph"],
@@ -1371,6 +1383,12 @@ defmodule LaviniaClass do
13711383 uproute: integer() | nil
13721384 }
13731385
1386+ def decode_disdiapason(value) when is_binary(value), do: value
1387+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding LaviniaClass.disdiapason"}
1388+
1389+ def encode_disdiapason(value) when is_binary(value), do: value
1390+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding LaviniaClass.disdiapason"}
1391+
13741392 def from_map(m) do
13751393 %LaviniaClass{
13761394 agitable: m["agitable"],
@@ -1381,7 +1399,7 @@ defmodule LaviniaClass do
13811399 chirotherium: m["Chirotherium"],
13821400 cholesteatomatous: m["cholesteatomatous"],
13831401 deprivement: m["deprivement"],
1384- disdiapason: m["disdiapason"],
1402+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
13851403 flippantness: m["flippantness"],
13861404 fogproof: m["fogproof"],
13871405 homocerc: m["homocerc"],
Test case

test/inputs/json/priority/combinations3.json

1 generated file · +35 −5
Melixirdefault / QuickType.ex+35 −5
@@ -666,6 +666,12 @@ defmodule LupusClass do
666666 vendible: integer() | nil
667667 }
668668
669+ def decode_disdiapason(value) when is_binary(value), do: value
670+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding LupusClass.disdiapason"}
671+
672+ def encode_disdiapason(value) when is_binary(value), do: value
673+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding LupusClass.disdiapason"}
674+
669675 def from_map(m) do
670676 %LupusClass{
671677 catharticalness: m["catharticalness"],
@@ -673,7 +679,7 @@ defmodule LupusClass do
673679 chlorioninae: m["Chlorioninae"],
674680 corvinae: m["Corvinae"],
675681 crassina: m["Crassina"],
676- disdiapason: m["disdiapason"],
682+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
677683 exiguity: m["exiguity"],
678684 farcist: m["farcist"],
679685 holographical: m["holographical"],
@@ -790,6 +796,12 @@ defmodule Maslin do
790796 unjudiciously: nil | nil
791797 }
792798
799+ def decode_disdiapason(value) when is_binary(value), do: value
800+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding Maslin.disdiapason"}
801+
802+ def encode_disdiapason(value) when is_binary(value), do: value
803+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding Maslin.disdiapason"}
804+
793805 def from_map(m) do
794806 %Maslin{
795807 alicant: m["Alicant"],
@@ -805,7 +817,7 @@ defmodule Maslin do
805817 curtailedly: m["curtailedly"],
806818 dellenite: m["dellenite"],
807819 dimitry: m["Dimitry"],
808- disdiapason: m["disdiapason"],
820+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
809821 edifying: m["edifying"],
810822 ethmoiditis: m["ethmoiditis"],
811823 gastralgy: m["gastralgy"],
@@ -1011,6 +1023,12 @@ defmodule MonotheisticallyClass do
10111023 whitestone: nil | nil
10121024 }
10131025
1026+ def decode_disdiapason(value) when is_binary(value), do: value
1027+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding MonotheisticallyClass.disdiapason"}
1028+
1029+ def encode_disdiapason(value) when is_binary(value), do: value
1030+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding MonotheisticallyClass.disdiapason"}
1031+
10141032 def from_map(m) do
10151033 %MonotheisticallyClass{
10161034 blaspheme: m["blaspheme"],
@@ -1018,7 +1036,7 @@ defmodule MonotheisticallyClass do
10181036 celiosalpingectomy: m["celiosalpingectomy"],
10191037 chirotherium: m["Chirotherium"],
10201038 consummativeness: m["consummativeness"],
1021- disdiapason: m["disdiapason"],
1039+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
10221040 egestive: m["egestive"],
10231041 enchylema: m["enchylema"],
10241042 gasconade: m["gasconade"],
@@ -1612,6 +1630,12 @@ defmodule PiaculumClass do
16121630 zipper: integer() | nil
16131631 }
16141632
1633+ def decode_disdiapason(value) when is_binary(value), do: value
1634+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding PiaculumClass.disdiapason"}
1635+
1636+ def encode_disdiapason(value) when is_binary(value), do: value
1637+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding PiaculumClass.disdiapason"}
1638+
16151639 def from_map(m) do
16161640 %PiaculumClass{
16171641 alada: m["alada"],
@@ -1621,7 +1645,7 @@ defmodule PiaculumClass do
16211645 chirotherium: m["Chirotherium"],
16221646 decardinalize: m["decardinalize"],
16231647 discouragement: m["discouragement"],
1624- disdiapason: m["disdiapason"],
1648+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
16251649 doitrified: m["doitrified"],
16261650 hexaspermous: m["hexaspermous"],
16271651 homocerc: m["homocerc"],
@@ -1716,6 +1740,12 @@ defmodule Pneumocele do
17161740 visitorial: nil | nil
17171741 }
17181742
1743+ def decode_disdiapason(value) when is_binary(value), do: value
1744+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding Pneumocele.disdiapason"}
1745+
1746+ def encode_disdiapason(value) when is_binary(value), do: value
1747+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding Pneumocele.disdiapason"}
1748+
17191749 def from_map(m) do
17201750 %Pneumocele{
17211751 carbonarism: m["Carbonarism"],
@@ -1725,7 +1755,7 @@ defmodule Pneumocele do
17251755 cobbly: m["cobbly"],
17261756 conchyliferous: m["conchyliferous"],
17271757 congregation: m["congregation"],
1728- disdiapason: m["disdiapason"],
1758+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
17291759 enterotomy: m["enterotomy"],
17301760 entophytal: m["entophytal"],
17311761 fewtrils: m["fewtrils"],
Test case

test/inputs/json/priority/combinations4.json

1 generated file · +42 −6
Melixirdefault / QuickType.ex+42 −6
@@ -533,6 +533,12 @@ defmodule Reimagine do
533533 waltzlike: nil | nil
534534 }
535535
536+ def decode_disdiapason(value) when is_binary(value), do: value
537+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding Reimagine.disdiapason"}
538+
539+ def encode_disdiapason(value) when is_binary(value), do: value
540+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding Reimagine.disdiapason"}
541+
536542 def from_map(m) do
537543 %Reimagine{
538544 adducible: m["adducible"],
@@ -541,7 +547,7 @@ defmodule Reimagine do
541547 catharticalness: m["catharticalness"],
542548 chirotherium: m["Chirotherium"],
543549 chrysamine: m["chrysamine"],
544- disdiapason: m["disdiapason"],
550+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
545551 fluxweed: m["fluxweed"],
546552 glaucine: m["glaucine"],
547553 grobianism: m["grobianism"],
@@ -1267,6 +1273,12 @@ defmodule SaxtenClass do
12671273 withdrawnness: nil | nil
12681274 }
12691275
1276+ def decode_disdiapason(value) when is_binary(value), do: value
1277+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding SaxtenClass.disdiapason"}
1278+
1279+ def encode_disdiapason(value) when is_binary(value), do: value
1280+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding SaxtenClass.disdiapason"}
1281+
12701282 def from_map(m) do
12711283 %SaxtenClass{
12721284 algarrobilla: m["algarrobilla"],
@@ -1274,7 +1286,7 @@ defmodule SaxtenClass do
12741286 catharticalness: m["catharticalness"],
12751287 centaurid: m["Centaurid"],
12761288 chirotherium: m["Chirotherium"],
1277- disdiapason: m["disdiapason"],
1289+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
12781290 flix: m["flix"],
12791291 germanely: m["germanely"],
12801292 homocerc: m["homocerc"],
@@ -1791,13 +1803,19 @@ defmodule Staghunting do
17911803 ungirlish: integer() | nil
17921804 }
17931805
1806+ def decode_disdiapason(value) when is_binary(value), do: value
1807+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding Staghunting.disdiapason"}
1808+
1809+ def encode_disdiapason(value) when is_binary(value), do: value
1810+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding Staghunting.disdiapason"}
1811+
17941812 def from_map(m) do
17951813 %Staghunting{
17961814 calorimetric: m["calorimetric"],
17971815 canid: m["canid"],
17981816 catharticalness: m["catharticalness"],
17991817 chirotherium: m["Chirotherium"],
1800- disdiapason: m["disdiapason"],
1818+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
18011819 ditriglyphic: m["ditriglyphic"],
18021820 floriferousness: m["floriferousness"],
18031821 gamelike: m["gamelike"],
@@ -1895,6 +1913,12 @@ defmodule StrenuosityClass do
18951913 yankeeist: integer() | nil
18961914 }
18971915
1916+ def decode_disdiapason(value) when is_binary(value), do: value
1917+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding StrenuosityClass.disdiapason"}
1918+
1919+ def encode_disdiapason(value) when is_binary(value), do: value
1920+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding StrenuosityClass.disdiapason"}
1921+
18981922 def from_map(m) do
18991923 %StrenuosityClass{
19001924 bliss: m["bliss"],
@@ -1903,7 +1927,7 @@ defmodule StrenuosityClass do
19031927 catharticalness: m["catharticalness"],
19041928 chirotherium: m["Chirotherium"],
19051929 crumblingness: m["crumblingness"],
1906- disdiapason: m["disdiapason"],
1930+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
19071931 engagedly: m["engagedly"],
19081932 fightable: m["fightable"],
19091933 hoariness: m["hoariness"],
@@ -1999,6 +2023,12 @@ defmodule TruantcyClass do
19992023 yuman: nil | nil
20002024 }
20012025
2026+ def decode_disdiapason(value) when is_binary(value), do: value
2027+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding TruantcyClass.disdiapason"}
2028+
2029+ def encode_disdiapason(value) when is_binary(value), do: value
2030+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding TruantcyClass.disdiapason"}
2031+
20022032 def from_map(m) do
20032033 %TruantcyClass{
20042034 alfiona: m["alfiona"],
@@ -2008,7 +2038,7 @@ defmodule TruantcyClass do
20082038 ceroxyle: m["ceroxyle"],
20092039 chirotherium: m["Chirotherium"],
20102040 chorology: m["chorology"],
2011- disdiapason: m["disdiapason"],
2041+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
20122042 enmarble: m["enmarble"],
20132043 epeira: m["Epeira"],
20142044 eurylaimi: m["Eurylaimi"],
@@ -2103,6 +2133,12 @@ defmodule UnimpeachablyClass do
21032133 unsuggestedness: integer() | nil
21042134 }
21052135
2136+ def decode_disdiapason(value) when is_binary(value), do: value
2137+ def decode_disdiapason(_), do: {:error, "Unexpected type when decoding UnimpeachablyClass.disdiapason"}
2138+
2139+ def encode_disdiapason(value) when is_binary(value), do: value
2140+ def encode_disdiapason(_), do: {:error, "Unexpected type when encoding UnimpeachablyClass.disdiapason"}
2141+
21062142 def from_map(m) do
21072143 %UnimpeachablyClass{
21082144 acerin: m["acerin"],
@@ -2112,7 +2148,7 @@ defmodule UnimpeachablyClass do
21122148 chlorophylligenous: m["chlorophylligenous"],
21132149 conversational: m["conversational"],
21142150 demiowl: m["demiowl"],
2115- disdiapason: m["disdiapason"],
2151+ disdiapason: m["disdiapason"] && decode_disdiapason(m["disdiapason"]),
21162152 ectorhinal: m["ectorhinal"],
21172153 gamblesomeness: m["gamblesomeness"],
21182154 homocerc: m["homocerc"],
Test case

test/inputs/json/priority/empty-enum.json

1 generated file · +7 −1
Melixirdefault / QuickType.ex+7 −1
@@ -12,9 +12,15 @@ defmodule Foo do
1212 bar: String.t() | nil
1313 }
1414
15+ def decode_bar(value) when is_binary(value), do: value
16+ def decode_bar(_), do: {:error, "Unexpected type when decoding Foo.bar"}
17+
18+ def encode_bar(value) when is_binary(value), do: value
19+ def encode_bar(_), do: {:error, "Unexpected type when encoding Foo.bar"}
20+
1521 def from_map(m) do
1622 %Foo{
17- bar: m["bar"],
23+ bar: m["bar"] && decode_bar(m["bar"]),
1824 }
1925 end
Test case

test/inputs/json/priority/nbl-stats.json

1 generated file · +84 −12
Melixirdefault / QuickType.ex+84 −12
@@ -529,12 +529,36 @@ defmodule Pbp do
529529 tno: integer()
530530 }
531531
532+ def decode_family_name(value) when is_binary(value), do: value
533+ def decode_family_name(_), do: {:error, "Unexpected type when decoding Pbp.family_name"}
534+
535+ def encode_family_name(value) when is_binary(value), do: value
536+ def encode_family_name(_), do: {:error, "Unexpected type when encoding Pbp.family_name"}
537+
538+ def decode_first_name(value) when is_binary(value), do: value
539+ def decode_first_name(_), do: {:error, "Unexpected type when decoding Pbp.first_name"}
540+
541+ def encode_first_name(value) when is_binary(value), do: value
542+ def encode_first_name(_), do: {:error, "Unexpected type when encoding Pbp.first_name"}
543+
532544 def decode_gt(value) when is_binary(value), do: value
533545 def decode_gt(_), do: {:error, "Unexpected type when decoding Pbp.gt"}
534546
535547 def encode_gt(value) when is_binary(value), do: value
536548 def encode_gt(_), do: {:error, "Unexpected type when encoding Pbp.gt"}
537549
550+ def decode_international_family_name(value) when is_binary(value), do: value
551+ def decode_international_family_name(_), do: {:error, "Unexpected type when decoding Pbp.international_family_name"}
552+
553+ def encode_international_family_name(value) when is_binary(value), do: value
554+ def encode_international_family_name(_), do: {:error, "Unexpected type when encoding Pbp.international_family_name"}
555+
556+ def decode_international_first_name(value) when is_binary(value), do: value
557+ def decode_international_first_name(_), do: {:error, "Unexpected type when decoding Pbp.international_first_name"}
558+
559+ def encode_international_first_name(value) when is_binary(value), do: value
560+ def encode_international_first_name(_), do: {:error, "Unexpected type when encoding Pbp.international_first_name"}
561+
538562 def decode_lead(value) when is_integer(value), do: value
539563 def decode_lead(_), do: {:error, "Unexpected type when decoding Pbp.lead"}
540564
@@ -610,14 +634,14 @@ defmodule Pbp do
610634 def from_map(m) do
611635 %Pbp{
612636 action_type: ActionType.decode(m["actionType"]),
613- family_name: m["familyName"],
637+ family_name: m["familyName"] && decode_family_name(m["familyName"]),
614638 family_name_initial: m["familyNameInitial"] && FamilyNameInitial.decode(m["familyNameInitial"]),
615- first_name: m["firstName"],
639+ first_name: m["firstName"] && decode_first_name(m["firstName"]),
616640 first_name_initial: m["firstNameInitial"] && FirstNameInitial.decode(m["firstNameInitial"]),
617641 gt: decode_gt(m["gt"]),
618- international_family_name: m["internationalFamilyName"],
642+ international_family_name: m["internationalFamilyName"] && decode_international_family_name(m["internationalFamilyName"]),
619643 international_family_name_initial: m["internationalFamilyNameInitial"] && FamilyNameInitial.decode(m["internationalFamilyNameInitial"]),
620- international_first_name: m["internationalFirstName"],
644+ international_first_name: m["internationalFirstName"] && decode_international_first_name(m["internationalFirstName"]),
621645 international_first_name_initial: m["internationalFirstNameInitial"] && FirstNameInitial.decode(m["internationalFirstNameInitial"]),
622646 lead: decode_lead(m["lead"]),
623647 period: decode_period(m["period"]),
@@ -756,6 +780,48 @@ defmodule Scorer do
756780 tot: integer() | nil
757781 }
758782
783+ def decode_family_name(value) when is_binary(value), do: value
784+ def decode_family_name(_), do: {:error, "Unexpected type when decoding Scorer.family_name"}
785+
786+ def encode_family_name(value) when is_binary(value), do: value
787+ def encode_family_name(_), do: {:error, "Unexpected type when encoding Scorer.family_name"}
788+
789+ def decode_first_name(value) when is_binary(value), do: value
790+ def decode_first_name(_), do: {:error, "Unexpected type when decoding Scorer.first_name"}
791+
792+ def encode_first_name(value) when is_binary(value), do: value
793+ def encode_first_name(_), do: {:error, "Unexpected type when encoding Scorer.first_name"}
794+
795+ def decode_gt(value) when is_binary(value), do: value
796+ def decode_gt(_), do: {:error, "Unexpected type when decoding Scorer.gt"}
797+
798+ def encode_gt(value) when is_binary(value), do: value
799+ def encode_gt(_), do: {:error, "Unexpected type when encoding Scorer.gt"}
800+
801+ def decode_international_family_name(value) when is_binary(value), do: value
802+ def decode_international_family_name(_), do: {:error, "Unexpected type when decoding Scorer.international_family_name"}
803+
804+ def encode_international_family_name(value) when is_binary(value), do: value
805+ def encode_international_family_name(_), do: {:error, "Unexpected type when encoding Scorer.international_family_name"}
806+
807+ def decode_international_first_name(value) when is_binary(value), do: value
808+ def decode_international_first_name(_), do: {:error, "Unexpected type when decoding Scorer.international_first_name"}
809+
810+ def encode_international_first_name(value) when is_binary(value), do: value
811+ def encode_international_first_name(_), do: {:error, "Unexpected type when encoding Scorer.international_first_name"}
812+
813+ def decode_name(value) when is_binary(value), do: value
814+ def decode_name(_), do: {:error, "Unexpected type when decoding Scorer.name"}
815+
816+ def encode_name(value) when is_binary(value), do: value
817+ def encode_name(_), do: {:error, "Unexpected type when encoding Scorer.name"}
818+
819+ def decode_player(value) when is_binary(value), do: value
820+ def decode_player(_), do: {:error, "Unexpected type when decoding Scorer.player"}
821+
822+ def encode_player(value) when is_binary(value), do: value
823+ def encode_player(_), do: {:error, "Unexpected type when encoding Scorer.player"}
824+
759825 def decode_pno(value) when is_integer(value), do: value
760826 def decode_pno(_), do: {:error, "Unexpected type when decoding Scorer.pno"}
761827
@@ -768,6 +834,12 @@ defmodule Scorer do
768834 def encode_shirt_number(value) when is_binary(value), do: value
769835 def encode_shirt_number(_), do: {:error, "Unexpected type when encoding Scorer.shirt_number"}
770836
837+ def decode_summary(value) when is_binary(value), do: value
838+ def decode_summary(_), do: {:error, "Unexpected type when decoding Scorer.summary"}
839+
840+ def encode_summary(value) when is_binary(value), do: value
841+ def encode_summary(_), do: {:error, "Unexpected type when encoding Scorer.summary"}
842+
771843 def decode_tno(value) when is_integer(value), do: value
772844 def decode_tno(_), do: {:error, "Unexpected type when decoding Scorer.tno"}
773845
@@ -776,23 +848,23 @@ defmodule Scorer do
776848
777849 def from_map(m) do
778850 %Scorer{
779- family_name: m["familyName"],
851+ family_name: m["familyName"] && decode_family_name(m["familyName"]),
780852 family_name_initial: m["familyNameInitial"] && FamilyNameInitial.decode(m["familyNameInitial"]),
781- first_name: m["firstName"],
853+ first_name: m["firstName"] && decode_first_name(m["firstName"]),
782854 first_name_initial: m["firstNameInitial"] && FirstNameInitial.decode(m["firstNameInitial"]),
783- gt: m["gt"],
784- international_family_name: m["internationalFamilyName"],
855+ gt: m["gt"] && decode_gt(m["gt"]),
856+ international_family_name: m["internationalFamilyName"] && decode_international_family_name(m["internationalFamilyName"]),
785857 international_family_name_initial: m["internationalFamilyNameInitial"] && FamilyNameInitial.decode(m["internationalFamilyNameInitial"]),
786- international_first_name: m["internationalFirstName"],
858+ international_first_name: m["internationalFirstName"] && decode_international_first_name(m["internationalFirstName"]),
787859 international_first_name_initial: m["internationalFirstNameInitial"] && FirstNameInitial.decode(m["internationalFirstNameInitial"]),
788- name: m["name"],
860+ name: m["name"] && decode_name(m["name"]),
789861 per: m["per"],
790862 per_type: m["perType"] && PerType.decode(m["perType"]),
791- player: m["player"],
863+ player: m["player"] && decode_player(m["player"]),
792864 pno: decode_pno(m["pno"]),
793865 scoreboard_name: m["scoreboardName"] && ScoreboardName.decode(m["scoreboardName"]),
794866 shirt_number: decode_shirt_number(m["shirtNumber"]),
795- summary: m["summary"],
867+ summary: m["summary"] && decode_summary(m["summary"]),
796868 times: m["times"] && Enum.map(m["times"], &TimeElement.from_map/1),
797869 tno: decode_tno(m["tno"]),
798870 tot: m["tot"],
Test case

test/inputs/json/samples/github-events.json

1 generated file · +63 −9
Melixirdefault / QuickType.ex+63 −9
@@ -24,6 +24,12 @@ defmodule Actor do
2424 def encode_avatar_url(value) when is_binary(value), do: value
2525 def encode_avatar_url(_), do: {:error, "Unexpected type when encoding Actor.avatar_url"}
2626
27+ def decode_display_login(value) when is_binary(value), do: value
28+ def decode_display_login(_), do: {:error, "Unexpected type when decoding Actor.display_login"}
29+
30+ def encode_display_login(value) when is_binary(value), do: value
31+ def encode_display_login(_), do: {:error, "Unexpected type when encoding Actor.display_login"}
32+
2733 def decode_gravatar_id(value) when is_binary(value), do: value
2834 def decode_gravatar_id(_), do: {:error, "Unexpected type when decoding Actor.gravatar_id"}
2935
@@ -51,7 +57,7 @@ defmodule Actor do
5157 def from_map(m) do
5258 %Actor{
5359 avatar_url: decode_avatar_url(m["avatar_url"]),
54- display_login: m["display_login"],
60+ display_login: m["display_login"] && decode_display_login(m["display_login"]),
5561 gravatar_id: decode_gravatar_id(m["gravatar_id"]),
5662 id: decode_id(m["id"]),
5763 login: decode_login(m["login"]),
@@ -2209,23 +2215,71 @@ defmodule Payload do
22092215 size: integer() | nil
22102216 }
22112217
2218+ def decode_action(value) when is_binary(value), do: value
2219+ def decode_action(_), do: {:error, "Unexpected type when decoding Payload.action"}
2220+
2221+ def encode_action(value) when is_binary(value), do: value
2222+ def encode_action(_), do: {:error, "Unexpected type when encoding Payload.action"}
2223+
2224+ def decode_before(value) when is_binary(value), do: value
2225+ def decode_before(_), do: {:error, "Unexpected type when decoding Payload.before"}
2226+
2227+ def encode_before(value) when is_binary(value), do: value
2228+ def encode_before(_), do: {:error, "Unexpected type when encoding Payload.before"}
2229+
2230+ def decode_description(value) when is_binary(value), do: value
2231+ def decode_description(_), do: {:error, "Unexpected type when decoding Payload.description"}
2232+
2233+ def encode_description(value) when is_binary(value), do: value
2234+ def encode_description(_), do: {:error, "Unexpected type when encoding Payload.description"}
2235+
2236+ def decode_head(value) when is_binary(value), do: value
2237+ def decode_head(_), do: {:error, "Unexpected type when decoding Payload.head"}
2238+
2239+ def encode_head(value) when is_binary(value), do: value
2240+ def encode_head(_), do: {:error, "Unexpected type when encoding Payload.head"}
2241+
2242+ def decode_master_branch(value) when is_binary(value), do: value
2243+ def decode_master_branch(_), do: {:error, "Unexpected type when decoding Payload.master_branch"}
2244+
2245+ def encode_master_branch(value) when is_binary(value), do: value
2246+ def encode_master_branch(_), do: {:error, "Unexpected type when encoding Payload.master_branch"}
2247+
2248+ def decode_pusher_type(value) when is_binary(value), do: value
2249+ def decode_pusher_type(_), do: {:error, "Unexpected type when decoding Payload.pusher_type"}
2250+
2251+ def encode_pusher_type(value) when is_binary(value), do: value
2252+ def encode_pusher_type(_), do: {:error, "Unexpected type when encoding Payload.pusher_type"}
2253+
2254+ def decode_ref(value) when is_binary(value), do: value
2255+ def decode_ref(_), do: {:error, "Unexpected type when decoding Payload.ref"}
2256+
2257+ def encode_ref(value) when is_binary(value), do: value
2258+ def encode_ref(_), do: {:error, "Unexpected type when encoding Payload.ref"}
2259+
2260+ def decode_ref_type(value) when is_binary(value), do: value
2261+ def decode_ref_type(_), do: {:error, "Unexpected type when decoding Payload.ref_type"}
2262+
2263+ def encode_ref_type(value) when is_binary(value), do: value
2264+ def encode_ref_type(_), do: {:error, "Unexpected type when encoding Payload.ref_type"}
2265+
22122266 def from_map(m) do
22132267 %Payload{
2214- action: m["action"],
2215- before: m["before"],
2268+ action: m["action"] && decode_action(m["action"]),
2269+ before: m["before"] && decode_before(m["before"]),
22162270 comment: m["comment"] && Comment.from_map(m["comment"]),
22172271 commits: m["commits"] && Enum.map(m["commits"], &Commit.from_map/1),
2218- description: m["description"],
2272+ description: m["description"] && decode_description(m["description"]),
22192273 distinct_size: m["distinct_size"],
2220- head: m["head"],
2274+ head: m["head"] && decode_head(m["head"]),
22212275 issue: m["issue"] && Issue.from_map(m["issue"]),
2222- master_branch: m["master_branch"],
2276+ master_branch: m["master_branch"] && decode_master_branch(m["master_branch"]),
22232277 number: m["number"],
22242278 pull_request: m["pull_request"] && PayloadPullRequest.from_map(m["pull_request"]),
22252279 push_id: m["push_id"],
2226- pusher_type: m["pusher_type"],
2227- ref: m["ref"],
2228- ref_type: m["ref_type"],
2280+ pusher_type: m["pusher_type"] && decode_pusher_type(m["pusher_type"]),
2281+ ref: m["ref"] && decode_ref(m["ref"]),
2282+ ref_type: m["ref_type"] && decode_ref_type(m["ref_type"]),
22292283 size: m["size"],
22302284 }
22312285 end
Test case

test/inputs/json/samples/null-safe.json

1 generated file · +7 −1
Melixirdefault / QuickType.ex+7 −1
@@ -73,6 +73,12 @@ defmodule Item do
7373 sex: integer() | nil
7474 }
7575
76+ def decode_created_at(value) when is_binary(value), do: value
77+ def decode_created_at(_), do: {:error, "Unexpected type when decoding Item.created_at"}
78+
79+ def encode_created_at(value) when is_binary(value), do: value
80+ def encode_created_at(_), do: {:error, "Unexpected type when encoding Item.created_at"}
81+
7682 def decode_name(value) when is_binary(value), do: value
7783 def decode_name(_), do: {:error, "Unexpected type when decoding Item.name"}
7884
@@ -82,7 +88,7 @@ defmodule Item do
8288 def from_map(m) do
8389 %Item{
8490 address: m["address"] && Address.from_map(m["address"]),
85- created_at: m["created_at"],
91+ created_at: m["created_at"] && decode_created_at(m["created_at"]),
8692 name: decode_name(m["name"]),
8793 sex: Map.fetch!(m, "sex"),
8894 }
Test case

test/inputs/json/samples/us-senators.json

1 generated file · +14 −2
Melixirdefault / QuickType.ex+14 −2
@@ -133,19 +133,31 @@ defmodule Extra do
133133 def encode_contact_form(value) when is_binary(value), do: value
134134 def encode_contact_form(_), do: {:error, "Unexpected type when encoding Extra.contact_form"}
135135
136+ def decode_fax(value) when is_binary(value), do: value
137+ def decode_fax(_), do: {:error, "Unexpected type when decoding Extra.fax"}
138+
139+ def encode_fax(value) when is_binary(value), do: value
140+ def encode_fax(_), do: {:error, "Unexpected type when encoding Extra.fax"}
141+
136142 def decode_office(value) when is_binary(value), do: value
137143 def decode_office(_), do: {:error, "Unexpected type when decoding Extra.office"}
138144
139145 def encode_office(value) when is_binary(value), do: value
140146 def encode_office(_), do: {:error, "Unexpected type when encoding Extra.office"}
141147
148+ def decode_rss_url(value) when is_binary(value), do: value
149+ def decode_rss_url(_), do: {:error, "Unexpected type when decoding Extra.rss_url"}
150+
151+ def encode_rss_url(value) when is_binary(value), do: value
152+ def encode_rss_url(_), do: {:error, "Unexpected type when encoding Extra.rss_url"}
153+
142154 def from_map(m) do
143155 %Extra{
144156 address: decode_address(m["address"]),
145157 contact_form: decode_contact_form(m["contact_form"]),
146- fax: m["fax"],
158+ fax: m["fax"] && decode_fax(m["fax"]),
147159 office: decode_office(m["office"]),
148- rss_url: m["rss_url"],
160+ rss_url: m["rss_url"] && decode_rss_url(m["rss_url"]),
149161 }
150162 end
Test case

test/inputs/schema/all-of-additional-properties-false.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -117,11 +117,17 @@ defmodule TopLevel do
117117 def encode_amount(value) when is_integer(value), do: value
118118 def encode_amount(_), do: {:error, "Unexpected type when encoding TopLevel.amount"}
119119
120+ def decode_description(value) when is_binary(value), do: value
121+ def decode_description(_), do: {:error, "Unexpected type when decoding TopLevel.description"}
122+
123+ def encode_description(value) when is_binary(value), do: value
124+ def encode_description(_), do: {:error, "Unexpected type when encoding TopLevel.description"}
125+
120126 def from_map(m) do
121127 %TopLevel{
122128 amount: decode_amount(m["amount"]),
123129 frequency: Frequency.decode(m["frequency"]),
124- description: m["description"],
130+ description: m["description"] && decode_description(m["description"]),
125131 type: Type.decode(m["type"]),
126132 }
127133 end
Test case

test/inputs/schema/bool-string.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -33,13 +33,19 @@ defmodule TopLevel do
3333 def encode_one(value) when is_binary(value), do: value
3434 def encode_one(_), do: {:error, "Unexpected type when encoding TopLevel.one"}
3535
36+ def decode_optional(value) when is_binary(value), do: value
37+ def decode_optional(_), do: {:error, "Unexpected type when decoding TopLevel.optional"}
38+
39+ def encode_optional(value) when is_binary(value), do: value
40+ def encode_optional(_), do: {:error, "Unexpected type when encoding TopLevel.optional"}
41+
3642 def from_map(m) do
3743 %TopLevel{
3844 arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
3945 arr_one: m["arrOne"],
4046 nullable: Map.fetch!(m, "nullable"),
4147 one: decode_one(m["one"]),
42- optional: m["optional"],
48+ optional: m["optional"] && decode_optional(m["optional"]),
4349 union_with_bool: Map.fetch!(m, "unionWithBool"),
4450 union_with_bool_and_enum: Map.fetch!(m, "unionWithBoolAndEnum"),
4551 }
Test case

test/inputs/schema/camelCase.schema

1 generated file · +14 −2
Mschema-elixirdefault / QuickType.ex+14 −2
@@ -13,10 +13,22 @@ defmodule TopLevel do
1313 second_property: String.t() | nil
1414 }
1515
16+ def decode_my_property(value) when is_binary(value), do: value
17+ def decode_my_property(_), do: {:error, "Unexpected type when decoding TopLevel.my_property"}
18+
19+ def encode_my_property(value) when is_binary(value), do: value
20+ def encode_my_property(_), do: {:error, "Unexpected type when encoding TopLevel.my_property"}
21+
22+ def decode_second_property(value) when is_binary(value), do: value
23+ def decode_second_property(_), do: {:error, "Unexpected type when decoding TopLevel.second_property"}
24+
25+ def encode_second_property(value) when is_binary(value), do: value
26+ def encode_second_property(_), do: {:error, "Unexpected type when encoding TopLevel.second_property"}
27+
1628 def from_map(m) do
1729 %TopLevel{
18- my_property: m["myProperty"],
19- second_property: m["secondProperty"],
30+ my_property: m["myProperty"] && decode_my_property(m["myProperty"]),
31+ second_property: m["secondProperty"] && decode_second_property(m["secondProperty"]),
2032 }
2133 end
Test case

test/inputs/schema/comment-injection.schema

1 generated file · +21 −3
Mschema-elixirdefault / QuickType.ex+21 −3
@@ -35,6 +35,24 @@ defmodule TopLevel do
3535 value: String.t()
3636 }
3737
38+ def decode_trailing_backslash(value) when is_binary(value), do: value
39+ def decode_trailing_backslash(_), do: {:error, "Unexpected type when decoding TopLevel.trailing_backslash"}
40+
41+ def encode_trailing_backslash(value) when is_binary(value), do: value
42+ def encode_trailing_backslash(_), do: {:error, "Unexpected type when encoding TopLevel.trailing_backslash"}
43+
44+ def decode_trailing_quote(value) when is_binary(value), do: value
45+ def decode_trailing_quote(_), do: {:error, "Unexpected type when decoding TopLevel.trailing_quote"}
46+
47+ def encode_trailing_quote(value) when is_binary(value), do: value
48+ def encode_trailing_quote(_), do: {:error, "Unexpected type when encoding TopLevel.trailing_quote"}
49+
50+ def decode_trailing_triple_quote(value) when is_binary(value), do: value
51+ def decode_trailing_triple_quote(_), do: {:error, "Unexpected type when decoding TopLevel.trailing_triple_quote"}
52+
53+ def encode_trailing_triple_quote(value) when is_binary(value), do: value
54+ def encode_trailing_triple_quote(_), do: {:error, "Unexpected type when encoding TopLevel.trailing_triple_quote"}
55+
3856 def decode_value(value) when is_binary(value), do: value
3957 def decode_value(_), do: {:error, "Unexpected type when decoding TopLevel.value"}
4058
@@ -43,9 +61,9 @@ defmodule TopLevel do
4361
4462 def from_map(m) do
4563 %TopLevel{
46- trailing_backslash: m["trailingBackslash"],
47- trailing_quote: m["trailingQuote"],
48- trailing_triple_quote: m["trailingTripleQuote"],
64+ trailing_backslash: m["trailingBackslash"] && decode_trailing_backslash(m["trailingBackslash"]),
65+ trailing_quote: m["trailingQuote"] && decode_trailing_quote(m["trailingQuote"]),
66+ trailing_triple_quote: m["trailingTripleQuote"] && decode_trailing_triple_quote(m["trailingTripleQuote"]),
4967 value: decode_value(m["value"]),
5068 }
5169 end
Test case

test/inputs/schema/enum.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -166,10 +166,16 @@ defmodule TopLevel do
166166 def encode_arr_element(value) when is_integer(value), do: value
167167 def encode_arr_element(_), do: {:error, "Unexpected type when encoding TopLevel.arr"}
168168
169+ def decode_for(value) when is_binary(value), do: value
170+ def decode_for(_), do: {:error, "Unexpected type when decoding TopLevel.for"}
171+
172+ def encode_for(value) when is_binary(value), do: value
173+ def encode_for(_), do: {:error, "Unexpected type when encoding TopLevel.for"}
174+
169175 def from_map(m) do
170176 %TopLevel{
171177 arr: m["arr"] && Enum.map(m["arr"], &decode_arr_element/1),
172- for: m["for"],
178+ for: m["for"] && decode_for(m["for"]),
173179 gve: Gve.decode(m["gve"]),
174180 lvc: m["lvc"] && Lvc.decode(m["lvc"]),
175181 other_arr: m["otherArr"] && Enum.map(m["otherArr"], &OtherArr.decode/1),
Test case

test/inputs/schema/implicit-one-of.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -21,11 +21,17 @@ defmodule TopLevel do
2121 def encode_foo(value) when is_integer(value), do: value
2222 def encode_foo(_), do: {:error, "Unexpected type when encoding TopLevel.foo"}
2323
24+ def decode_quux(value) when is_binary(value), do: value
25+ def decode_quux(_), do: {:error, "Unexpected type when decoding TopLevel.quux"}
26+
27+ def encode_quux(value) when is_binary(value), do: value
28+ def encode_quux(_), do: {:error, "Unexpected type when encoding TopLevel.quux"}
29+
2430 def from_map(m) do
2531 %TopLevel{
2632 foo: decode_foo(m["foo"]),
2733 bar: m["bar"],
28- quux: m["quux"],
34+ quux: m["quux"] && decode_quux(m["quux"]),
2935 }
3036 end
Test case

test/inputs/schema/integer-string.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -33,13 +33,19 @@ defmodule TopLevel do
3333 def encode_one(value) when is_binary(value), do: value
3434 def encode_one(_), do: {:error, "Unexpected type when encoding TopLevel.one"}
3535
36+ def decode_optional(value) when is_binary(value), do: value
37+ def decode_optional(_), do: {:error, "Unexpected type when decoding TopLevel.optional"}
38+
39+ def encode_optional(value) when is_binary(value), do: value
40+ def encode_optional(_), do: {:error, "Unexpected type when encoding TopLevel.optional"}
41+
3642 def from_map(m) do
3743 %TopLevel{
3844 arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
3945 arr_one: m["arrOne"],
4046 nullable: Map.fetch!(m, "nullable"),
4147 one: decode_one(m["one"]),
42- optional: m["optional"],
48+ optional: m["optional"] && decode_optional(m["optional"]),
4349 union_with_int: Map.fetch!(m, "unionWithInt"),
4450 union_with_int_and_enum: Map.fetch!(m, "unionWithIntAndEnum"),
4551 }
Test case

test/inputs/schema/intersection.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -22,10 +22,16 @@ defmodule Intersection do
2222 def encode_foo(value) when is_integer(value), do: value
2323 def encode_foo(_), do: {:error, "Unexpected type when encoding Intersection.foo"}
2424
25+ def decode_bar(value) when is_binary(value), do: value
26+ def decode_bar(_), do: {:error, "Unexpected type when decoding Intersection.bar"}
27+
28+ def encode_bar(value) when is_binary(value), do: value
29+ def encode_bar(_), do: {:error, "Unexpected type when encoding Intersection.bar"}
30+
2531 def from_map(m) do
2632 %Intersection{
2733 foo: decode_foo(m["foo"]),
28- bar: m["bar"],
34+ bar: m["bar"] && decode_bar(m["bar"]),
2935 }
3036 end
Test case

test/inputs/schema/minmaxlength.schema

1 generated file · +18 −6
Mschema-elixirdefault / QuickType.ex+18 −6
@@ -20,31 +20,41 @@ defmodule TopLevel do
2020 union: String.t()
2121 }
2222
23- def decode_intersection(value) when is_binary(value), do: value
23+ def decode_intersection(value) when is_binary(value) do
24+ if String.length(value) >= 4 and String.length(value) <= 5, do: value, else: raise(ArgumentError)
25+ end
2426 def decode_intersection(_), do: {:error, "Unexpected type when decoding TopLevel.intersection"}
2527
2628 def encode_intersection(value) when is_binary(value), do: value
2729 def encode_intersection(_), do: {:error, "Unexpected type when encoding TopLevel.intersection"}
2830
29- def decode_maxlength(value) when is_binary(value), do: value
31+ def decode_maxlength(value) when is_binary(value) do
32+ if String.length(value) <= 5, do: value, else: raise(ArgumentError)
33+ end
3034 def decode_maxlength(_), do: {:error, "Unexpected type when decoding TopLevel.maxlength"}
3135
3236 def encode_maxlength(value) when is_binary(value), do: value
3337 def encode_maxlength(_), do: {:error, "Unexpected type when encoding TopLevel.maxlength"}
3438
35- def decode_minlength(value) when is_binary(value), do: value
39+ def decode_minlength(value) when is_binary(value) do
40+ if String.length(value) >= 3, do: value, else: raise(ArgumentError)
41+ end
3642 def decode_minlength(_), do: {:error, "Unexpected type when decoding TopLevel.minlength"}
3743
3844 def encode_minlength(value) when is_binary(value), do: value
3945 def encode_minlength(_), do: {:error, "Unexpected type when encoding TopLevel.minlength"}
4046
41- def decode_min_max_intersection(value) when is_binary(value), do: value
47+ def decode_min_max_intersection(value) when is_binary(value) do
48+ if String.length(value) >= 3 and String.length(value) <= 5, do: value, else: raise(ArgumentError)
49+ end
4250 def decode_min_max_intersection(_), do: {:error, "Unexpected type when decoding TopLevel.min_max_intersection"}
4351
4452 def encode_min_max_intersection(value) when is_binary(value), do: value
4553 def encode_min_max_intersection(_), do: {:error, "Unexpected type when encoding TopLevel.min_max_intersection"}
4654
47- def decode_minmaxlength(value) when is_binary(value), do: value
55+ def decode_minmaxlength(value) when is_binary(value) do
56+ if String.length(value) >= 3 and String.length(value) <= 5, do: value, else: raise(ArgumentError)
57+ end
4858 def decode_minmaxlength(_), do: {:error, "Unexpected type when decoding TopLevel.minmaxlength"}
4959
5060 def encode_minmaxlength(value) when is_binary(value), do: value
@@ -56,7 +66,9 @@ defmodule TopLevel do
5666 def encode_min_max_union(value) when is_binary(value), do: value
5767 def encode_min_max_union(_), do: {:error, "Unexpected type when encoding TopLevel.min_max_union"}
5868
59- def decode_union(value) when is_binary(value), do: value
69+ def decode_union(value) when is_binary(value) do
70+ if String.length(value) >= 3 and String.length(value) <= 6, do: value, else: raise(ArgumentError)
71+ end
6072 def decode_union(_), do: {:error, "Unexpected type when decoding TopLevel.union"}
6173
6274 def encode_union(value) when is_binary(value), do: value
Test case

test/inputs/schema/nested-intersection-union.schema

1 generated file · +28 −4
Mschema-elixirdefault / QuickType.ex+28 −4
@@ -15,12 +15,36 @@ defmodule Item do
1515 summary: String.t() | nil
1616 }
1717
18+ def decode_content(value) when is_binary(value), do: value
19+ def decode_content(_), do: {:error, "Unexpected type when decoding Item.content"}
20+
21+ def encode_content(value) when is_binary(value), do: value
22+ def encode_content(_), do: {:error, "Unexpected type when encoding Item.content"}
23+
24+ def decode_id(value) when is_binary(value), do: value
25+ def decode_id(_), do: {:error, "Unexpected type when decoding Item.id"}
26+
27+ def encode_id(value) when is_binary(value), do: value
28+ def encode_id(_), do: {:error, "Unexpected type when encoding Item.id"}
29+
30+ def decode_output(value) when is_binary(value), do: value
31+ def decode_output(_), do: {:error, "Unexpected type when decoding Item.output"}
32+
33+ def encode_output(value) when is_binary(value), do: value
34+ def encode_output(_), do: {:error, "Unexpected type when encoding Item.output"}
35+
36+ def decode_summary(value) when is_binary(value), do: value
37+ def decode_summary(_), do: {:error, "Unexpected type when decoding Item.summary"}
38+
39+ def encode_summary(value) when is_binary(value), do: value
40+ def encode_summary(_), do: {:error, "Unexpected type when encoding Item.summary"}
41+
1842 def from_map(m) do
1943 %Item{
20- content: m["content"],
21- id: m["id"],
22- output: m["output"],
23- summary: m["summary"],
44+ content: m["content"] && decode_content(m["content"]),
45+ id: m["id"] && decode_id(m["id"]),
46+ output: m["output"] && decode_output(m["output"]),
47+ summary: m["summary"] && decode_summary(m["summary"]),
2448 }
2549 end
Test case

test/inputs/schema/object-type-required.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -20,10 +20,16 @@ defmodule TopLevel do
2020 def encode_foo(value) when is_binary(value), do: value
2121 def encode_foo(_), do: {:error, "Unexpected type when encoding TopLevel.foo"}
2222
23+ def decode_bar(value) when is_binary(value), do: value
24+ def decode_bar(_), do: {:error, "Unexpected type when decoding TopLevel.bar"}
25+
26+ def encode_bar(value) when is_binary(value), do: value
27+ def encode_bar(_), do: {:error, "Unexpected type when encoding TopLevel.bar"}
28+
2329 def from_map(m) do
2430 %TopLevel{
2531 foo: decode_foo(m["foo"]),
26- bar: m["bar"],
32+ bar: m["bar"] && decode_bar(m["bar"]),
2733 }
2834 end
Test case

test/inputs/schema/optional-const-ref.schema

1 generated file · +12 −2
Mschema-elixirdefault / QuickType.ex+12 −2
@@ -71,6 +71,14 @@ defmodule TopLevel do
7171 weight: float() | nil
7272 }
7373
74+ def decode_label(value) when is_binary(value) do
75+ if String.length(value) >= 2 and String.length(value) <= 16, do: value, else: raise(ArgumentError)
76+ end
77+ def decode_label(_), do: {:error, "Unexpected type when decoding TopLevel.label"}
78+
79+ def encode_label(value) when is_binary(value), do: value
80+ def encode_label(_), do: {:error, "Unexpected type when encoding TopLevel.label"}
81+
7482 def decode_required_coordinates(value) when is_list(value), do: value
7583 def decode_required_coordinates(_), do: {:error, "Unexpected type when decoding TopLevel.required_coordinates"}
7684
@@ -83,7 +91,9 @@ defmodule TopLevel do
8391 def encode_required_count(value) when is_integer(value), do: value
8492 def encode_required_count(_), do: {:error, "Unexpected type when encoding TopLevel.required_count"}
8593
86- def decode_required_label(value) when is_binary(value), do: value
94+ def decode_required_label(value) when is_binary(value) do
95+ if String.length(value) >= 2 and String.length(value) <= 16, do: value, else: raise(ArgumentError)
96+ end
8797 def decode_required_label(_), do: {:error, "Unexpected type when decoding TopLevel.required_label"}
8898
8999 def encode_required_label(value) when is_binary(value), do: value
@@ -93,7 +103,7 @@ defmodule TopLevel do
93103 %TopLevel{
94104 coordinates: m["coordinates"] && Enum.map(m["coordinates"], &Coordinate.from_map/1),
95105 count: m["count"],
96- label: m["label"],
106+ label: m["label"] && decode_label(m["label"]),
97107 required_coordinates: Enum.map(m["requiredCoordinates"], &Coordinate.from_map/1),
98108 required_count: decode_required_count(m["requiredCount"]),
99109 required_label: decode_required_label(m["requiredLabel"]),
Test case

test/inputs/schema/optional-constraints.schema

1 generated file · +16 −2
Mschema-elixirdefault / QuickType.ex+16 −2
@@ -17,6 +17,20 @@ defmodule TopLevel do
1717 req_zero_min: integer()
1818 }
1919
20+ def decode_opt_pattern(value) when is_binary(value), do: value
21+ def decode_opt_pattern(_), do: {:error, "Unexpected type when decoding TopLevel.opt_pattern"}
22+
23+ def encode_opt_pattern(value) when is_binary(value), do: value
24+ def encode_opt_pattern(_), do: {:error, "Unexpected type when encoding TopLevel.opt_pattern"}
25+
26+ def decode_opt_string(value) when is_binary(value) do
27+ if String.length(value) >= 3 and String.length(value) <= 10, do: value, else: raise(ArgumentError)
28+ end
29+ def decode_opt_string(_), do: {:error, "Unexpected type when decoding TopLevel.opt_string"}
30+
31+ def encode_opt_string(value) when is_binary(value), do: value
32+ def encode_opt_string(_), do: {:error, "Unexpected type when encoding TopLevel.opt_string"}
33+
2034 def decode_req_zero_min(value) when is_integer(value), do: value
2135 def decode_req_zero_min(_), do: {:error, "Unexpected type when decoding TopLevel.req_zero_min"}
2236
@@ -27,8 +41,8 @@ defmodule TopLevel do
2741 %TopLevel{
2842 opt_double: m["optDouble"],
2943 opt_int: m["optInt"],
30- opt_pattern: m["optPattern"],
31- opt_string: m["optString"],
44+ opt_pattern: m["optPattern"] && decode_opt_pattern(m["optPattern"]),
45+ opt_string: m["optString"] && decode_opt_string(m["optString"]),
3246 req_zero_min: decode_req_zero_min(m["reqZeroMin"]),
3347 }
3448 end
Test case

test/inputs/schema/optional-date-time.schema

1 generated file · +21 −3
Mschema-elixirdefault / QuickType.ex+21 −3
@@ -18,6 +18,24 @@ defmodule TopLevel do
1818 required_time: String.t()
1919 }
2020
21+ def decode_optional_date(value) when is_binary(value), do: value
22+ def decode_optional_date(_), do: {:error, "Unexpected type when decoding TopLevel.optional_date"}
23+
24+ def encode_optional_date(value) when is_binary(value), do: value
25+ def encode_optional_date(_), do: {:error, "Unexpected type when encoding TopLevel.optional_date"}
26+
27+ def decode_optional_date_time(value) when is_binary(value), do: value
28+ def decode_optional_date_time(_), do: {:error, "Unexpected type when decoding TopLevel.optional_date_time"}
29+
30+ def encode_optional_date_time(value) when is_binary(value), do: value
31+ def encode_optional_date_time(_), do: {:error, "Unexpected type when encoding TopLevel.optional_date_time"}
32+
33+ def decode_optional_time(value) when is_binary(value), do: value
34+ def decode_optional_time(_), do: {:error, "Unexpected type when decoding TopLevel.optional_time"}
35+
36+ def encode_optional_time(value) when is_binary(value), do: value
37+ def encode_optional_time(_), do: {:error, "Unexpected type when encoding TopLevel.optional_time"}
38+
2139 def decode_required_date(value) when is_binary(value), do: value
2240 def decode_required_date(_), do: {:error, "Unexpected type when decoding TopLevel.required_date"}
2341
@@ -38,9 +56,9 @@ defmodule TopLevel do
3856
3957 def from_map(m) do
4058 %TopLevel{
41- optional_date: m["optional-date"],
42- optional_date_time: m["optional-date-time"],
43- optional_time: m["optional-time"],
59+ optional_date: m["optional-date"] && decode_optional_date(m["optional-date"]),
60+ optional_date_time: m["optional-date-time"] && decode_optional_date_time(m["optional-date-time"]),
61+ optional_time: m["optional-time"] && decode_optional_time(m["optional-time"]),
4462 required_date: decode_required_date(m["required-date"]),
4563 required_date_time: decode_required_date_time(m["required-date-time"]),
4664 required_time: decode_required_time(m["required-time"]),
Test case

test/inputs/schema/postman-collection.schema

1 generated file · +14 −2
Mschema-elixirdefault / QuickType.ex+14 −2
@@ -12,9 +12,15 @@ defmodule Response do
1212 body: String.t() | nil
1313 }
1414
15+ def decode_body(value) when is_binary(value), do: value
16+ def decode_body(_), do: {:error, "Unexpected type when decoding Response.body"}
17+
18+ def encode_body(value) when is_binary(value), do: value
19+ def encode_body(_), do: {:error, "Unexpected type when encoding Response.body"}
20+
1521 def from_map(m) do
1622 %Response{
17- body: m["body"],
23+ body: m["body"] && decode_body(m["body"]),
1824 }
1925 end
2026
@@ -50,10 +56,16 @@ defmodule TopLevel do
5056 response: [Response.t()] | nil
5157 }
5258
59+ def decode_name(value) when is_binary(value), do: value
60+ def decode_name(_), do: {:error, "Unexpected type when decoding TopLevel.name"}
61+
62+ def encode_name(value) when is_binary(value), do: value
63+ def encode_name(_), do: {:error, "Unexpected type when encoding TopLevel.name"}
64+
5365 def from_map(m) do
5466 %TopLevel{
5567 item: m["item"] && Enum.map(m["item"], &TopLevel.from_map/1),
56- name: m["name"],
68+ name: m["name"] && decode_name(m["name"]),
5769 response: m["response"] && Enum.map(m["response"], &Response.from_map/1),
5870 }
5971 end
Test case

test/inputs/schema/renaming-bug.schema

1 generated file · +74 −10
Mschema-elixirdefault / QuickType.ex+74 −10
@@ -44,9 +44,15 @@ defmodule CircularShape do
4444 shape_name: String.t() | nil
4545 }
4646
47+ def decode_shape_name(value) when is_binary(value), do: value
48+ def decode_shape_name(_), do: {:error, "Unexpected type when decoding CircularShape.shape_name"}
49+
50+ def encode_shape_name(value) when is_binary(value), do: value
51+ def encode_shape_name(_), do: {:error, "Unexpected type when encoding CircularShape.shape_name"}
52+
4753 def from_map(m) do
4854 %CircularShape{
49- shape_name: m["shapeName"],
55+ shape_name: m["shapeName"] && decode_shape_name(m["shapeName"]),
5056 }
5157 end
5258
@@ -78,11 +84,29 @@ defmodule Part do
7884 width: String.t() | nil
7985 }
8086
87+ def decode_depth(value) when is_binary(value), do: value
88+ def decode_depth(_), do: {:error, "Unexpected type when decoding Part.depth"}
89+
90+ def encode_depth(value) when is_binary(value), do: value
91+ def encode_depth(_), do: {:error, "Unexpected type when encoding Part.depth"}
92+
93+ def decode_length(value) when is_binary(value), do: value
94+ def decode_length(_), do: {:error, "Unexpected type when decoding Part.length"}
95+
96+ def encode_length(value) when is_binary(value), do: value
97+ def encode_length(_), do: {:error, "Unexpected type when encoding Part.length"}
98+
99+ def decode_width(value) when is_binary(value), do: value
100+ def decode_width(_), do: {:error, "Unexpected type when decoding Part.width"}
101+
102+ def encode_width(value) when is_binary(value), do: value
103+ def encode_width(_), do: {:error, "Unexpected type when encoding Part.width"}
104+
81105 def from_map(m) do
82106 %Part{
83- depth: m["depth"],
84- length: m["length"],
85- width: m["width"],
107+ depth: m["depth"] && decode_depth(m["depth"]),
108+ length: m["length"] && decode_length(m["length"]),
109+ width: m["width"] && decode_width(m["width"]),
86110 }
87111 end
88112
@@ -181,9 +205,15 @@ defmodule History do
181205 class: String.t() | nil
182206 }
183207
208+ def decode_class(value) when is_binary(value), do: value
209+ def decode_class(_), do: {:error, "Unexpected type when decoding History.class"}
210+
211+ def encode_class(value) when is_binary(value), do: value
212+ def encode_class(_), do: {:error, "Unexpected type when encoding History.class"}
213+
184214 def from_map(m) do
185215 %History{
186- class: m["class"],
216+ class: m["class"] && decode_class(m["class"]),
187217 }
188218 end
189219
@@ -250,10 +280,18 @@ defmodule Berry do
250280 shapes: [Shape.t()] | nil
251281 }
252282
283+ def decode_name(value) when is_binary(value) do
284+ if String.length(value) >= 1, do: value, else: raise(ArgumentError)
285+ end
286+ def decode_name(_), do: {:error, "Unexpected type when decoding Berry.name"}
287+
288+ def encode_name(value) when is_binary(value), do: value
289+ def encode_name(_), do: {:error, "Unexpected type when encoding Berry.name"}
290+
253291 def from_map(m) do
254292 %Berry{
255293 color: m["color"] && Color.from_map(m["color"]),
256- name: m["name"],
294+ name: m["name"] && decode_name(m["name"]),
257295 shapes: m["shapes"] && Enum.map(m["shapes"], &Shape.from_map/1),
258296 }
259297 end
@@ -537,14 +575,34 @@ defmodule Vehicle do
537575 year: String.t() | nil
538576 }
539577
578+ def decode_brand(value) when is_binary(value), do: value
579+ def decode_brand(_), do: {:error, "Unexpected type when decoding Vehicle.brand"}
580+
581+ def encode_brand(value) when is_binary(value), do: value
582+ def encode_brand(_), do: {:error, "Unexpected type when encoding Vehicle.brand"}
583+
584+ def decode_id(value) when is_binary(value) do
585+ if String.length(value) >= 1, do: value, else: raise(ArgumentError)
586+ end
587+ def decode_id(_), do: {:error, "Unexpected type when decoding Vehicle.id"}
588+
589+ def encode_id(value) when is_binary(value), do: value
590+ def encode_id(_), do: {:error, "Unexpected type when encoding Vehicle.id"}
591+
592+ def decode_year(value) when is_binary(value), do: value
593+ def decode_year(_), do: {:error, "Unexpected type when decoding Vehicle.year"}
594+
595+ def encode_year(value) when is_binary(value), do: value
596+ def encode_year(_), do: {:error, "Unexpected type when encoding Vehicle.year"}
597+
540598 def from_map(m) do
541599 %Vehicle{
542- brand: m["brand"],
543- id: m["id"],
600+ brand: m["brand"] && decode_brand(m["brand"]),
601+ id: m["id"] && decode_id(m["id"]),
544602 speed: m["speed"] && Speed.from_map(m["speed"]),
545603 sub_module: m["subModule"],
546604 type: m["type"] && VehicleType.from_map(m["type"]),
547- year: m["year"],
605+ year: m["year"] && decode_year(m["year"]),
548606 }
549607 end
550608
@@ -581,9 +639,15 @@ defmodule TopLevel do
581639 vehicles: [Vehicle.t()] | nil
582640 }
583641
642+ def decode_version(value) when is_binary(value), do: value
643+ def decode_version(_), do: {:error, "Unexpected type when decoding TopLevel.version"}
644+
645+ def encode_version(value) when is_binary(value), do: value
646+ def encode_version(_), do: {:error, "Unexpected type when encoding TopLevel.version"}
647+
584648 def from_map(m) do
585649 %TopLevel{
586- version: m["version"],
650+ version: m["version"] && decode_version(m["version"]),
587651 fruits: m["fruits"] && Enum.map(m["fruits"], &Fruit.from_map/1),
588652 vehicles: m["vehicles"] && Enum.map(m["vehicles"], &Vehicle.from_map/1),
589653 }
Test case

test/inputs/schema/schema-constraints.schema

1 generated file · +3 −1
Mschema-elixirdefault / QuickType.ex+3 −1
@@ -14,7 +14,9 @@ defmodule TopLevel do
1414 percent: float()
1515 }
1616
17- def decode_min_max_length(value) when is_binary(value), do: value
17+ def decode_min_max_length(value) when is_binary(value) do
18+ if String.length(value) >= 5 and String.length(value) <= 5, do: value, else: raise(ArgumentError)
19+ end
1820 def decode_min_max_length(_), do: {:error, "Unexpected type when decoding TopLevel.min_max_length"}
1921
2022 def encode_min_max_length(value) when is_binary(value), do: value
Test case

test/inputs/schema/unevaluated-properties.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -109,10 +109,16 @@ defmodule ConfigClass do
109109 def encode_closed(value) when is_list(value), do: value
110110 def encode_closed(_), do: {:error, "Unexpected type when encoding ConfigClass.closed"}
111111
112+ def decode_name(value) when is_binary(value), do: value
113+ def decode_name(_), do: {:error, "Unexpected type when decoding ConfigClass.name"}
114+
115+ def encode_name(value) when is_binary(value), do: value
116+ def encode_name(_), do: {:error, "Unexpected type when encoding ConfigClass.name"}
117+
112118 def from_map(m) do
113119 %ConfigClass{
114120 closed: decode_closed(m["closed"]),
115- name: m["name"],
121+ name: m["name"] && decode_name(m["name"]),
116122 settings: m["settings"]
117123 |> Map.new(fn {key, value} -> {key, (fn value -> Enum.map(value, &Item.from_map/1) end).(value)} end),
118124 }
Test case

test/inputs/schema/uuid.schema

1 generated file · +7 −1
Mschema-elixirdefault / QuickType.ex+7 −1
@@ -32,6 +32,12 @@ defmodule TopLevel do
3232 def encode_one(value) when is_binary(value), do: value
3333 def encode_one(_), do: {:error, "Unexpected type when encoding TopLevel.one"}
3434
35+ def decode_optional(value) when is_binary(value), do: value
36+ def decode_optional(_), do: {:error, "Unexpected type when decoding TopLevel.optional"}
37+
38+ def encode_optional(value) when is_binary(value), do: value
39+ def encode_optional(_), do: {:error, "Unexpected type when encoding TopLevel.optional"}
40+
3541 def decode_union_with_enum(value) when is_binary(value), do: value
3642 def decode_union_with_enum(_), do: {:error, "Unexpected type when decoding TopLevel.union_with_enum"}
3743
@@ -44,7 +50,7 @@ defmodule TopLevel do
4450 arr_one: m["arrOne"],
4551 nullable: Map.fetch!(m, "nullable"),
4652 one: decode_one(m["one"]),
47- optional: m["optional"],
53+ optional: m["optional"] && decode_optional(m["optional"]),
4854 union_with_enum: decode_union_with_enum(m["unionWithEnum"]),
4955 }
5056 end
Test case

test/inputs/schema/vega-lite.schema

1 generated file · +770 −110
Mschema-elixirdefault / QuickType.ex+770 −110
@@ -661,6 +661,24 @@ defmodule MarkConfig do
661661 theta: float() | nil
662662 }
663663
664+ def decode_color(value) when is_binary(value), do: value
665+ def decode_color(_), do: {:error, "Unexpected type when decoding MarkConfig.color"}
666+
667+ def encode_color(value) when is_binary(value), do: value
668+ def encode_color(_), do: {:error, "Unexpected type when encoding MarkConfig.color"}
669+
670+ def decode_fill(value) when is_binary(value), do: value
671+ def decode_fill(_), do: {:error, "Unexpected type when decoding MarkConfig.fill"}
672+
673+ def encode_fill(value) when is_binary(value), do: value
674+ def encode_fill(_), do: {:error, "Unexpected type when encoding MarkConfig.fill"}
675+
676+ def decode_font(value) when is_binary(value), do: value
677+ def decode_font(_), do: {:error, "Unexpected type when decoding MarkConfig.font"}
678+
679+ def encode_font(value) when is_binary(value), do: value
680+ def encode_font(_), do: {:error, "Unexpected type when encoding MarkConfig.font"}
681+
664682 def decode_font_weight(value) when is_binary(value), do: FontWeight.decode(value)
665683 def decode_font_weight(value) when is_float(value), do: value
666684 def decode_font_weight(value) when is_integer(value), do: value
@@ -673,37 +691,61 @@ defmodule MarkConfig do
673691 def encode_font_weight(value) when is_nil(value), do: value
674692 def encode_font_weight(_), do: {:error, "Unexpected type when encoding MarkConfig.font_weight"}
675693
694+ def decode_href(value) when is_binary(value), do: value
695+ def decode_href(_), do: {:error, "Unexpected type when decoding MarkConfig.href"}
696+
697+ def encode_href(value) when is_binary(value), do: value
698+ def encode_href(_), do: {:error, "Unexpected type when encoding MarkConfig.href"}
699+
700+ def decode_shape(value) when is_binary(value), do: value
701+ def decode_shape(_), do: {:error, "Unexpected type when decoding MarkConfig.shape"}
702+
703+ def encode_shape(value) when is_binary(value), do: value
704+ def encode_shape(_), do: {:error, "Unexpected type when encoding MarkConfig.shape"}
705+
706+ def decode_stroke(value) when is_binary(value), do: value
707+ def decode_stroke(_), do: {:error, "Unexpected type when decoding MarkConfig.stroke"}
708+
709+ def encode_stroke(value) when is_binary(value), do: value
710+ def encode_stroke(_), do: {:error, "Unexpected type when encoding MarkConfig.stroke"}
711+
712+ def decode_text(value) when is_binary(value), do: value
713+ def decode_text(_), do: {:error, "Unexpected type when decoding MarkConfig.text"}
714+
715+ def encode_text(value) when is_binary(value), do: value
716+ def encode_text(_), do: {:error, "Unexpected type when encoding MarkConfig.text"}
717+
676718 def from_map(m) do
677719 %MarkConfig{
678720 align: m["align"] && HorizontalAlign.decode(m["align"]),
679721 angle: m["angle"],
680722 baseline: m["baseline"] && VerticalAlign.decode(m["baseline"]),
681- color: m["color"],
723+ color: m["color"] && decode_color(m["color"]),
682724 cursor: m["cursor"] && Cursor.decode(m["cursor"]),
683725 dx: m["dx"],
684726 dy: m["dy"],
685- fill: m["fill"],
727+ fill: m["fill"] && decode_fill(m["fill"]),
686728 filled: m["filled"],
687729 fill_opacity: m["fillOpacity"],
688- font: m["font"],
730+ font: m["font"] && decode_font(m["font"]),
689731 font_size: m["fontSize"],
690732 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
691733 font_weight: decode_font_weight(m["fontWeight"]),
692- href: m["href"],
734+ href: m["href"] && decode_href(m["href"]),
693735 interpolate: m["interpolate"] && Interpolate.decode(m["interpolate"]),
694736 limit: m["limit"],
695737 opacity: m["opacity"],
696738 orient: m["orient"] && Orient.decode(m["orient"]),
697739 radius: m["radius"],
698- shape: m["shape"],
740+ shape: m["shape"] && decode_shape(m["shape"]),
699741 size: m["size"],
700- stroke: m["stroke"],
742+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
701743 stroke_dash: m["strokeDash"],
702744 stroke_dash_offset: m["strokeDashOffset"],
703745 stroke_opacity: m["strokeOpacity"],
704746 stroke_width: m["strokeWidth"],
705747 tension: m["tension"],
706- text: m["text"],
748+ text: m["text"] && decode_text(m["text"]),
707749 theta: m["theta"],
708750 }
709751 end
@@ -892,6 +934,30 @@ defmodule AxisConfig do
892934 title_y: float() | nil
893935 }
894936
937+ def decode_domain_color(value) when is_binary(value), do: value
938+ def decode_domain_color(_), do: {:error, "Unexpected type when decoding AxisConfig.domain_color"}
939+
940+ def encode_domain_color(value) when is_binary(value), do: value
941+ def encode_domain_color(_), do: {:error, "Unexpected type when encoding AxisConfig.domain_color"}
942+
943+ def decode_grid_color(value) when is_binary(value), do: value
944+ def decode_grid_color(_), do: {:error, "Unexpected type when decoding AxisConfig.grid_color"}
945+
946+ def encode_grid_color(value) when is_binary(value), do: value
947+ def encode_grid_color(_), do: {:error, "Unexpected type when encoding AxisConfig.grid_color"}
948+
949+ def decode_label_color(value) when is_binary(value), do: value
950+ def decode_label_color(_), do: {:error, "Unexpected type when decoding AxisConfig.label_color"}
951+
952+ def encode_label_color(value) when is_binary(value), do: value
953+ def encode_label_color(_), do: {:error, "Unexpected type when encoding AxisConfig.label_color"}
954+
955+ def decode_label_font(value) when is_binary(value), do: value
956+ def decode_label_font(_), do: {:error, "Unexpected type when decoding AxisConfig.label_font"}
957+
958+ def encode_label_font(value) when is_binary(value), do: value
959+ def encode_label_font(_), do: {:error, "Unexpected type when encoding AxisConfig.label_font"}
960+
895961 def decode_label_overlap(value) when is_boolean(value), do: value
896962 def decode_label_overlap(value) when is_binary(value), do: LabelOverlapEnum.decode(value)
897963 def decode_label_overlap(value) when is_nil(value), do: value
@@ -902,22 +968,52 @@ defmodule AxisConfig do
902968 def encode_label_overlap(value) when is_nil(value), do: value
903969 def encode_label_overlap(_), do: {:error, "Unexpected type when encoding AxisConfig.label_overlap"}
904970
971+ def decode_tick_color(value) when is_binary(value), do: value
972+ def decode_tick_color(_), do: {:error, "Unexpected type when decoding AxisConfig.tick_color"}
973+
974+ def encode_tick_color(value) when is_binary(value), do: value
975+ def encode_tick_color(_), do: {:error, "Unexpected type when encoding AxisConfig.tick_color"}
976+
977+ def decode_title_align(value) when is_binary(value), do: value
978+ def decode_title_align(_), do: {:error, "Unexpected type when decoding AxisConfig.title_align"}
979+
980+ def encode_title_align(value) when is_binary(value), do: value
981+ def encode_title_align(_), do: {:error, "Unexpected type when encoding AxisConfig.title_align"}
982+
983+ def decode_title_baseline(value) when is_binary(value), do: value
984+ def decode_title_baseline(_), do: {:error, "Unexpected type when decoding AxisConfig.title_baseline"}
985+
986+ def encode_title_baseline(value) when is_binary(value), do: value
987+ def encode_title_baseline(_), do: {:error, "Unexpected type when encoding AxisConfig.title_baseline"}
988+
989+ def decode_title_color(value) when is_binary(value), do: value
990+ def decode_title_color(_), do: {:error, "Unexpected type when decoding AxisConfig.title_color"}
991+
992+ def encode_title_color(value) when is_binary(value), do: value
993+ def encode_title_color(_), do: {:error, "Unexpected type when encoding AxisConfig.title_color"}
994+
995+ def decode_title_font(value) when is_binary(value), do: value
996+ def decode_title_font(_), do: {:error, "Unexpected type when decoding AxisConfig.title_font"}
997+
998+ def encode_title_font(value) when is_binary(value), do: value
999+ def encode_title_font(_), do: {:error, "Unexpected type when encoding AxisConfig.title_font"}
1000+
9051001 def from_map(m) do
9061002 %AxisConfig{
9071003 band_position: m["bandPosition"],
9081004 domain: m["domain"],
909- domain_color: m["domainColor"],
1005+ domain_color: m["domainColor"] && decode_domain_color(m["domainColor"]),
9101006 domain_width: m["domainWidth"],
9111007 grid: m["grid"],
912- grid_color: m["gridColor"],
1008+ grid_color: m["gridColor"] && decode_grid_color(m["gridColor"]),
9131009 grid_dash: m["gridDash"],
9141010 grid_opacity: m["gridOpacity"],
9151011 grid_width: m["gridWidth"],
9161012 label_angle: m["labelAngle"],
9171013 label_bound: m["labelBound"],
918- label_color: m["labelColor"],
1014+ label_color: m["labelColor"] && decode_label_color(m["labelColor"]),
9191015 label_flush: m["labelFlush"],
920- label_font: m["labelFont"],
1016+ label_font: m["labelFont"] && decode_label_font(m["labelFont"]),
9211017 label_font_size: m["labelFontSize"],
9221018 label_limit: m["labelLimit"],
9231019 label_overlap: decode_label_overlap(m["labelOverlap"]),
@@ -926,16 +1022,16 @@ defmodule AxisConfig do
9261022 max_extent: m["maxExtent"],
9271023 min_extent: m["minExtent"],
9281024 short_time_labels: m["shortTimeLabels"],
929- tick_color: m["tickColor"],
1025+ tick_color: m["tickColor"] && decode_tick_color(m["tickColor"]),
9301026 tick_round: m["tickRound"],
9311027 ticks: m["ticks"],
9321028 tick_size: m["tickSize"],
9331029 tick_width: m["tickWidth"],
934- title_align: m["titleAlign"],
1030+ title_align: m["titleAlign"] && decode_title_align(m["titleAlign"]),
9351031 title_angle: m["titleAngle"],
936- title_baseline: m["titleBaseline"],
937- title_color: m["titleColor"],
938- title_font: m["titleFont"],
1032+ title_baseline: m["titleBaseline"] && decode_title_baseline(m["titleBaseline"]),
1033+ title_color: m["titleColor"] && decode_title_color(m["titleColor"]),
1034+ title_font: m["titleFont"] && decode_title_font(m["titleFont"]),
9391035 title_font_size: m["titleFontSize"],
9401036 title_font_weight: m["titleFontWeight"],
9411037 title_limit: m["titleLimit"],
@@ -1101,6 +1197,30 @@ defmodule VGAxisConfig do
11011197 title_y: float() | nil
11021198 }
11031199
1200+ def decode_domain_color(value) when is_binary(value), do: value
1201+ def decode_domain_color(_), do: {:error, "Unexpected type when decoding VGAxisConfig.domain_color"}
1202+
1203+ def encode_domain_color(value) when is_binary(value), do: value
1204+ def encode_domain_color(_), do: {:error, "Unexpected type when encoding VGAxisConfig.domain_color"}
1205+
1206+ def decode_grid_color(value) when is_binary(value), do: value
1207+ def decode_grid_color(_), do: {:error, "Unexpected type when decoding VGAxisConfig.grid_color"}
1208+
1209+ def encode_grid_color(value) when is_binary(value), do: value
1210+ def encode_grid_color(_), do: {:error, "Unexpected type when encoding VGAxisConfig.grid_color"}
1211+
1212+ def decode_label_color(value) when is_binary(value), do: value
1213+ def decode_label_color(_), do: {:error, "Unexpected type when decoding VGAxisConfig.label_color"}
1214+
1215+ def encode_label_color(value) when is_binary(value), do: value
1216+ def encode_label_color(_), do: {:error, "Unexpected type when encoding VGAxisConfig.label_color"}
1217+
1218+ def decode_label_font(value) when is_binary(value), do: value
1219+ def decode_label_font(_), do: {:error, "Unexpected type when decoding VGAxisConfig.label_font"}
1220+
1221+ def encode_label_font(value) when is_binary(value), do: value
1222+ def encode_label_font(_), do: {:error, "Unexpected type when encoding VGAxisConfig.label_font"}
1223+
11041224 def decode_label_overlap(value) when is_boolean(value), do: value
11051225 def decode_label_overlap(value) when is_binary(value), do: LabelOverlapEnum.decode(value)
11061226 def decode_label_overlap(value) when is_nil(value), do: value
@@ -1111,22 +1231,52 @@ defmodule VGAxisConfig do
11111231 def encode_label_overlap(value) when is_nil(value), do: value
11121232 def encode_label_overlap(_), do: {:error, "Unexpected type when encoding VGAxisConfig.label_overlap"}
11131233
1234+ def decode_tick_color(value) when is_binary(value), do: value
1235+ def decode_tick_color(_), do: {:error, "Unexpected type when decoding VGAxisConfig.tick_color"}
1236+
1237+ def encode_tick_color(value) when is_binary(value), do: value
1238+ def encode_tick_color(_), do: {:error, "Unexpected type when encoding VGAxisConfig.tick_color"}
1239+
1240+ def decode_title_align(value) when is_binary(value), do: value
1241+ def decode_title_align(_), do: {:error, "Unexpected type when decoding VGAxisConfig.title_align"}
1242+
1243+ def encode_title_align(value) when is_binary(value), do: value
1244+ def encode_title_align(_), do: {:error, "Unexpected type when encoding VGAxisConfig.title_align"}
1245+
1246+ def decode_title_baseline(value) when is_binary(value), do: value
1247+ def decode_title_baseline(_), do: {:error, "Unexpected type when decoding VGAxisConfig.title_baseline"}
1248+
1249+ def encode_title_baseline(value) when is_binary(value), do: value
1250+ def encode_title_baseline(_), do: {:error, "Unexpected type when encoding VGAxisConfig.title_baseline"}
1251+
1252+ def decode_title_color(value) when is_binary(value), do: value
1253+ def decode_title_color(_), do: {:error, "Unexpected type when decoding VGAxisConfig.title_color"}
1254+
1255+ def encode_title_color(value) when is_binary(value), do: value
1256+ def encode_title_color(_), do: {:error, "Unexpected type when encoding VGAxisConfig.title_color"}
1257+
1258+ def decode_title_font(value) when is_binary(value), do: value
1259+ def decode_title_font(_), do: {:error, "Unexpected type when decoding VGAxisConfig.title_font"}
1260+
1261+ def encode_title_font(value) when is_binary(value), do: value
1262+ def encode_title_font(_), do: {:error, "Unexpected type when encoding VGAxisConfig.title_font"}
1263+
11141264 def from_map(m) do
11151265 %VGAxisConfig{
11161266 band_position: m["bandPosition"],
11171267 domain: m["domain"],
1118- domain_color: m["domainColor"],
1268+ domain_color: m["domainColor"] && decode_domain_color(m["domainColor"]),
11191269 domain_width: m["domainWidth"],
11201270 grid: m["grid"],
1121- grid_color: m["gridColor"],
1271+ grid_color: m["gridColor"] && decode_grid_color(m["gridColor"]),
11221272 grid_dash: m["gridDash"],
11231273 grid_opacity: m["gridOpacity"],
11241274 grid_width: m["gridWidth"],
11251275 label_angle: m["labelAngle"],
11261276 label_bound: m["labelBound"],
1127- label_color: m["labelColor"],
1277+ label_color: m["labelColor"] && decode_label_color(m["labelColor"]),
11281278 label_flush: m["labelFlush"],
1129- label_font: m["labelFont"],
1279+ label_font: m["labelFont"] && decode_label_font(m["labelFont"]),
11301280 label_font_size: m["labelFontSize"],
11311281 label_limit: m["labelLimit"],
11321282 label_overlap: decode_label_overlap(m["labelOverlap"]),
@@ -1134,16 +1284,16 @@ defmodule VGAxisConfig do
11341284 labels: m["labels"],
11351285 max_extent: m["maxExtent"],
11361286 min_extent: m["minExtent"],
1137- tick_color: m["tickColor"],
1287+ tick_color: m["tickColor"] && decode_tick_color(m["tickColor"]),
11381288 tick_round: m["tickRound"],
11391289 ticks: m["ticks"],
11401290 tick_size: m["tickSize"],
11411291 tick_width: m["tickWidth"],
1142- title_align: m["titleAlign"],
1292+ title_align: m["titleAlign"] && decode_title_align(m["titleAlign"]),
11431293 title_angle: m["titleAngle"],
1144- title_baseline: m["titleBaseline"],
1145- title_color: m["titleColor"],
1146- title_font: m["titleFont"],
1294+ title_baseline: m["titleBaseline"] && decode_title_baseline(m["titleBaseline"]),
1295+ title_color: m["titleColor"] && decode_title_color(m["titleColor"]),
1296+ title_font: m["titleFont"] && decode_title_font(m["titleFont"]),
11471297 title_font_size: m["titleFontSize"],
11481298 title_font_weight: m["titleFontWeight"],
11491299 title_limit: m["titleLimit"],
@@ -1286,6 +1436,24 @@ defmodule BarConfig do
12861436 theta: float() | nil
12871437 }
12881438
1439+ def decode_color(value) when is_binary(value), do: value
1440+ def decode_color(_), do: {:error, "Unexpected type when decoding BarConfig.color"}
1441+
1442+ def encode_color(value) when is_binary(value), do: value
1443+ def encode_color(_), do: {:error, "Unexpected type when encoding BarConfig.color"}
1444+
1445+ def decode_fill(value) when is_binary(value), do: value
1446+ def decode_fill(_), do: {:error, "Unexpected type when decoding BarConfig.fill"}
1447+
1448+ def encode_fill(value) when is_binary(value), do: value
1449+ def encode_fill(_), do: {:error, "Unexpected type when encoding BarConfig.fill"}
1450+
1451+ def decode_font(value) when is_binary(value), do: value
1452+ def decode_font(_), do: {:error, "Unexpected type when decoding BarConfig.font"}
1453+
1454+ def encode_font(value) when is_binary(value), do: value
1455+ def encode_font(_), do: {:error, "Unexpected type when encoding BarConfig.font"}
1456+
12891457 def decode_font_weight(value) when is_binary(value), do: FontWeight.decode(value)
12901458 def decode_font_weight(value) when is_float(value), do: value
12911459 def decode_font_weight(value) when is_integer(value), do: value
@@ -1298,40 +1466,64 @@ defmodule BarConfig do
12981466 def encode_font_weight(value) when is_nil(value), do: value
12991467 def encode_font_weight(_), do: {:error, "Unexpected type when encoding BarConfig.font_weight"}
13001468
1469+ def decode_href(value) when is_binary(value), do: value
1470+ def decode_href(_), do: {:error, "Unexpected type when decoding BarConfig.href"}
1471+
1472+ def encode_href(value) when is_binary(value), do: value
1473+ def encode_href(_), do: {:error, "Unexpected type when encoding BarConfig.href"}
1474+
1475+ def decode_shape(value) when is_binary(value), do: value
1476+ def decode_shape(_), do: {:error, "Unexpected type when decoding BarConfig.shape"}
1477+
1478+ def encode_shape(value) when is_binary(value), do: value
1479+ def encode_shape(_), do: {:error, "Unexpected type when encoding BarConfig.shape"}
1480+
1481+ def decode_stroke(value) when is_binary(value), do: value
1482+ def decode_stroke(_), do: {:error, "Unexpected type when decoding BarConfig.stroke"}
1483+
1484+ def encode_stroke(value) when is_binary(value), do: value
1485+ def encode_stroke(_), do: {:error, "Unexpected type when encoding BarConfig.stroke"}
1486+
1487+ def decode_text(value) when is_binary(value), do: value
1488+ def decode_text(_), do: {:error, "Unexpected type when decoding BarConfig.text"}
1489+
1490+ def encode_text(value) when is_binary(value), do: value
1491+ def encode_text(_), do: {:error, "Unexpected type when encoding BarConfig.text"}
1492+
13011493 def from_map(m) do
13021494 %BarConfig{
13031495 align: m["align"] && HorizontalAlign.decode(m["align"]),
13041496 angle: m["angle"],
13051497 baseline: m["baseline"] && VerticalAlign.decode(m["baseline"]),
13061498 bin_spacing: m["binSpacing"],
1307- color: m["color"],
1499+ color: m["color"] && decode_color(m["color"]),
13081500 continuous_band_size: m["continuousBandSize"],
13091501 cursor: m["cursor"] && Cursor.decode(m["cursor"]),
13101502 discrete_band_size: m["discreteBandSize"],
13111503 dx: m["dx"],
13121504 dy: m["dy"],
1313- fill: m["fill"],
1505+ fill: m["fill"] && decode_fill(m["fill"]),
13141506 filled: m["filled"],
13151507 fill_opacity: m["fillOpacity"],
1316- font: m["font"],
1508+ font: m["font"] && decode_font(m["font"]),
13171509 font_size: m["fontSize"],
13181510 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
13191511 font_weight: decode_font_weight(m["fontWeight"]),
1320- href: m["href"],
1512+ href: m["href"] && decode_href(m["href"]),
13211513 interpolate: m["interpolate"] && Interpolate.decode(m["interpolate"]),
13221514 limit: m["limit"],
13231515 opacity: m["opacity"],
13241516 orient: m["orient"] && Orient.decode(m["orient"]),
13251517 radius: m["radius"],
1326- shape: m["shape"],
1518+ shape: m["shape"] && decode_shape(m["shape"]),
13271519 size: m["size"],
1328- stroke: m["stroke"],
1520+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
13291521 stroke_dash: m["strokeDash"],
13301522 stroke_dash_offset: m["strokeDashOffset"],
13311523 stroke_opacity: m["strokeOpacity"],
13321524 stroke_width: m["strokeWidth"],
13331525 tension: m["tension"],
1334- text: m["text"],
1526+ text: m["text"] && decode_text(m["text"]),
13351527 theta: m["theta"],
13361528 }
13371529 end
@@ -1637,22 +1829,106 @@ defmodule LegendConfig do
16371829 title_padding: float() | nil
16381830 }
16391831
1832+ def decode_fill_color(value) when is_binary(value), do: value
1833+ def decode_fill_color(_), do: {:error, "Unexpected type when decoding LegendConfig.fill_color"}
1834+
1835+ def encode_fill_color(value) when is_binary(value), do: value
1836+ def encode_fill_color(_), do: {:error, "Unexpected type when encoding LegendConfig.fill_color"}
1837+
1838+ def decode_gradient_label_baseline(value) when is_binary(value), do: value
1839+ def decode_gradient_label_baseline(_), do: {:error, "Unexpected type when decoding LegendConfig.gradient_label_baseline"}
1840+
1841+ def encode_gradient_label_baseline(value) when is_binary(value), do: value
1842+ def encode_gradient_label_baseline(_), do: {:error, "Unexpected type when encoding LegendConfig.gradient_label_baseline"}
1843+
1844+ def decode_gradient_stroke_color(value) when is_binary(value), do: value
1845+ def decode_gradient_stroke_color(_), do: {:error, "Unexpected type when decoding LegendConfig.gradient_stroke_color"}
1846+
1847+ def encode_gradient_stroke_color(value) when is_binary(value), do: value
1848+ def encode_gradient_stroke_color(_), do: {:error, "Unexpected type when encoding LegendConfig.gradient_stroke_color"}
1849+
1850+ def decode_label_align(value) when is_binary(value), do: value
1851+ def decode_label_align(_), do: {:error, "Unexpected type when decoding LegendConfig.label_align"}
1852+
1853+ def encode_label_align(value) when is_binary(value), do: value
1854+ def encode_label_align(_), do: {:error, "Unexpected type when encoding LegendConfig.label_align"}
1855+
1856+ def decode_label_baseline(value) when is_binary(value), do: value
1857+ def decode_label_baseline(_), do: {:error, "Unexpected type when decoding LegendConfig.label_baseline"}
1858+
1859+ def encode_label_baseline(value) when is_binary(value), do: value
1860+ def encode_label_baseline(_), do: {:error, "Unexpected type when encoding LegendConfig.label_baseline"}
1861+
1862+ def decode_label_color(value) when is_binary(value), do: value
1863+ def decode_label_color(_), do: {:error, "Unexpected type when decoding LegendConfig.label_color"}
1864+
1865+ def encode_label_color(value) when is_binary(value), do: value
1866+ def encode_label_color(_), do: {:error, "Unexpected type when encoding LegendConfig.label_color"}
1867+
1868+ def decode_label_font(value) when is_binary(value), do: value
1869+ def decode_label_font(_), do: {:error, "Unexpected type when decoding LegendConfig.label_font"}
1870+
1871+ def encode_label_font(value) when is_binary(value), do: value
1872+ def encode_label_font(_), do: {:error, "Unexpected type when encoding LegendConfig.label_font"}
1873+
1874+ def decode_stroke_color(value) when is_binary(value), do: value
1875+ def decode_stroke_color(_), do: {:error, "Unexpected type when decoding LegendConfig.stroke_color"}
1876+
1877+ def encode_stroke_color(value) when is_binary(value), do: value
1878+ def encode_stroke_color(_), do: {:error, "Unexpected type when encoding LegendConfig.stroke_color"}
1879+
1880+ def decode_symbol_color(value) when is_binary(value), do: value
1881+ def decode_symbol_color(_), do: {:error, "Unexpected type when decoding LegendConfig.symbol_color"}
1882+
1883+ def encode_symbol_color(value) when is_binary(value), do: value
1884+ def encode_symbol_color(_), do: {:error, "Unexpected type when encoding LegendConfig.symbol_color"}
1885+
1886+ def decode_symbol_type(value) when is_binary(value), do: value
1887+ def decode_symbol_type(_), do: {:error, "Unexpected type when decoding LegendConfig.symbol_type"}
1888+
1889+ def encode_symbol_type(value) when is_binary(value), do: value
1890+ def encode_symbol_type(_), do: {:error, "Unexpected type when encoding LegendConfig.symbol_type"}
1891+
1892+ def decode_title_align(value) when is_binary(value), do: value
1893+ def decode_title_align(_), do: {:error, "Unexpected type when decoding LegendConfig.title_align"}
1894+
1895+ def encode_title_align(value) when is_binary(value), do: value
1896+ def encode_title_align(_), do: {:error, "Unexpected type when encoding LegendConfig.title_align"}
1897+
1898+ def decode_title_baseline(value) when is_binary(value), do: value
1899+ def decode_title_baseline(_), do: {:error, "Unexpected type when decoding LegendConfig.title_baseline"}
1900+
1901+ def encode_title_baseline(value) when is_binary(value), do: value
1902+ def encode_title_baseline(_), do: {:error, "Unexpected type when encoding LegendConfig.title_baseline"}
1903+
1904+ def decode_title_color(value) when is_binary(value), do: value
1905+ def decode_title_color(_), do: {:error, "Unexpected type when decoding LegendConfig.title_color"}
1906+
1907+ def encode_title_color(value) when is_binary(value), do: value
1908+ def encode_title_color(_), do: {:error, "Unexpected type when encoding LegendConfig.title_color"}
1909+
1910+ def decode_title_font(value) when is_binary(value), do: value
1911+ def decode_title_font(_), do: {:error, "Unexpected type when decoding LegendConfig.title_font"}
1912+
1913+ def encode_title_font(value) when is_binary(value), do: value
1914+ def encode_title_font(_), do: {:error, "Unexpected type when encoding LegendConfig.title_font"}
1915+
16401916 def from_map(m) do
16411917 %LegendConfig{
16421918 corner_radius: m["cornerRadius"],
16431919 entry_padding: m["entryPadding"],
1644- fill_color: m["fillColor"],
1920+ fill_color: m["fillColor"] && decode_fill_color(m["fillColor"]),
16451921 gradient_height: m["gradientHeight"],
1646- gradient_label_baseline: m["gradientLabelBaseline"],
1922+ gradient_label_baseline: m["gradientLabelBaseline"] && decode_gradient_label_baseline(m["gradientLabelBaseline"]),
16471923 gradient_label_limit: m["gradientLabelLimit"],
16481924 gradient_label_offset: m["gradientLabelOffset"],
1649- gradient_stroke_color: m["gradientStrokeColor"],
1925+ gradient_stroke_color: m["gradientStrokeColor"] && decode_gradient_stroke_color(m["gradientStrokeColor"]),
16501926 gradient_stroke_width: m["gradientStrokeWidth"],
16511927 gradient_width: m["gradientWidth"],
1652- label_align: m["labelAlign"],
1653- label_baseline: m["labelBaseline"],
1654- label_color: m["labelColor"],
1655- label_font: m["labelFont"],
1928+ label_align: m["labelAlign"] && decode_label_align(m["labelAlign"]),
1929+ label_baseline: m["labelBaseline"] && decode_label_baseline(m["labelBaseline"]),
1930+ label_color: m["labelColor"] && decode_label_color(m["labelColor"]),
1931+ label_font: m["labelFont"] && decode_label_font(m["labelFont"]),
16561932 label_font_size: m["labelFontSize"],
16571933 label_limit: m["labelLimit"],
16581934 label_offset: m["labelOffset"],
@@ -1660,17 +1936,17 @@ defmodule LegendConfig do
16601936 orient: m["orient"] && LegendOrient.decode(m["orient"]),
16611937 padding: m["padding"],
16621938 short_time_labels: m["shortTimeLabels"],
1663- stroke_color: m["strokeColor"],
1939+ stroke_color: m["strokeColor"] && decode_stroke_color(m["strokeColor"]),
16641940 stroke_dash: m["strokeDash"],
16651941 stroke_width: m["strokeWidth"],
1666- symbol_color: m["symbolColor"],
1942+ symbol_color: m["symbolColor"] && decode_symbol_color(m["symbolColor"]),
16671943 symbol_size: m["symbolSize"],
16681944 symbol_stroke_width: m["symbolStrokeWidth"],
1669- symbol_type: m["symbolType"],
1670- title_align: m["titleAlign"],
1671- title_baseline: m["titleBaseline"],
1672- title_color: m["titleColor"],
1673- title_font: m["titleFont"],
1945+ symbol_type: m["symbolType"] && decode_symbol_type(m["symbolType"]),
1946+ title_align: m["titleAlign"] && decode_title_align(m["titleAlign"]),
1947+ title_baseline: m["titleBaseline"] && decode_title_baseline(m["titleBaseline"]),
1948+ title_color: m["titleColor"] && decode_title_color(m["titleColor"]),
1949+ title_font: m["titleFont"] && decode_title_font(m["titleFont"]),
16741950 title_font_size: m["titleFontSize"],
16751951 title_font_weight: m["titleFontWeight"],
16761952 title_limit: m["titleLimit"],
@@ -1949,11 +2225,17 @@ defmodule VGScheme do
19492225 step: float() | nil
19502226 }
19512227
2228+ def decode_scheme(value) when is_binary(value), do: value
2229+ def decode_scheme(_), do: {:error, "Unexpected type when decoding VGScheme.scheme"}
2230+
2231+ def encode_scheme(value) when is_binary(value), do: value
2232+ def encode_scheme(_), do: {:error, "Unexpected type when encoding VGScheme.scheme"}
2233+
19522234 def from_map(m) do
19532235 %VGScheme{
19542236 count: m["count"],
19552237 extent: m["extent"],
1956- scheme: m["scheme"],
2238+ scheme: m["scheme"] && decode_scheme(m["scheme"]),
19572239 step: m["step"],
19582240 }
19592241 end
@@ -2274,11 +2556,23 @@ defmodule BrushConfig do
22742556 stroke_width: float() | nil
22752557 }
22762558
2559+ def decode_fill(value) when is_binary(value), do: value
2560+ def decode_fill(_), do: {:error, "Unexpected type when decoding BrushConfig.fill"}
2561+
2562+ def encode_fill(value) when is_binary(value), do: value
2563+ def encode_fill(_), do: {:error, "Unexpected type when encoding BrushConfig.fill"}
2564+
2565+ def decode_stroke(value) when is_binary(value), do: value
2566+ def decode_stroke(_), do: {:error, "Unexpected type when decoding BrushConfig.stroke"}
2567+
2568+ def encode_stroke(value) when is_binary(value), do: value
2569+ def encode_stroke(_), do: {:error, "Unexpected type when encoding BrushConfig.stroke"}
2570+
22772571 def from_map(m) do
22782572 %BrushConfig{
2279- fill: m["fill"],
2573+ fill: m["fill"] && decode_fill(m["fill"]),
22802574 fill_opacity: m["fillOpacity"],
2281- stroke: m["stroke"],
2575+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
22822576 stroke_dash: m["strokeDash"],
22832577 stroke_dash_offset: m["strokeDashOffset"],
22842578 stroke_opacity: m["strokeOpacity"],
@@ -2516,6 +2810,12 @@ defmodule VGBinding do
25162810 step: float() | nil
25172811 }
25182812
2813+ def decode_element(value) when is_binary(value), do: value
2814+ def decode_element(_), do: {:error, "Unexpected type when decoding VGBinding.element"}
2815+
2816+ def encode_element(value) when is_binary(value), do: value
2817+ def encode_element(_), do: {:error, "Unexpected type when encoding VGBinding.element"}
2818+
25192819 def decode_input(value) when is_binary(value), do: value
25202820 def decode_input(_), do: {:error, "Unexpected type when decoding VGBinding.input"}
25212821
@@ -2524,7 +2824,7 @@ defmodule VGBinding do
25242824
25252825 def from_map(m) do
25262826 %VGBinding{
2527- element: m["element"],
2827+ element: m["element"] && decode_element(m["element"]),
25282828 input: decode_input(m["input"]),
25292829 options: m["options"],
25302830 max: m["max"],
@@ -2785,6 +3085,18 @@ defmodule VGMarkConfig do
27853085 theta: float() | nil
27863086 }
27873087
3088+ def decode_fill(value) when is_binary(value), do: value
3089+ def decode_fill(_), do: {:error, "Unexpected type when decoding VGMarkConfig.fill"}
3090+
3091+ def encode_fill(value) when is_binary(value), do: value
3092+ def encode_fill(_), do: {:error, "Unexpected type when encoding VGMarkConfig.fill"}
3093+
3094+ def decode_font(value) when is_binary(value), do: value
3095+ def decode_font(_), do: {:error, "Unexpected type when decoding VGMarkConfig.font"}
3096+
3097+ def encode_font(value) when is_binary(value), do: value
3098+ def encode_font(_), do: {:error, "Unexpected type when encoding VGMarkConfig.font"}
3099+
27883100 def decode_font_weight(value) when is_binary(value), do: FontWeight.decode(value)
27893101 def decode_font_weight(value) when is_float(value), do: value
27903102 def decode_font_weight(value) when is_integer(value), do: value
@@ -2797,6 +3109,30 @@ defmodule VGMarkConfig do
27973109 def encode_font_weight(value) when is_nil(value), do: value
27983110 def encode_font_weight(_), do: {:error, "Unexpected type when encoding VGMarkConfig.font_weight"}
27993111
3112+ def decode_href(value) when is_binary(value), do: value
3113+ def decode_href(_), do: {:error, "Unexpected type when decoding VGMarkConfig.href"}
3114+
3115+ def encode_href(value) when is_binary(value), do: value
3116+ def encode_href(_), do: {:error, "Unexpected type when encoding VGMarkConfig.href"}
3117+
3118+ def decode_shape(value) when is_binary(value), do: value
3119+ def decode_shape(_), do: {:error, "Unexpected type when decoding VGMarkConfig.shape"}
3120+
3121+ def encode_shape(value) when is_binary(value), do: value
3122+ def encode_shape(_), do: {:error, "Unexpected type when encoding VGMarkConfig.shape"}
3123+
3124+ def decode_stroke(value) when is_binary(value), do: value
3125+ def decode_stroke(_), do: {:error, "Unexpected type when decoding VGMarkConfig.stroke"}
3126+
3127+ def encode_stroke(value) when is_binary(value), do: value
3128+ def encode_stroke(_), do: {:error, "Unexpected type when encoding VGMarkConfig.stroke"}
3129+
3130+ def decode_text(value) when is_binary(value), do: value
3131+ def decode_text(_), do: {:error, "Unexpected type when decoding VGMarkConfig.text"}
3132+
3133+ def encode_text(value) when is_binary(value), do: value
3134+ def encode_text(_), do: {:error, "Unexpected type when encoding VGMarkConfig.text"}
3135+
28003136 def from_map(m) do
28013137 %VGMarkConfig{
28023138 align: m["align"] && HorizontalAlign.decode(m["align"]),
@@ -2805,27 +3141,27 @@ defmodule VGMarkConfig do
28053141 cursor: m["cursor"] && Cursor.decode(m["cursor"]),
28063142 dx: m["dx"],
28073143 dy: m["dy"],
2808- fill: m["fill"],
3144+ fill: m["fill"] && decode_fill(m["fill"]),
28093145 fill_opacity: m["fillOpacity"],
2810- font: m["font"],
3146+ font: m["font"] && decode_font(m["font"]),
28113147 font_size: m["fontSize"],
28123148 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
28133149 font_weight: decode_font_weight(m["fontWeight"]),
2814- href: m["href"],
3150+ href: m["href"] && decode_href(m["href"]),
28153151 interpolate: m["interpolate"] && Interpolate.decode(m["interpolate"]),
28163152 limit: m["limit"],
28173153 opacity: m["opacity"],
28183154 orient: m["orient"] && Orient.decode(m["orient"]),
28193155 radius: m["radius"],
2820- shape: m["shape"],
3156+ shape: m["shape"] && decode_shape(m["shape"]),
28213157 size: m["size"],
2822- stroke: m["stroke"],
3158+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
28233159 stroke_dash: m["strokeDash"],
28243160 stroke_dash_offset: m["strokeDashOffset"],
28253161 stroke_opacity: m["strokeOpacity"],
28263162 stroke_width: m["strokeWidth"],
28273163 tension: m["tension"],
2828- text: m["text"],
3164+ text: m["text"] && decode_text(m["text"]),
28293165 theta: m["theta"],
28303166 }
28313167 end
@@ -2948,6 +3284,24 @@ defmodule TextConfig do
29483284 theta: float() | nil
29493285 }
29503286
3287+ def decode_color(value) when is_binary(value), do: value
3288+ def decode_color(_), do: {:error, "Unexpected type when decoding TextConfig.color"}
3289+
3290+ def encode_color(value) when is_binary(value), do: value
3291+ def encode_color(_), do: {:error, "Unexpected type when encoding TextConfig.color"}
3292+
3293+ def decode_fill(value) when is_binary(value), do: value
3294+ def decode_fill(_), do: {:error, "Unexpected type when decoding TextConfig.fill"}
3295+
3296+ def encode_fill(value) when is_binary(value), do: value
3297+ def encode_fill(_), do: {:error, "Unexpected type when encoding TextConfig.fill"}
3298+
3299+ def decode_font(value) when is_binary(value), do: value
3300+ def decode_font(_), do: {:error, "Unexpected type when decoding TextConfig.font"}
3301+
3302+ def encode_font(value) when is_binary(value), do: value
3303+ def encode_font(_), do: {:error, "Unexpected type when encoding TextConfig.font"}
3304+
29513305 def decode_font_weight(value) when is_binary(value), do: FontWeight.decode(value)
29523306 def decode_font_weight(value) when is_float(value), do: value
29533307 def decode_font_weight(value) when is_integer(value), do: value
@@ -2960,38 +3314,62 @@ defmodule TextConfig do
29603314 def encode_font_weight(value) when is_nil(value), do: value
29613315 def encode_font_weight(_), do: {:error, "Unexpected type when encoding TextConfig.font_weight"}
29623316
3317+ def decode_href(value) when is_binary(value), do: value
3318+ def decode_href(_), do: {:error, "Unexpected type when decoding TextConfig.href"}
3319+
3320+ def encode_href(value) when is_binary(value), do: value
3321+ def encode_href(_), do: {:error, "Unexpected type when encoding TextConfig.href"}
3322+
3323+ def decode_shape(value) when is_binary(value), do: value
3324+ def decode_shape(_), do: {:error, "Unexpected type when decoding TextConfig.shape"}
3325+
3326+ def encode_shape(value) when is_binary(value), do: value
3327+ def encode_shape(_), do: {:error, "Unexpected type when encoding TextConfig.shape"}
3328+
3329+ def decode_stroke(value) when is_binary(value), do: value
3330+ def decode_stroke(_), do: {:error, "Unexpected type when decoding TextConfig.stroke"}
3331+
3332+ def encode_stroke(value) when is_binary(value), do: value
3333+ def encode_stroke(_), do: {:error, "Unexpected type when encoding TextConfig.stroke"}
3334+
3335+ def decode_text(value) when is_binary(value), do: value
3336+ def decode_text(_), do: {:error, "Unexpected type when decoding TextConfig.text"}
3337+
3338+ def encode_text(value) when is_binary(value), do: value
3339+ def encode_text(_), do: {:error, "Unexpected type when encoding TextConfig.text"}
3340+
29633341 def from_map(m) do
29643342 %TextConfig{
29653343 align: m["align"] && HorizontalAlign.decode(m["align"]),
29663344 angle: m["angle"],
29673345 baseline: m["baseline"] && VerticalAlign.decode(m["baseline"]),
2968- color: m["color"],
3346+ color: m["color"] && decode_color(m["color"]),
29693347 cursor: m["cursor"] && Cursor.decode(m["cursor"]),
29703348 dx: m["dx"],
29713349 dy: m["dy"],
2972- fill: m["fill"],
3350+ fill: m["fill"] && decode_fill(m["fill"]),
29733351 filled: m["filled"],
29743352 fill_opacity: m["fillOpacity"],
2975- font: m["font"],
3353+ font: m["font"] && decode_font(m["font"]),
29763354 font_size: m["fontSize"],
29773355 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
29783356 font_weight: decode_font_weight(m["fontWeight"]),
2979- href: m["href"],
3357+ href: m["href"] && decode_href(m["href"]),
29803358 interpolate: m["interpolate"] && Interpolate.decode(m["interpolate"]),
29813359 limit: m["limit"],
29823360 opacity: m["opacity"],
29833361 orient: m["orient"] && Orient.decode(m["orient"]),
29843362 radius: m["radius"],
2985- shape: m["shape"],
3363+ shape: m["shape"] && decode_shape(m["shape"]),
29863364 short_time_labels: m["shortTimeLabels"],
29873365 size: m["size"],
2988- stroke: m["stroke"],
3366+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
29893367 stroke_dash: m["strokeDash"],
29903368 stroke_dash_offset: m["strokeDashOffset"],
29913369 stroke_opacity: m["strokeOpacity"],
29923370 stroke_width: m["strokeWidth"],
29933371 tension: m["tension"],
2994- text: m["text"],
3372+ text: m["text"] && decode_text(m["text"]),
29953373 theta: m["theta"],
29963374 }
29973375 end
@@ -3119,6 +3497,24 @@ defmodule TickConfig do
31193497 thickness: float() | nil
31203498 }
31213499
3500+ def decode_color(value) when is_binary(value), do: value
3501+ def decode_color(_), do: {:error, "Unexpected type when decoding TickConfig.color"}
3502+
3503+ def encode_color(value) when is_binary(value), do: value
3504+ def encode_color(_), do: {:error, "Unexpected type when encoding TickConfig.color"}
3505+
3506+ def decode_fill(value) when is_binary(value), do: value
3507+ def decode_fill(_), do: {:error, "Unexpected type when decoding TickConfig.fill"}
3508+
3509+ def encode_fill(value) when is_binary(value), do: value
3510+ def encode_fill(_), do: {:error, "Unexpected type when encoding TickConfig.fill"}
3511+
3512+ def decode_font(value) when is_binary(value), do: value
3513+ def decode_font(_), do: {:error, "Unexpected type when decoding TickConfig.font"}
3514+
3515+ def encode_font(value) when is_binary(value), do: value
3516+ def encode_font(_), do: {:error, "Unexpected type when encoding TickConfig.font"}
3517+
31223518 def decode_font_weight(value) when is_binary(value), do: FontWeight.decode(value)
31233519 def decode_font_weight(value) when is_float(value), do: value
31243520 def decode_font_weight(value) when is_integer(value), do: value
@@ -3131,38 +3527,62 @@ defmodule TickConfig do
31313527 def encode_font_weight(value) when is_nil(value), do: value
31323528 def encode_font_weight(_), do: {:error, "Unexpected type when encoding TickConfig.font_weight"}
31333529
3530+ def decode_href(value) when is_binary(value), do: value
3531+ def decode_href(_), do: {:error, "Unexpected type when decoding TickConfig.href"}
3532+
3533+ def encode_href(value) when is_binary(value), do: value
3534+ def encode_href(_), do: {:error, "Unexpected type when encoding TickConfig.href"}
3535+
3536+ def decode_shape(value) when is_binary(value), do: value
3537+ def decode_shape(_), do: {:error, "Unexpected type when decoding TickConfig.shape"}
3538+
3539+ def encode_shape(value) when is_binary(value), do: value
3540+ def encode_shape(_), do: {:error, "Unexpected type when encoding TickConfig.shape"}
3541+
3542+ def decode_stroke(value) when is_binary(value), do: value
3543+ def decode_stroke(_), do: {:error, "Unexpected type when decoding TickConfig.stroke"}
3544+
3545+ def encode_stroke(value) when is_binary(value), do: value
3546+ def encode_stroke(_), do: {:error, "Unexpected type when encoding TickConfig.stroke"}
3547+
3548+ def decode_text(value) when is_binary(value), do: value
3549+ def decode_text(_), do: {:error, "Unexpected type when decoding TickConfig.text"}
3550+
3551+ def encode_text(value) when is_binary(value), do: value
3552+ def encode_text(_), do: {:error, "Unexpected type when encoding TickConfig.text"}
3553+
31343554 def from_map(m) do
31353555 %TickConfig{
31363556 align: m["align"] && HorizontalAlign.decode(m["align"]),
31373557 angle: m["angle"],
31383558 band_size: m["bandSize"],
31393559 baseline: m["baseline"] && VerticalAlign.decode(m["baseline"]),
3140- color: m["color"],
3560+ color: m["color"] && decode_color(m["color"]),
31413561 cursor: m["cursor"] && Cursor.decode(m["cursor"]),
31423562 dx: m["dx"],
31433563 dy: m["dy"],
3144- fill: m["fill"],
3564+ fill: m["fill"] && decode_fill(m["fill"]),
31453565 filled: m["filled"],
31463566 fill_opacity: m["fillOpacity"],
3147- font: m["font"],
3567+ font: m["font"] && decode_font(m["font"]),
31483568 font_size: m["fontSize"],
31493569 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
31503570 font_weight: decode_font_weight(m["fontWeight"]),
3151- href: m["href"],
3571+ href: m["href"] && decode_href(m["href"]),
31523572 interpolate: m["interpolate"] && Interpolate.decode(m["interpolate"]),
31533573 limit: m["limit"],
31543574 opacity: m["opacity"],
31553575 orient: m["orient"] && Orient.decode(m["orient"]),
31563576 radius: m["radius"],
3157- shape: m["shape"],
3577+ shape: m["shape"] && decode_shape(m["shape"]),
31583578 size: m["size"],
3159- stroke: m["stroke"],
3579+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
31603580 stroke_dash: m["strokeDash"],
31613581 stroke_dash_offset: m["strokeDashOffset"],
31623582 stroke_opacity: m["strokeOpacity"],
31633583 stroke_width: m["strokeWidth"],
31643584 tension: m["tension"],
3165- text: m["text"],
3585+ text: m["text"] && decode_text(m["text"]),
31663586 theta: m["theta"],
31673587 thickness: m["thickness"],
31683588 }
@@ -3369,6 +3789,18 @@ defmodule VGTitleConfig do
33693789 orient: TitleOrient.t() | nil
33703790 }
33713791
3792+ def decode_color(value) when is_binary(value), do: value
3793+ def decode_color(_), do: {:error, "Unexpected type when decoding VGTitleConfig.color"}
3794+
3795+ def encode_color(value) when is_binary(value), do: value
3796+ def encode_color(_), do: {:error, "Unexpected type when encoding VGTitleConfig.color"}
3797+
3798+ def decode_font(value) when is_binary(value), do: value
3799+ def decode_font(_), do: {:error, "Unexpected type when decoding VGTitleConfig.font"}
3800+
3801+ def encode_font(value) when is_binary(value), do: value
3802+ def encode_font(_), do: {:error, "Unexpected type when encoding VGTitleConfig.font"}
3803+
33723804 def decode_font_weight(value) when is_binary(value), do: FontWeight.decode(value)
33733805 def decode_font_weight(value) when is_float(value), do: value
33743806 def decode_font_weight(value) when is_integer(value), do: value
@@ -3386,8 +3818,8 @@ defmodule VGTitleConfig do
33863818 anchor: m["anchor"] && Anchor.decode(m["anchor"]),
33873819 angle: m["angle"],
33883820 baseline: m["baseline"] && VerticalAlign.decode(m["baseline"]),
3389- color: m["color"],
3390- font: m["font"],
3821+ color: m["color"] && decode_color(m["color"]),
3822+ font: m["font"] && decode_font(m["font"]),
33913823 font_size: m["fontSize"],
33923824 font_weight: decode_font_weight(m["fontWeight"]),
33933825 limit: m["limit"],
@@ -3454,13 +3886,25 @@ defmodule ViewConfig do
34543886 width: float() | nil
34553887 }
34563888
3889+ def decode_fill(value) when is_binary(value), do: value
3890+ def decode_fill(_), do: {:error, "Unexpected type when decoding ViewConfig.fill"}
3891+
3892+ def encode_fill(value) when is_binary(value), do: value
3893+ def encode_fill(_), do: {:error, "Unexpected type when encoding ViewConfig.fill"}
3894+
3895+ def decode_stroke(value) when is_binary(value), do: value
3896+ def decode_stroke(_), do: {:error, "Unexpected type when decoding ViewConfig.stroke"}
3897+
3898+ def encode_stroke(value) when is_binary(value), do: value
3899+ def encode_stroke(_), do: {:error, "Unexpected type when encoding ViewConfig.stroke"}
3900+
34573901 def from_map(m) do
34583902 %ViewConfig{
34593903 clip: m["clip"],
3460- fill: m["fill"],
3904+ fill: m["fill"] && decode_fill(m["fill"]),
34613905 fill_opacity: m["fillOpacity"],
34623906 height: m["height"],
3463- stroke: m["stroke"],
3907+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
34643908 stroke_dash: m["strokeDash"],
34653909 stroke_dash_offset: m["strokeDashOffset"],
34663910 stroke_opacity: m["strokeOpacity"],
@@ -3592,6 +4036,24 @@ defmodule ConfigClass do
35924036 def encode_autosize(value) when is_nil(value), do: value
35934037 def encode_autosize(_), do: {:error, "Unexpected type when encoding ConfigClass.autosize"}
35944038
4039+ def decode_background(value) when is_binary(value), do: value
4040+ def decode_background(_), do: {:error, "Unexpected type when decoding ConfigClass.background"}
4041+
4042+ def encode_background(value) when is_binary(value), do: value
4043+ def encode_background(_), do: {:error, "Unexpected type when encoding ConfigClass.background"}
4044+
4045+ def decode_count_title(value) when is_binary(value), do: value
4046+ def decode_count_title(_), do: {:error, "Unexpected type when decoding ConfigClass.count_title"}
4047+
4048+ def encode_count_title(value) when is_binary(value), do: value
4049+ def encode_count_title(_), do: {:error, "Unexpected type when encoding ConfigClass.count_title"}
4050+
4051+ def decode_number_format(value) when is_binary(value), do: value
4052+ def decode_number_format(_), do: {:error, "Unexpected type when decoding ConfigClass.number_format"}
4053+
4054+ def encode_number_format(value) when is_binary(value), do: value
4055+ def encode_number_format(_), do: {:error, "Unexpected type when encoding ConfigClass.number_format"}
4056+
35954057 def decode_padding(%{} = value), do: PaddingClass.from_map(value)
35964058 def decode_padding(value) when is_float(value), do: value
35974059 def decode_padding(value) when is_integer(value), do: value
@@ -3612,6 +4074,12 @@ defmodule ConfigClass do
36124074 def encode_range_value(value) when is_list(value), do: value
36134075 def encode_range_value(_), do: {:error, "Unexpected type when encoding ConfigClass.range"}
36144076
4077+ def decode_time_format(value) when is_binary(value), do: value
4078+ def decode_time_format(_), do: {:error, "Unexpected type when decoding ConfigClass.time_format"}
4079+
4080+ def encode_time_format(value) when is_binary(value), do: value
4081+ def encode_time_format(_), do: {:error, "Unexpected type when encoding ConfigClass.time_format"}
4082+
36154083 def from_map(m) do
36164084 %ConfigClass{
36174085 area: m["area"] && MarkConfig.from_map(m["area"]),
@@ -3624,17 +4092,17 @@ defmodule ConfigClass do
36244092 axis_top: m["axisTop"] && VGAxisConfig.from_map(m["axisTop"]),
36254093 axis_x: m["axisX"] && VGAxisConfig.from_map(m["axisX"]),
36264094 axis_y: m["axisY"] && VGAxisConfig.from_map(m["axisY"]),
3627- background: m["background"],
4095+ background: m["background"] && decode_background(m["background"]),
36284096 bar: m["bar"] && BarConfig.from_map(m["bar"]),
36294097 circle: m["circle"] && MarkConfig.from_map(m["circle"]),
3630- count_title: m["countTitle"],
4098+ count_title: m["countTitle"] && decode_count_title(m["countTitle"]),
36314099 field_title: m["fieldTitle"] && FieldTitle.decode(m["fieldTitle"]),
36324100 geoshape: m["geoshape"] && MarkConfig.from_map(m["geoshape"]),
36334101 invalid_values: m["invalidValues"] && InvalidValues.decode(m["invalidValues"]),
36344102 legend: m["legend"] && LegendConfig.from_map(m["legend"]),
36354103 line: m["line"] && MarkConfig.from_map(m["line"]),
36364104 mark: m["mark"] && MarkConfig.from_map(m["mark"]),
3637- number_format: m["numberFormat"],
4105+ number_format: m["numberFormat"] && decode_number_format(m["numberFormat"]),
36384106 padding: decode_padding(m["padding"]),
36394107 point: m["point"] && MarkConfig.from_map(m["point"]),
36404108 projection: m["projection"] && ProjectionConfig.from_map(m["projection"]),
@@ -3650,7 +4118,7 @@ defmodule ConfigClass do
36504118 |> Map.new(fn {key, value} -> {key, VGMarkConfig.from_map(value)} end),
36514119 text: m["text"] && TextConfig.from_map(m["text"]),
36524120 tick: m["tick"] && TickConfig.from_map(m["tick"]),
3653- time_format: m["timeFormat"],
4121+ time_format: m["timeFormat"] && decode_time_format(m["timeFormat"]),
36544122 title: m["title"] && VGTitleConfig.from_map(m["title"]),
36554123 view: m["view"] && ViewConfig.from_map(m["view"]),
36564124 }
@@ -3845,13 +4313,31 @@ defmodule DataFormat do
38454313 def encode_parse(value) when is_nil(value), do: value
38464314 def encode_parse(_), do: {:error, "Unexpected type when encoding DataFormat.parse"}
38474315
4316+ def decode_property(value) when is_binary(value), do: value
4317+ def decode_property(_), do: {:error, "Unexpected type when decoding DataFormat.property"}
4318+
4319+ def encode_property(value) when is_binary(value), do: value
4320+ def encode_property(_), do: {:error, "Unexpected type when encoding DataFormat.property"}
4321+
4322+ def decode_feature(value) when is_binary(value), do: value
4323+ def decode_feature(_), do: {:error, "Unexpected type when decoding DataFormat.feature"}
4324+
4325+ def encode_feature(value) when is_binary(value), do: value
4326+ def encode_feature(_), do: {:error, "Unexpected type when encoding DataFormat.feature"}
4327+
4328+ def decode_mesh(value) when is_binary(value), do: value
4329+ def decode_mesh(_), do: {:error, "Unexpected type when decoding DataFormat.mesh"}
4330+
4331+ def encode_mesh(value) when is_binary(value), do: value
4332+ def encode_mesh(_), do: {:error, "Unexpected type when encoding DataFormat.mesh"}
4333+
38484334 def from_map(m) do
38494335 %DataFormat{
38504336 parse: decode_parse(m["parse"]),
38514337 type: m["type"] && DataFormatType.decode(m["type"]),
3852- property: m["property"],
3853- feature: m["feature"],
3854- mesh: m["mesh"],
4338+ property: m["property"] && decode_property(m["property"]),
4339+ feature: m["feature"] && decode_feature(m["feature"]),
4340+ mesh: m["mesh"] && decode_mesh(m["mesh"]),
38554341 }
38564342 end
38574343
@@ -3898,6 +4384,12 @@ defmodule Data do
38984384 name: String.t() | nil
38994385 }
39004386
4387+ def decode_url(value) when is_binary(value), do: value
4388+ def decode_url(_), do: {:error, "Unexpected type when decoding Data.url"}
4389+
4390+ def encode_url(value) when is_binary(value), do: value
4391+ def encode_url(_), do: {:error, "Unexpected type when encoding Data.url"}
4392+
39014393 def decode_values(value) when is_binary(value), do: value
39024394 def decode_values(value) when is_list(value), do: value
39034395 def decode_values(value) when is_map(value), do: value
@@ -3910,12 +4402,18 @@ defmodule Data do
39104402 def encode_values(value) when is_nil(value), do: value
39114403 def encode_values(_), do: {:error, "Unexpected type when encoding Data.values"}
39124404
4405+ def decode_name(value) when is_binary(value), do: value
4406+ def decode_name(_), do: {:error, "Unexpected type when decoding Data.name"}
4407+
4408+ def encode_name(value) when is_binary(value), do: value
4409+ def encode_name(_), do: {:error, "Unexpected type when encoding Data.name"}
4410+
39134411 def from_map(m) do
39144412 %Data{
39154413 format: m["format"] && DataFormat.from_map(m["format"]),
3916- url: m["url"],
4414+ url: m["url"] && decode_url(m["url"]),
39174415 values: decode_values(m["values"]),
3918- name: m["name"],
4416+ name: m["name"] && decode_name(m["name"]),
39194417 }
39204418 end
39214419
@@ -4397,6 +4895,12 @@ defmodule Predicate do
43974895 def encode_equal(value) when is_nil(value), do: value
43984896 def encode_equal(_), do: {:error, "Unexpected type when encoding Predicate.equal"}
43994897
4898+ def decode_field(value) when is_binary(value), do: value
4899+ def decode_field(_), do: {:error, "Unexpected type when decoding Predicate.field"}
4900+
4901+ def encode_field(value) when is_binary(value), do: value
4902+ def encode_field(_), do: {:error, "Unexpected type when encoding Predicate.field"}
4903+
44004904 def decode_range_element(%{} = value), do: DateTimeClass.from_map(value)
44014905 def decode_range_element(value) when is_float(value), do: value
44024906 def decode_range_element(value) when is_integer(value), do: value
@@ -4439,7 +4943,7 @@ defmodule Predicate do
44394943 predicate_and: m["and"] && Enum.map(m["and"], &decode_predicate_and_element/1),
44404944 predicate_or: m["or"] && Enum.map(m["or"], &decode_predicate_or_element/1),
44414945 equal: decode_equal(m["equal"]),
4442- field: m["field"],
4946+ field: m["field"] && decode_field(m["field"]),
44434947 time_unit: m["timeUnit"] && TimeUnit.decode(m["timeUnit"]),
44444948 range: m["range"] && Enum.map(m["range"], &decode_range_element/1),
44454949 one_of: m["oneOf"] && Enum.map(m["oneOf"], &decode_one_of_element/1),
@@ -4704,6 +5208,12 @@ defmodule Legend do
47045208 zindex: float() | nil
47055209 }
47065210
5211+ def decode_format(value) when is_binary(value), do: value
5212+ def decode_format(_), do: {:error, "Unexpected type when decoding Legend.format"}
5213+
5214+ def encode_format(value) when is_binary(value), do: value
5215+ def encode_format(_), do: {:error, "Unexpected type when encoding Legend.format"}
5216+
47075217 def decode_values_element(%{} = value), do: DateTimeClass.from_map(value)
47085218 def decode_values_element(value) when is_float(value), do: value
47095219 def decode_values_element(value) when is_integer(value), do: value
@@ -4719,7 +5229,7 @@ defmodule Legend do
47195229 def from_map(m) do
47205230 %Legend{
47215231 entry_padding: m["entryPadding"],
4722- format: m["format"],
5232+ format: m["format"] && decode_format(m["format"]),
47235233 offset: m["offset"],
47245234 orient: m["orient"] && LegendOrient.decode(m["orient"]),
47255235 padding: m["padding"],
@@ -4775,17 +5285,29 @@ defmodule DomainClass do
47755285 encoding: String.t() | nil
47765286 }
47775287
5288+ def decode_field(value) when is_binary(value), do: value
5289+ def decode_field(_), do: {:error, "Unexpected type when decoding DomainClass.field"}
5290+
5291+ def encode_field(value) when is_binary(value), do: value
5292+ def encode_field(_), do: {:error, "Unexpected type when encoding DomainClass.field"}
5293+
47785294 def decode_selection(value) when is_binary(value), do: value
47795295 def decode_selection(_), do: {:error, "Unexpected type when decoding DomainClass.selection"}
47805296
47815297 def encode_selection(value) when is_binary(value), do: value
47825298 def encode_selection(_), do: {:error, "Unexpected type when encoding DomainClass.selection"}
47835299
5300+ def decode_encoding(value) when is_binary(value), do: value
5301+ def decode_encoding(_), do: {:error, "Unexpected type when decoding DomainClass.encoding"}
5302+
5303+ def encode_encoding(value) when is_binary(value), do: value
5304+ def encode_encoding(_), do: {:error, "Unexpected type when encoding DomainClass.encoding"}
5305+
47845306 def from_map(m) do
47855307 %DomainClass{
4786- field: m["field"],
5308+ field: m["field"] && decode_field(m["field"]),
47875309 selection: decode_selection(m["selection"]),
4788- encoding: m["encoding"],
5310+ encoding: m["encoding"] && decode_encoding(m["encoding"]),
47895311 }
47905312 end
47915313
@@ -5772,9 +6294,15 @@ defmodule Header do
57726294 title: nil | String.t() | nil
57736295 }
57746296
6297+ def decode_format(value) when is_binary(value), do: value
6298+ def decode_format(_), do: {:error, "Unexpected type when decoding Header.format"}
6299+
6300+ def encode_format(value) when is_binary(value), do: value
6301+ def encode_format(_), do: {:error, "Unexpected type when encoding Header.format"}
6302+
57756303 def from_map(m) do
57766304 %Header{
5777- format: m["format"],
6305+ format: m["format"] && decode_format(m["format"]),
57786306 label_angle: m["labelAngle"],
57796307 title: m["title"],
57806308 }
@@ -6309,6 +6837,12 @@ defmodule ConditionalPredicateTextFieldDefClass do
63096837 def encode_field(value) when is_nil(value), do: value
63106838 def encode_field(_), do: {:error, "Unexpected type when encoding ConditionalPredicateTextFieldDefClass.field"}
63116839
6840+ def decode_format(value) when is_binary(value), do: value
6841+ def decode_format(_), do: {:error, "Unexpected type when decoding ConditionalPredicateTextFieldDefClass.format"}
6842+
6843+ def encode_format(value) when is_binary(value), do: value
6844+ def encode_format(_), do: {:error, "Unexpected type when encoding ConditionalPredicateTextFieldDefClass.format"}
6845+
63126846 def from_map(m) do
63136847 %ConditionalPredicateTextFieldDefClass{
63146848 test: decode_test(m["test"]),
@@ -6317,7 +6851,7 @@ defmodule ConditionalPredicateTextFieldDefClass do
63176851 aggregate: m["aggregate"] && AggregateOp.decode(m["aggregate"]),
63186852 bin: decode_bin(m["bin"]),
63196853 field: decode_field(m["field"]),
6320- format: m["format"],
6854+ format: m["format"] && decode_format(m["format"]),
63216855 time_unit: m["timeUnit"] && TimeUnit.decode(m["timeUnit"]),
63226856 type: m["type"] && Type.decode(m["type"]),
63236857 }
@@ -6421,13 +6955,19 @@ defmodule TextDefWithCondition do
64216955 def encode_field(value) when is_nil(value), do: value
64226956 def encode_field(_), do: {:error, "Unexpected type when encoding TextDefWithCondition.field"}
64236957
6958+ def decode_format(value) when is_binary(value), do: value
6959+ def decode_format(_), do: {:error, "Unexpected type when decoding TextDefWithCondition.format"}
6960+
6961+ def encode_format(value) when is_binary(value), do: value
6962+ def encode_format(_), do: {:error, "Unexpected type when encoding TextDefWithCondition.format"}
6963+
64246964 def from_map(m) do
64256965 %TextDefWithCondition{
64266966 aggregate: m["aggregate"] && AggregateOp.decode(m["aggregate"]),
64276967 bin: decode_bin(m["bin"]),
64286968 condition: decode_condition(m["condition"]),
64296969 field: decode_field(m["field"]),
6430- format: m["format"],
6970+ format: m["format"] && decode_format(m["format"]),
64316971 time_unit: m["timeUnit"] && TimeUnit.decode(m["timeUnit"]),
64326972 type: m["type"] && Type.decode(m["type"]),
64336973 value: m["value"],
@@ -6513,6 +7053,12 @@ defmodule Axis do
65137053 zindex: float() | nil
65147054 }
65157055
7056+ def decode_format(value) when is_binary(value), do: value
7057+ def decode_format(_), do: {:error, "Unexpected type when decoding Axis.format"}
7058+
7059+ def encode_format(value) when is_binary(value), do: value
7060+ def encode_format(_), do: {:error, "Unexpected type when encoding Axis.format"}
7061+
65167062 def decode_label_overlap(value) when is_boolean(value), do: value
65177063 def decode_label_overlap(value) when is_binary(value), do: LabelOverlapEnum.decode(value)
65187064 def decode_label_overlap(value) when is_nil(value), do: value
@@ -6536,7 +7082,7 @@ defmodule Axis do
65367082 def from_map(m) do
65377083 %Axis{
65387084 domain: m["domain"],
6539- format: m["format"],
7085+ format: m["format"] && decode_format(m["format"]),
65407086 grid: m["grid"],
65417087 label_angle: m["labelAngle"],
65427088 label_bound: m["labelBound"],
@@ -7188,6 +7734,24 @@ defmodule MarkDef do
71887734 type: Mark.t()
71897735 }
71907736
7737+ def decode_color(value) when is_binary(value), do: value
7738+ def decode_color(_), do: {:error, "Unexpected type when decoding MarkDef.color"}
7739+
7740+ def encode_color(value) when is_binary(value), do: value
7741+ def encode_color(_), do: {:error, "Unexpected type when encoding MarkDef.color"}
7742+
7743+ def decode_fill(value) when is_binary(value), do: value
7744+ def decode_fill(_), do: {:error, "Unexpected type when decoding MarkDef.fill"}
7745+
7746+ def encode_fill(value) when is_binary(value), do: value
7747+ def encode_fill(_), do: {:error, "Unexpected type when encoding MarkDef.fill"}
7748+
7749+ def decode_font(value) when is_binary(value), do: value
7750+ def decode_font(_), do: {:error, "Unexpected type when decoding MarkDef.font"}
7751+
7752+ def encode_font(value) when is_binary(value), do: value
7753+ def encode_font(_), do: {:error, "Unexpected type when encoding MarkDef.font"}
7754+
71917755 def decode_font_weight(value) when is_binary(value), do: FontWeight.decode(value)
71927756 def decode_font_weight(value) when is_float(value), do: value
71937757 def decode_font_weight(value) when is_integer(value), do: value
@@ -7200,6 +7764,24 @@ defmodule MarkDef do
72007764 def encode_font_weight(value) when is_nil(value), do: value
72017765 def encode_font_weight(_), do: {:error, "Unexpected type when encoding MarkDef.font_weight"}
72027766
7767+ def decode_href(value) when is_binary(value), do: value
7768+ def decode_href(_), do: {:error, "Unexpected type when decoding MarkDef.href"}
7769+
7770+ def encode_href(value) when is_binary(value), do: value
7771+ def encode_href(_), do: {:error, "Unexpected type when encoding MarkDef.href"}
7772+
7773+ def decode_shape(value) when is_binary(value), do: value
7774+ def decode_shape(_), do: {:error, "Unexpected type when decoding MarkDef.shape"}
7775+
7776+ def encode_shape(value) when is_binary(value), do: value
7777+ def encode_shape(_), do: {:error, "Unexpected type when encoding MarkDef.shape"}
7778+
7779+ def decode_stroke(value) when is_binary(value), do: value
7780+ def decode_stroke(_), do: {:error, "Unexpected type when decoding MarkDef.stroke"}
7781+
7782+ def encode_stroke(value) when is_binary(value), do: value
7783+ def encode_stroke(_), do: {:error, "Unexpected type when encoding MarkDef.stroke"}
7784+
72037785 def decode_style(value) when is_binary(value), do: value
72047786 def decode_style(value) when is_list(value), do: value
72057787 def decode_style(value) when is_nil(value), do: value
@@ -7210,39 +7792,45 @@ defmodule MarkDef do
72107792 def encode_style(value) when is_nil(value), do: value
72117793 def encode_style(_), do: {:error, "Unexpected type when encoding MarkDef.style"}
72127794
7795+ def decode_text(value) when is_binary(value), do: value
7796+ def decode_text(_), do: {:error, "Unexpected type when decoding MarkDef.text"}
7797+
7798+ def encode_text(value) when is_binary(value), do: value
7799+ def encode_text(_), do: {:error, "Unexpected type when encoding MarkDef.text"}
7800+
72137801 def from_map(m) do
72147802 %MarkDef{
72157803 align: m["align"] && HorizontalAlign.decode(m["align"]),
72167804 angle: m["angle"],
72177805 baseline: m["baseline"] && VerticalAlign.decode(m["baseline"]),
72187806 clip: m["clip"],
7219- color: m["color"],
7807+ color: m["color"] && decode_color(m["color"]),
72207808 cursor: m["cursor"] && Cursor.decode(m["cursor"]),
72217809 dx: m["dx"],
72227810 dy: m["dy"],
7223- fill: m["fill"],
7811+ fill: m["fill"] && decode_fill(m["fill"]),
72247812 filled: m["filled"],
72257813 fill_opacity: m["fillOpacity"],
7226- font: m["font"],
7814+ font: m["font"] && decode_font(m["font"]),
72277815 font_size: m["fontSize"],
72287816 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
72297817 font_weight: decode_font_weight(m["fontWeight"]),
7230- href: m["href"],
7818+ href: m["href"] && decode_href(m["href"]),
72317819 interpolate: m["interpolate"] && Interpolate.decode(m["interpolate"]),
72327820 limit: m["limit"],
72337821 opacity: m["opacity"],
72347822 orient: m["orient"] && Orient.decode(m["orient"]),
72357823 radius: m["radius"],
7236- shape: m["shape"],
7824+ shape: m["shape"] && decode_shape(m["shape"]),
72377825 size: m["size"],
7238- stroke: m["stroke"],
7826+ stroke: m["stroke"] && decode_stroke(m["stroke"]),
72397827 stroke_dash: m["strokeDash"],
72407828 stroke_dash_offset: m["strokeDashOffset"],
72417829 stroke_opacity: m["strokeOpacity"],
72427830 stroke_width: m["strokeWidth"],
72437831 style: decode_style(m["style"]),
72447832 tension: m["tension"],
7245- text: m["text"],
7833+ text: m["text"] && decode_text(m["text"]),
72467834 theta: m["theta"],
72477835 type: Mark.decode(m["type"]),
72487836 }
@@ -7986,6 +8574,24 @@ defmodule Transform do
79868574 def encode_as(value) when is_nil(value), do: value
79878575 def encode_as(_), do: {:error, "Unexpected type when encoding Transform.as"}
79888576
8577+ def decode_calculate(value) when is_binary(value), do: value
8578+ def decode_calculate(_), do: {:error, "Unexpected type when decoding Transform.calculate"}
8579+
8580+ def encode_calculate(value) when is_binary(value), do: value
8581+ def encode_calculate(_), do: {:error, "Unexpected type when encoding Transform.calculate"}
8582+
8583+ def decode_default(value) when is_binary(value), do: value
8584+ def decode_default(_), do: {:error, "Unexpected type when decoding Transform.default"}
8585+
8586+ def encode_default(value) when is_binary(value), do: value
8587+ def encode_default(_), do: {:error, "Unexpected type when encoding Transform.default"}
8588+
8589+ def decode_lookup(value) when is_binary(value), do: value
8590+ def decode_lookup(_), do: {:error, "Unexpected type when decoding Transform.lookup"}
8591+
8592+ def encode_lookup(value) when is_binary(value), do: value
8593+ def encode_lookup(_), do: {:error, "Unexpected type when encoding Transform.lookup"}
8594+
79898595 def decode_bin(%{} = value), do: BinParams.from_map(value)
79908596 def decode_bin(value) when is_boolean(value), do: value
79918597 def decode_bin(value) when is_nil(value), do: value
@@ -7996,16 +8602,22 @@ defmodule Transform do
79968602 def encode_bin(value) when is_nil(value), do: value
79978603 def encode_bin(_), do: {:error, "Unexpected type when encoding Transform.bin"}
79988604
8605+ def decode_field(value) when is_binary(value), do: value
8606+ def decode_field(_), do: {:error, "Unexpected type when decoding Transform.field"}
8607+
8608+ def encode_field(value) when is_binary(value), do: value
8609+ def encode_field(_), do: {:error, "Unexpected type when encoding Transform.field"}
8610+
79998611 def from_map(m) do
80008612 %Transform{
80018613 filter: decode_filter(m["filter"]),
80028614 as: decode_as(m["as"]),
8003- calculate: m["calculate"],
8004- default: m["default"],
8615+ calculate: m["calculate"] && decode_calculate(m["calculate"]),
8616+ default: m["default"] && decode_default(m["default"]),
80058617 from: m["from"] && LookupData.from_map(m["from"]),
8006- lookup: m["lookup"],
8618+ lookup: m["lookup"] && decode_lookup(m["lookup"]),
80078619 bin: decode_bin(m["bin"]),
8008- field: m["field"],
8620+ field: m["field"] && decode_field(m["field"]),
80098621 time_unit: m["timeUnit"] && TimeUnit.decode(m["timeUnit"]),
80108622 aggregate: m["aggregate"] && Enum.map(m["aggregate"], &AggregatedFieldDef.from_map/1),
80118623 groupby: m["groupby"],
@@ -8077,6 +8689,18 @@ defmodule LayerSpec do
80778689 selection: %{String.t() => SelectionDef.t()} | nil
80788690 }
80798691
8692+ def decode_description(value) when is_binary(value), do: value
8693+ def decode_description(_), do: {:error, "Unexpected type when decoding LayerSpec.description"}
8694+
8695+ def encode_description(value) when is_binary(value), do: value
8696+ def encode_description(_), do: {:error, "Unexpected type when encoding LayerSpec.description"}
8697+
8698+ def decode_name(value) when is_binary(value), do: value
8699+ def decode_name(_), do: {:error, "Unexpected type when decoding LayerSpec.name"}
8700+
8701+ def encode_name(value) when is_binary(value), do: value
8702+ def encode_name(_), do: {:error, "Unexpected type when encoding LayerSpec.name"}
8703+
80808704 def decode_title(%{"text" => _,} = value), do: TitleParams.from_map(value)
80818705 def decode_title(value) when is_binary(value), do: value
80828706 def decode_title(value) when is_nil(value), do: value
@@ -8100,10 +8724,10 @@ defmodule LayerSpec do
81008724 def from_map(m) do
81018725 %LayerSpec{
81028726 data: m["data"] && Data.from_map(m["data"]),
8103- description: m["description"],
8727+ description: m["description"] && decode_description(m["description"]),
81048728 height: m["height"],
81058729 layer: m["layer"] && Enum.map(m["layer"], &LayerSpec.from_map/1),
8106- name: m["name"],
8730+ name: m["name"] && decode_name(m["name"]),
81078731 resolve: m["resolve"] && Resolve.from_map(m["resolve"]),
81088732 title: decode_title(m["title"]),
81098733 transform: m["transform"] && Enum.map(m["transform"], &Transform.from_map/1),
@@ -8236,6 +8860,18 @@ defmodule Spec do
82368860 hconcat: [Spec.t()] | nil
82378861 }
82388862
8863+ def decode_description(value) when is_binary(value), do: value
8864+ def decode_description(_), do: {:error, "Unexpected type when decoding Spec.description"}
8865+
8866+ def encode_description(value) when is_binary(value), do: value
8867+ def encode_description(_), do: {:error, "Unexpected type when encoding Spec.description"}
8868+
8869+ def decode_name(value) when is_binary(value), do: value
8870+ def decode_name(_), do: {:error, "Unexpected type when decoding Spec.name"}
8871+
8872+ def encode_name(value) when is_binary(value), do: value
8873+ def encode_name(_), do: {:error, "Unexpected type when encoding Spec.name"}
8874+
82398875 def decode_title(%{"text" => _,} = value), do: TitleParams.from_map(value)
82408876 def decode_title(value) when is_binary(value), do: value
82418877 def decode_title(value) when is_nil(value), do: value
@@ -8259,10 +8895,10 @@ defmodule Spec do
82598895 def from_map(m) do
82608896 %Spec{
82618897 data: m["data"] && Data.from_map(m["data"]),
8262- description: m["description"],
8898+ description: m["description"] && decode_description(m["description"]),
82638899 height: m["height"],
82648900 layer: m["layer"] && Enum.map(m["layer"], &LayerSpec.from_map/1),
8265- name: m["name"],
8901+ name: m["name"] && decode_name(m["name"]),
82668902 resolve: m["resolve"] && Resolve.from_map(m["resolve"]),
82678903 title: decode_title(m["title"]),
82688904 transform: m["transform"] && Enum.map(m["transform"], &Transform.from_map/1),
@@ -8372,6 +9008,12 @@ defmodule TopLevel do
83729008 hconcat: [Spec.t()] | nil
83739009 }
83749010
9011+ def decode_schema(value) when is_binary(value), do: value
9012+ def decode_schema(_), do: {:error, "Unexpected type when decoding TopLevel.schema"}
9013+
9014+ def encode_schema(value) when is_binary(value), do: value
9015+ def encode_schema(_), do: {:error, "Unexpected type when encoding TopLevel.schema"}
9016+
83759017 def decode_autosize(%{} = value), do: AutoSizeParams.from_map(value)
83769018 def decode_autosize(value) when is_binary(value), do: AutosizeType.decode(value)
83779019 def decode_autosize(value) when is_nil(value), do: value
@@ -8382,6 +9024,18 @@ defmodule TopLevel do
83829024 def encode_autosize(value) when is_nil(value), do: value
83839025 def encode_autosize(_), do: {:error, "Unexpected type when encoding TopLevel.autosize"}
83849026
9027+ def decode_background(value) when is_binary(value), do: value
9028+ def decode_background(_), do: {:error, "Unexpected type when decoding TopLevel.background"}
9029+
9030+ def encode_background(value) when is_binary(value), do: value
9031+ def encode_background(_), do: {:error, "Unexpected type when encoding TopLevel.background"}
9032+
9033+ def decode_description(value) when is_binary(value), do: value
9034+ def decode_description(_), do: {:error, "Unexpected type when decoding TopLevel.description"}
9035+
9036+ def encode_description(value) when is_binary(value), do: value
9037+ def encode_description(_), do: {:error, "Unexpected type when encoding TopLevel.description"}
9038+
83859039 def decode_mark(%{"type" => _,} = value), do: MarkDef.from_map(value)
83869040 def decode_mark(value) when is_binary(value), do: Mark.decode(value)
83879041 def decode_mark(value) when is_nil(value), do: value
@@ -8392,6 +9046,12 @@ defmodule TopLevel do
83929046 def encode_mark(value) when is_nil(value), do: value
83939047 def encode_mark(_), do: {:error, "Unexpected type when encoding TopLevel.mark"}
83949048
9049+ def decode_name(value) when is_binary(value), do: value
9050+ def decode_name(_), do: {:error, "Unexpected type when decoding TopLevel.name"}
9051+
9052+ def encode_name(value) when is_binary(value), do: value
9053+ def encode_name(_), do: {:error, "Unexpected type when encoding TopLevel.name"}
9054+
83959055 def decode_padding(%{} = value), do: PaddingClass.from_map(value)
83969056 def decode_padding(value) when is_float(value), do: value
83979057 def decode_padding(value) when is_integer(value), do: value
@@ -8416,16 +9076,16 @@ defmodule TopLevel do
84169076
84179077 def from_map(m) do
84189078 %TopLevel{
8419- schema: m["$schema"],
9079+ schema: m["$schema"] && decode_schema(m["$schema"]),
84209080 autosize: decode_autosize(m["autosize"]),
8421- background: m["background"],
9081+ background: m["background"] && decode_background(m["background"]),
84229082 config: m["config"] && ConfigClass.from_map(m["config"]),
84239083 data: m["data"] && Data.from_map(m["data"]),
8424- description: m["description"],
9084+ description: m["description"] && decode_description(m["description"]),
84259085 encoding: m["encoding"] && EncodingWithFacet.from_map(m["encoding"]),
84269086 height: m["height"],
84279087 mark: decode_mark(m["mark"]),
8428- name: m["name"],
9088+ name: m["name"] && decode_name(m["name"]),
84299089 padding: decode_padding(m["padding"]),
84309090 projection: m["projection"] && Projection.from_map(m["projection"]),
84319091 selection: m["selection"]
No generated files match these filters.