@@ -14,8 +14,8 @@ function type_to_dict(x)
1414 return Dict(name => getfield(x, name) for name in fieldnames(typeof(x)))
1515end
1616
17- function update_id(uri:: HTTP .URI , s:: String )
18- id2 = HTTP . URI(s)
17+ function update_id(uri:: URIs .URI , s:: String )
18+ id2 = URIs . URI(s)
1919 if ! isempty(id2. scheme)
2020 return id2
2121 end
@@ -27,7 +27,7 @@ function update_id(uri::HTTP.URI, s::String)
2727 els[:path] =
2828 oldpath == nothing ? id2. path : oldpath. captures[1 ] * id2. path
2929 end
30- return HTTP . URI(; els... )
30+ return URIs . URI(; els... )
3131end
3232
3333function get_element(schema, path:: AbstractString )
@@ -60,7 +60,7 @@ function _recurse_get_element(schema::Vector, element::String)
6060 return schema[index+ 1 ]
6161end
6262
63- function get_remote_schema(uri:: HTTP .URI )
63+ function get_remote_schema(uri:: URIs .URI )
6464 r = HTTP. get(uri)
6565 if r. status != 200
6666 error(" Unable to get remote schema at $uri . HTTP status = $(r. status) " )
@@ -69,7 +69,7 @@ function get_remote_schema(uri::HTTP.URI)
6969end
7070
7171function find_ref(
72- uri:: HTTP .URI ,
72+ uri:: URIs .URI ,
7373 id_map:: AbstractDict ,
7474 path:: String ,
7575 parent_dir:: String ,
@@ -82,14 +82,11 @@ function find_ref(
8282 uri = update_id(uri, path)
8383 els = type_to_dict(uri)
8484 delete!.(Ref(els), [:uri, :fragment])
85- uri2 = HTTP . URI(; els... )
85+ uri2 = URIs . URI(; els... )
8686 is_file_uri = startswith(uri2. scheme, " file" ) || isempty(uri2. scheme)
8787 if is_file_uri && ! isabspath(uri2. path)
8888 # Normalize a file path to an absolute path so creating a key is consistent.
89- uri2 = HTTP. URIs. merge(
90- uri2;
91- path = abspath(joinpath(parent_dir, uri2. path)),
92- )
89+ uri2 = URIs. URI(uri2; path = abspath(joinpath(parent_dir, uri2. path)))
9390 end
9491 if ! haskey(id_map, string(uri2))
9592 # id_map doesn't have this key so, fetch the ref and add it to id_map.
@@ -110,11 +107,11 @@ end
110107
111108# Recursively find all "$ref" fields and resolve their path.
112109
113- resolve_refs!(:: Any , :: HTTP .URI , :: AbstractDict , :: String ) = nothing
110+ resolve_refs!(:: Any , :: URIs .URI , :: AbstractDict , :: String ) = nothing
114111
115112function resolve_refs!(
116113 schema:: Vector ,
117- uri:: HTTP .URI ,
114+ uri:: URIs .URI ,
118115 id_map:: AbstractDict ,
119116 parent_dir:: String ,
120117)
126123
127124function resolve_refs!(
128125 schema:: AbstractDict ,
129- uri:: HTTP .URI ,
126+ uri:: URIs .URI ,
130127 id_map:: AbstractDict ,
131128 parent_dir:: String ,
132129)
@@ -154,21 +151,21 @@ end
154151
155152function build_id_map(schema:: AbstractDict )
156153 id_map = Dict{String,Any}(" " => schema)
157- build_id_map!(id_map, schema, HTTP . URI())
154+ build_id_map!(id_map, schema, URIs . URI())
158155 return id_map
159156end
160157
161- build_id_map!(:: AbstractDict , :: Any , :: HTTP .URI ) = nothing
158+ build_id_map!(:: AbstractDict , :: Any , :: URIs .URI ) = nothing
162159
163- function build_id_map!(id_map:: AbstractDict , schema:: Vector , uri:: HTTP .URI )
160+ function build_id_map!(id_map:: AbstractDict , schema:: Vector , uri:: URIs .URI )
164161 build_id_map!.(Ref(id_map), schema, Ref(uri))
165162 return
166163end
167164
168165function build_id_map!(
169166 id_map:: AbstractDict ,
170167 schema:: AbstractDict ,
171- uri:: HTTP .URI ,
168+ uri:: URIs .URI ,
172169)
173170 if haskey(schema, " id" ) && schema[" id" ] isa String
174171 # This block is for draft 4.
@@ -218,7 +215,7 @@ struct Schema
218215 end
219216 schema = deepcopy(schema) # Ensure we don't modify the user's data!
220217 id_map = build_id_map(schema)
221- resolve_refs!(schema, HTTP . URI(), id_map, parent_dir)
218+ resolve_refs!(schema, URIs . URI(), id_map, parent_dir)
222219 return new(schema)
223220 end
224221end
0 commit comments