Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
1test cases
1files differ
0modified
1new
0deleted
34changed lines
+34 −0insertions / deletions
Base a49b94e8f6f1b319a4da9fb15d57ef13ba316ddc · PR merge 8657bd3a119ae9b34ec5af19768f48b21d140d31 · Head 6d24faa26f26245c72df2cacfe5109e8ea5fa772 · raw patch
Test case

test/inputs/schema/top-level-enum.schema

1 generated file · +34 −0
Aschema-rubydefault / 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.