Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
1files differ
0modified
1new
0deleted
34changed lines
+34 −0insertions / deletions
Base 3df8d2010453809da42f3a516d959c56eb8ebe37 · PR merge d014100d75e43797a78b1d18107743ba039f091d · Head 29c41daee7aa74ea8d581ab0de29be9ba4be42d2 · raw patch
Aschema-ruby/test/inputs/schema/top-level-enum.schema/default/TopLevel.rb+34 −0
@@ -0,0 +1,34 @@
1+# This code may look unusually verbose for Ruby (and it is), but
2+# it performs some subtle and complex validation of JSON data.
3+#
4+# To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
5+#
6+# top_level = TopLevel.from_json! "…"
7+# puts top_level == TopLevel::One
8+#
9+# If from_json! succeeds, the value returned matches the schema.
10+
11+require 'json'
12+require 'dry-types'
13+require 'dry-struct'
14+
15+module Types
16+ include Dry.Types(default: :nominal)
17+
18+ String = Strict::String
19+ TopLevel = Strict::String.enum("one", "three", "two")
20+end
21+
22+module TopLevel
23+ One = "one"
24+ Three = "three"
25+ Two = "two"
26+
27+ def self.from_dynamic!(d)
28+ Types::TopLevel[d]
29+ end
30+
31+ def self.from_json!(json)
32+ from_dynamic!(JSON.parse(json))
33+ end
34+end
No generated files match these filters.