{
"id": "https://example.com/locator-api/1.0/default/GPS.json",
"title": "GPS",
"description": "Provides the longitude and latitude information",
"type": "object",
"properties": {
"latitude": {
"type": "integer",
"description": "Provides the latitude information of a location"
},
"longitude": {
"type": "integer",
"description": "Provides the longitude information of a location"
}
},
"required": [
"latitude",
"longitude"
]
}
and Landmark.json
{
"id": "https://example.com/locator-api/1.0/default/Landmark.json",
"title": "Landmark",
"description": "Provides the landmark related information",
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "Represents the identifier for the landmark"
},
"name": {
"type": "string",
"description": "Represents the name of the landmark"
},
"location": {
"$ref": "https://example/locator-api/1.0/default/GPS.json",
"description": "Represents the longitude and latitude information"
}
},
"required": [
"location",
"name"
]
}
The problem is that resolver is trying to reach the url causing exceptions and to avoid that I've created custom schema source like this
// defined additional properties likes this
private final String prefixURL = "https://example.com/locator-api/1.0/";
private final String prefixFileUrl = "file:///var/tmp/location_schema/"; // This is specified in source paths
and overridden the method
public synchronized Schema create(URI id) {
if (!schemas.containsKey(id)) {
JsonNode content;
if (id.toString().startsWith(prefixURL)) {
URI fileId = null;
try {
fileId = new URI(id.toString().replace(prefixURL, prefixFileUrl));
} catch (URISyntaxException e) {
e.printStackTrace();
}
content = contentResolver.resolve(removeFragment(fileId));
}
else {
content = contentResolver.resolve(removeFragment(id));
}
if (id.toString().contains("#")) {
content = fragmentResolver.resolve(content, '#' + substringAfter(id.toString(), "#"));
}
schemas.put(id, new Schema(id, content));
}
return schemas.get(id);
}
I could easily solve the problem but I am not a great fan of the solution. I would like to know if there is any easy way to solve this.
Thanks,