Skip to content

Commit ac46cee

Browse files
authored
Merge pull request #223 from networknt/issue222
fixes #222 add document for URL mapping
2 parents 81ca7f1 + 709a9bb commit ac46cee

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/schema-map.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
While working with JSON schema validation, we have to use external references sometimes. However, there are two issues to have references to schemas on the Internet.
2+
3+
* Some applications are running inside a corporate network without Internet access.
4+
* Some of the Internet resources are not reliable
5+
6+
One solution is to change all the external reference to internal in JSON schemas, but this is error-prone and hard to maintain in a long run.
7+
8+
A smart solution is to map the external references to internal ones in a configuration file. This allows us to use the resources as they are without any modification. In the JSON schema specification, it is not allowed to use local filesystem resource directly. With the mapping, we can use the local resources without worrying about breaking the specification as the references are still in URL format in schemas. In addition, the mapped URL can be a different external URL, or embbeded within a JAR file with a lot more flexibility.
9+
10+
Note that when using a mapping, the local copy is always used, and the external reference is not queried.
11+
12+
### Usage
13+
14+
Basically, you can specify a mapping in the builder. For more details, please take a look at the test cases and the [PR](https://github.com/networknt/json-schema-validator/pull/125).
15+
16+
17+
### Real Example
18+
19+
https://github.com/JMRI/JMRI/blob/master/java/src/jmri/server/json/schema-map.json

0 commit comments

Comments
 (0)