Skip to content

Commit e096d1a

Browse files
authored
Revert "Develop (#128)" (#129)
This reverts commit 9746310.
1 parent 9746310 commit e096d1a

File tree

8 files changed

+4
-230
lines changed

8 files changed

+4
-230
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ This is an implementation of the [JSON Schema Core Draft v4](http://json-schema.
66
[Subreddit](https://www.reddit.com/r/lightapi/) |
77
[Youtube Channel](https://www.youtube.com/channel/UCHCRMWJVXw8iB7zKxF55Byw) |
88
[Documentation](https://doc.networknt.com/library/json-overlay/) |
9-
[Javadocs](https://www.javadoc.io/doc/com.networknt/json-schema-validator) |
109
[Contribution Guide](https://doc.networknt.com/contribute/) |
1110

1211
[![Build Status](https://travis-ci.org/networknt/json-schema-validator.svg?branch=master)](https://travis-ci.org/networknt/json-schema-validator)

src/main/java/com/networknt/schema/JsonSchemaFactory.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public static class Builder {
4141
private URLFetcher urlFetcher;
4242
private String defaultMetaSchemaURI;
4343
private Map<String, JsonMetaSchema> jsonMetaSchemas = new HashMap<String, JsonMetaSchema>();
44-
private Map<URL, URL> urlMap = new HashMap<URL, URL>();
4544

4645
public Builder objectMapper(ObjectMapper objectMapper) {
4746
this.objectMapper = objectMapper;
@@ -70,19 +69,13 @@ public Builder addMetaSchemas(Collection<? extends JsonMetaSchema> jsonMetaSchem
7069
return this;
7170
}
7271

73-
public Builder addUrlMappings(Map<URL, URL> map) {
74-
this.urlMap.putAll(map);
75-
return this;
76-
}
77-
7872
public JsonSchemaFactory build() {
7973
// create builtin keywords with (custom) formats.
8074
return new JsonSchemaFactory(
8175
objectMapper == null ? new ObjectMapper() : objectMapper,
8276
urlFetcher == null ? new StandardURLFetcher(): urlFetcher,
8377
defaultMetaSchemaURI,
84-
jsonMetaSchemas,
85-
urlMap
78+
jsonMetaSchemas
8679
);
8780
}
8881
}
@@ -91,9 +84,8 @@ public JsonSchemaFactory build() {
9184
private final URLFetcher urlFetcher;
9285
private final String defaultMetaSchemaURI;
9386
private final Map<String, JsonMetaSchema> jsonMetaSchemas;
94-
private final Map<URL, URL> urlMap;
9587

96-
private JsonSchemaFactory(ObjectMapper mapper, URLFetcher urlFetcher, String defaultMetaSchemaURI, Map<String, JsonMetaSchema> jsonMetaSchemas, Map<URL, URL> urlMap) {
88+
private JsonSchemaFactory(ObjectMapper mapper, URLFetcher urlFetcher, String defaultMetaSchemaURI, Map<String, JsonMetaSchema> jsonMetaSchemas) {
9789
if (mapper == null) {
9890
throw new IllegalArgumentException("ObjectMapper must not be null");
9991
}
@@ -109,14 +101,10 @@ private JsonSchemaFactory(ObjectMapper mapper, URLFetcher urlFetcher, String def
109101
if (jsonMetaSchemas.get(defaultMetaSchemaURI) == null) {
110102
throw new IllegalArgumentException("Meta Schema for default Meta Schema URI must be provided");
111103
}
112-
if (urlMap == null) {
113-
throw new IllegalArgumentException("URL Mappings must not be null");
114-
}
115104
this.mapper = mapper;
116105
this.defaultMetaSchemaURI = defaultMetaSchemaURI;
117106
this.urlFetcher = urlFetcher;
118107
this.jsonMetaSchemas = jsonMetaSchemas;
119-
this.urlMap = urlMap;
120108
}
121109

122110
/**
@@ -147,8 +135,7 @@ public static Builder builder(JsonSchemaFactory blueprint) {
147135
.addMetaSchemas(blueprint.jsonMetaSchemas.values())
148136
.urlFetcher(blueprint.urlFetcher)
149137
.defaultMetaSchemaURI(blueprint.defaultMetaSchemaURI)
150-
.objectMapper(blueprint.mapper)
151-
.addUrlMappings(blueprint.urlMap);
138+
.objectMapper(blueprint.mapper);
152139
}
153140

154141
private JsonSchema newJsonSchema(JsonNode schemaNode, SchemaValidatorsConfig config) {
@@ -204,11 +191,8 @@ public JsonSchema getSchema(InputStream schemaStream) {
204191
public JsonSchema getSchema(URL schemaURL, SchemaValidatorsConfig config) {
205192
try {
206193
InputStream inputStream = null;
207-
Map<URL, URL> map = (config != null) ? config.getUrlMappings() : new HashMap<URL, URL>(urlMap);
208-
map.putAll(urlMap);
209-
URL mappedURL = map.getOrDefault(schemaURL, schemaURL);
210194
try {
211-
inputStream = urlFetcher.fetch(mappedURL);
195+
inputStream = urlFetcher.fetch(schemaURL);
212196
JsonNode schemaNode = mapper.readTree(inputStream);
213197
final JsonMetaSchema jsonMetaSchema = findMetaSchemaForSchema(schemaNode);
214198

src/main/java/com/networknt/schema/SchemaValidatorsConfig.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package com.networknt.schema;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
5-
import java.net.URL;
6-
73
public class SchemaValidatorsConfig {
84
/**
95
* when validate type, if TYPE_LOOSE = true, will try to convert string to different types to match the type defined in schema.
@@ -22,13 +18,6 @@ public class SchemaValidatorsConfig {
2218
*/
2319
private boolean elementValidationError = false;
2420

25-
/**
26-
* Map of public, normally internet accessible schema URLs to alternate locations; this allows for offline
27-
* validation of schemas that refer to public URLs. This is merged with any mappings the {@link JsonSchemaFactory}
28-
* may have been built with.
29-
*/
30-
private Map<URL, URL> urlMappings = new HashMap<URL, URL>();
31-
3221
public boolean isTypeLoose() {
3322
return typeLoose;
3423
}
@@ -37,14 +26,6 @@ public void setTypeLoose(boolean typeLoose) {
3726
this.typeLoose = typeLoose;
3827
}
3928

40-
public Map<URL, URL> getUrlMappings() {
41-
return new HashMap<URL, URL>(urlMappings);
42-
}
43-
44-
public void setUrlMappings(Map<URL, URL> urlMappings) {
45-
this.urlMappings = urlMappings;
46-
}
47-
4829
public boolean isMissingNodeAsError() {
4930
return missingNodeAsError;
5031
}
@@ -67,6 +48,5 @@ public SchemaValidatorsConfig() {
6748

6849
private void loadDefaultConfig() {
6950
this.typeLoose = true;
70-
this.urlMappings = new HashMap<URL, URL>();
7151
}
7252
}

src/test/java/com/networknt/schema/UrlMappingTest.java

Lines changed: 0 additions & 141 deletions
This file was deleted.

src/test/resources/tests/url_mapping/example-schema.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/test/resources/tests/url_mapping/invalid-schema-url.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/test/resources/tests/url_mapping/url-mapping.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/test/resources/tests/url_mapping/url-mapping.schema.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)