-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ref as object #36
Comments
There might be a bug when referencing the root of another schema, I'll look into it. Note: I'm also working on improved error reporting. |
Found and fixed the bug, will push a solution soon. If you want to fix this now for yourself you can replace the line
|
Closing issue as f238a54 fixes it. |
i updated and perhaps i'm doing something wrong. Also did the wild guess that "id" resolves somehow and is how "http://example.com/x.json" gets from a non existent URI to the file with that "id". Is that correct? I've seen other libraries resort to having a module apply tuple for resolving file refs. ../../js2e y2.json
20:15:15.465 [debug] Arguments: ["y2.json"]
20:15:15.474 [debug] Files: ["y2.json"]
20:15:15.496 [debug] Parsing type with name: #, path: , and value: %{"$schema" => "http://json-schema.org/draft-04/schema#", "description" => "Schema for a circle shape", "id" => "http://example.com/y2.json", "properties" => %{"x" => %{"$ref" => "http://example.com/x.json"}}, "required" => ["x"], "title" => "Circle", "type" => "object"}
20:15:15.500 [debug] node_parser: &JS2E.Parsers.ObjectParser.parse/5
20:15:15.501 [debug] Parsing '["#"]' as ObjectType
20:15:15.504 [debug] Parsing type with name: x, path: #, and value: %{"$ref" => "http://example.com/x.json"}
20:15:15.504 [debug] node_parser: &JS2E.Parsers.TypeReferenceParser.parse/5
20:15:15.505 [debug] parsing '["#", "x"]' as TypeReference
20:15:15.509 [debug] Parsed type reference: %JS2E.Types.TypeReference{name: "x", path: %URI{authority: "example.com", fragment: nil, host: "example.com", path: "/x.json", port: 80, query: nil, scheme: "http", userinfo: nil}}
20:15:15.510 [debug] Descendants types dict: %{"#/x" => %JS2E.Types.TypeReference{name: "x", path: %URI{authority: "example.com", fragment: nil, host: "example.com", path: "/x.json", port: 80, query: nil, scheme: "http", userinfo: nil}}}
20:15:15.510 [debug] Property ref dict: %{"x" => ["#", "x"]}
20:15:15.511 [debug] Parsed object type: %JS2E.Types.ObjectType{name: "#", path: ["#"], properties: %{"x" => ["#", "x"]}, required: ["x"]}
** (UndefinedFunctionError) function nil.id/0 is undefined or private
nil.id()
(js2e) lib/printers/preamble_printer.ex:112: JS2E.Printers.PreamblePrinter.resolve_dependency/4
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
(js2e) lib/printers/preamble_printer.ex:57: JS2E.Printers.PreamblePrinter.create_imports/3
(js2e) lib/printers/preamble_printer.ex:35: JS2E.Printers.PreamblePrinter.print_preamble/3
(js2e) lib/printer.ex:51: JS2E.Printer.print_schema/3
(js2e) lib/printer.ex:33: anonymous fn/5 in JS2E.Printer.print_schemas/2
(stdlib) lists.erl:1263: :lists.foldl/3 schoch@xeon:~/dev/json-schema-to-elm/examples/example-input-json-schemas$ cat y2.json {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Circle",
"id": "http://example.com/y2.json",
"description": "Schema for a circle shape",
"type": "object",
"properties": {
"x": {
"$ref": "http://example.com/x.json"
}
},
"required": ["x"]
} schoch@xeon:~/dev/json-schema-to-elm/examples/example-input-json-schemas$ cat x.json {
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
"title": "x",
"id": "http://example.com/x.json",
"description": "Schema for common types",
"properties": {
"color": {
"id": "#color",
"type": "string",
"enum": [ "red", "yellow", "green", "blue" ]
},
"point": {
"id": "#point",
"type": "object",
"properties": {
"x": {
"type": "number"
},
"y": {
"type": "number"
}
},
"required": [ "x", "y" ]
}
}
}``` |
AFAIK this should work but perhaps it only works with the libraries I have been using.
y.json
x.json
The text was updated successfully, but these errors were encountered: