Skip to content

Commit 6701880

Browse files
committed
Rename JsonSchemaIdValidator to SchemaIdValidator
1 parent 0c120da commit 6701880

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc
182182
resolve = id.substring(0, fragment);
183183
}
184184
SchemaLocation result = !"".equals(resolve) ? schemaLocation.resolve(resolve) : schemaLocation;
185-
JsonSchemaIdValidator validator = schemaContext.getSchemaRegistryConfig().getSchemaIdValidator();
185+
SchemaIdValidator validator = schemaContext.getSchemaRegistryConfig().getSchemaIdValidator();
186186
if (validator != null) {
187187
if (!validator.validate(id, rootSchema, schemaLocation, result, schemaContext)) {
188188
SchemaLocation idSchemaLocation = schemaLocation.append(schemaContext.getDialect().getIdKeyword());

src/main/java/com/networknt/schema/JsonSchemaIdValidator.java renamed to src/main/java/com/networknt/schema/SchemaIdValidator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Validator for validating the correctness of $id.
2323
*/
24-
public interface JsonSchemaIdValidator {
24+
public interface SchemaIdValidator {
2525
/**
2626
* Validates if the $id value is valid.
2727
*
@@ -36,10 +36,10 @@ public interface JsonSchemaIdValidator {
3636
boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation,
3737
SchemaLocation resolvedSchemaLocation, SchemaContext schemaContext);
3838

39-
JsonSchemaIdValidator DEFAULT = new DefaultJsonSchemaIdValidator();
39+
SchemaIdValidator DEFAULT = new DefaultSchemaIdValidator();
4040

4141
/**
42-
* Implementation of {@link JsonSchemaIdValidator}.
42+
* Implementation of {@link SchemaIdValidator}.
4343
* <p>
4444
* Note that this does not strictly follow the specification.
4545
* <p>
@@ -48,7 +48,7 @@ boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation,
4848
* <p>
4949
* This also allows non-empty fragments.
5050
*/
51-
class DefaultJsonSchemaIdValidator implements JsonSchemaIdValidator {
51+
class DefaultSchemaIdValidator implements SchemaIdValidator {
5252
@Override
5353
public boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation,
5454
SchemaLocation resolvedSchemaLocation, SchemaContext schemaContext) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static SchemaRegistryConfig getInstance() {
118118
/**
119119
* Used to validate the acceptable $id values.
120120
*/
121-
private final JsonSchemaIdValidator schemaIdValidator;
121+
private final SchemaIdValidator schemaIdValidator;
122122

123123
/**
124124
* Contains a mapping of how strict a keyword's validators should be.
@@ -142,7 +142,7 @@ protected SchemaRegistryConfig(boolean cacheRefs,
142142
Locale locale, boolean losslessNarrowing,
143143
MessageSource messageSource, PathType pathType,
144144
boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth,
145-
RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator,
145+
RegularExpressionFactory regularExpressionFactory, SchemaIdValidator schemaIdValidator,
146146
Map<String, Boolean> strictness, boolean typeLoose) {
147147
super();
148148
this.cacheRefs = cacheRefs;
@@ -246,7 +246,7 @@ public RegularExpressionFactory getRegularExpressionFactory() {
246246
*
247247
* @return the validator
248248
*/
249-
public JsonSchemaIdValidator getSchemaIdValidator() {
249+
public SchemaIdValidator getSchemaIdValidator() {
250250
return schemaIdValidator;
251251
}
252252

@@ -386,7 +386,7 @@ public static abstract class BuilderSupport<T> {
386386
protected boolean preloadJsonSchema = true;
387387
protected int preloadJsonSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH;
388388
protected RegularExpressionFactory regularExpressionFactory = JDKRegularExpressionFactory.getInstance();
389-
protected JsonSchemaIdValidator schemaIdValidator = JsonSchemaIdValidator.DEFAULT;
389+
protected SchemaIdValidator schemaIdValidator = SchemaIdValidator.DEFAULT;
390390
protected Map<String, Boolean> strictness = new HashMap<>(0);
391391
protected boolean typeLoose = false;
392392

@@ -550,12 +550,12 @@ public T regularExpressionFactory(RegularExpressionFactory regularExpressionFact
550550
/**
551551
* Sets the schema id validator to use.
552552
* <p>
553-
* Defaults to {@link JsonSchemaIdValidator#DEFAULT}.
553+
* Defaults to {@link SchemaIdValidator#DEFAULT}.
554554
*
555555
* @param schemaIdValidator the builder
556556
* @return the builder
557557
*/
558-
public T schemaIdValidator(JsonSchemaIdValidator schemaIdValidator) {
558+
public T schemaIdValidator(SchemaIdValidator schemaIdValidator) {
559559
this.schemaIdValidator = schemaIdValidator;
560560
return self();
561561
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void givenRelativeIdShouldThrowInvalidSchemaException() {
3232
String schema = "{\r\n" + " \"$id\": \"0\",\r\n"
3333
+ " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}";
3434
SchemaRegistryConfig config = SchemaRegistryConfig.builder()
35-
.schemaIdValidator(JsonSchemaIdValidator.DEFAULT)
35+
.schemaIdValidator(SchemaIdValidator.DEFAULT)
3636
.build();
3737
assertThrowsExactly(InvalidSchemaException.class,
3838
() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema));
@@ -48,7 +48,7 @@ void givenFragmentWithNoContextShouldNotThrowInvalidSchemaException() {
4848
String schema = "{\r\n" + " \"$id\": \"#0\",\r\n"
4949
+ " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}";
5050
SchemaRegistryConfig config = SchemaRegistryConfig.builder()
51-
.schemaIdValidator(JsonSchemaIdValidator.DEFAULT)
51+
.schemaIdValidator(SchemaIdValidator.DEFAULT)
5252
.build();
5353
assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema));
5454
}
@@ -58,15 +58,15 @@ void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() {
5858
String schema = "{\r\n" + " \"$id\": \"/base\",\r\n"
5959
+ " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}";
6060
SchemaRegistryConfig config = SchemaRegistryConfig.builder()
61-
.schemaIdValidator(JsonSchemaIdValidator.DEFAULT)
61+
.schemaIdValidator(SchemaIdValidator.DEFAULT)
6262
.build();
6363
assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema));
6464
}
6565

6666
@Test
6767
void givenRelativeIdWithClasspathBaseShouldNotThrowInvalidSchemaException() {
6868
SchemaRegistryConfig config = SchemaRegistryConfig.builder()
69-
.schemaIdValidator(JsonSchemaIdValidator.DEFAULT)
69+
.schemaIdValidator(SchemaIdValidator.DEFAULT)
7070
.build();
7171
assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config))
7272
.getSchema(SchemaLocation.of("classpath:schema/id-relative.json")));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void shouldThrowInvalidSchemaException() {
2828
String schema = "{\r\n" + " \"$id\": \"0\",\r\n"
2929
+ " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}";
3030
SchemaRegistryConfig config = SchemaRegistryConfig.builder()
31-
.schemaIdValidator(JsonSchemaIdValidator.DEFAULT)
31+
.schemaIdValidator(SchemaIdValidator.DEFAULT)
3232
.build();
3333
assertThrowsExactly(InvalidSchemaException.class,
3434
() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema));

0 commit comments

Comments
 (0)