Skip to content

Commit f61f24f

Browse files
committed
Rename ValidatorTypeCode to KeywordType
1 parent 8811f37 commit f61f24f

File tree

69 files changed

+205
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+205
-205
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.networknt.schema.keyword.DiscriminatorValidator;
3535
import com.networknt.schema.keyword.KeywordValidator;
3636
import com.networknt.schema.keyword.TypeValidator;
37-
import com.networknt.schema.keyword.Keywords;
37+
import com.networknt.schema.keyword.KeywordType;
3838
import com.networknt.schema.utils.JsonNodes;
3939

4040
/**
@@ -186,13 +186,13 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc
186186
if (!validator.validate(id, rootSchema, schemaLocation, result, schemaContext)) {
187187
SchemaLocation idSchemaLocation = schemaLocation.append(schemaContext.getDialect().getIdKeyword());
188188
Error error = Error.builder()
189-
.messageKey(Keywords.ID.getValue()).keyword(Keywords.ID.getValue())
189+
.messageKey(KeywordType.ID.getValue()).keyword(KeywordType.ID.getValue())
190190
.instanceLocation(idSchemaLocation.getFragment())
191191
.arguments(id, schemaContext.getDialect().getIdKeyword(), idSchemaLocation)
192192
.schemaLocation(idSchemaLocation)
193193
.schemaNode(schemaNode)
194194
.messageFormatter(args -> schemaContext.getSchemaRegistryConfig().getMessageSource().getMessage(
195-
Keywords.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args))
195+
KeywordType.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args))
196196
.build();
197197
throw new InvalidSchemaException(error);
198198
}
@@ -506,7 +506,7 @@ public Schema getSubSchema(NodePath fragment) {
506506
}
507507
if (found == null) {
508508
Error error = Error.builder()
509-
.keyword(Keywords.REF.getValue()).messageKey("internal.unresolvedRef")
509+
.keyword(KeywordType.REF.getValue()).messageKey("internal.unresolvedRef")
510510
.message("Reference {0} cannot be resolved")
511511
.instanceLocation(schemaLocation.getFragment())
512512
.schemaLocation(schemaLocation)

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

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.networknt.schema.keyword.AnnotationKeyword;
2424
import com.networknt.schema.keyword.Keyword;
2525
import com.networknt.schema.keyword.NonValidationKeyword;
26-
import com.networknt.schema.keyword.Keywords;
26+
import com.networknt.schema.keyword.KeywordType;
2727

2828
/**
2929
* Represents a vocabulary in meta-schema.
@@ -35,75 +35,75 @@ public class Vocabulary {
3535
// 2019-09
3636
public static final Vocabulary DRAFT_2019_09_CORE = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/core",
3737
new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), new NonValidationKeyword("$anchor"),
38-
Keywords.REF, Keywords.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"),
38+
KeywordType.REF, KeywordType.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"),
3939
new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"),
4040
new NonValidationKeyword("$defs"));
4141
public static final Vocabulary DRAFT_2019_09_APPLICATOR = new Vocabulary(
4242
"https://json-schema.org/draft/2019-09/vocab/applicator", new NonValidationKeyword("additionalItems"),
43-
Keywords.UNEVALUATED_ITEMS, Keywords.ITEMS, Keywords.CONTAINS,
44-
Keywords.ADDITIONAL_PROPERTIES, Keywords.UNEVALUATED_PROPERTIES,
45-
Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS,
46-
Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"),
47-
new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF,
48-
Keywords.ONE_OF, Keywords.NOT);
43+
KeywordType.UNEVALUATED_ITEMS, KeywordType.ITEMS, KeywordType.CONTAINS,
44+
KeywordType.ADDITIONAL_PROPERTIES, KeywordType.UNEVALUATED_PROPERTIES,
45+
KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS,
46+
KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"),
47+
new NonValidationKeyword("else"), KeywordType.ALL_OF, KeywordType.ANY_OF,
48+
KeywordType.ONE_OF, KeywordType.NOT);
4949
public static final Vocabulary DRAFT_2019_09_VALIDATION = new Vocabulary(
50-
"https://json-schema.org/draft/2019-09/vocab/validation", Keywords.MULTIPLE_OF,
51-
Keywords.MAXIMUM, Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM,
52-
Keywords.EXCLUSIVE_MINIMUM, Keywords.MAX_LENGTH, Keywords.MIN_LENGTH,
53-
Keywords.PATTERN, Keywords.MAX_ITEMS, Keywords.MIN_ITEMS,
54-
Keywords.UNIQUE_ITEMS, Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS,
55-
Keywords.MAX_PROPERTIES, Keywords.MIN_PROPERTIES, Keywords.REQUIRED,
56-
Keywords.DEPENDENT_REQUIRED, Keywords.CONST, Keywords.ENUM,
57-
Keywords.TYPE);
50+
"https://json-schema.org/draft/2019-09/vocab/validation", KeywordType.MULTIPLE_OF,
51+
KeywordType.MAXIMUM, KeywordType.EXCLUSIVE_MAXIMUM, KeywordType.MINIMUM,
52+
KeywordType.EXCLUSIVE_MINIMUM, KeywordType.MAX_LENGTH, KeywordType.MIN_LENGTH,
53+
KeywordType.PATTERN, KeywordType.MAX_ITEMS, KeywordType.MIN_ITEMS,
54+
KeywordType.UNIQUE_ITEMS, KeywordType.MAX_CONTAINS, KeywordType.MIN_CONTAINS,
55+
KeywordType.MAX_PROPERTIES, KeywordType.MIN_PROPERTIES, KeywordType.REQUIRED,
56+
KeywordType.DEPENDENT_REQUIRED, KeywordType.CONST, KeywordType.ENUM,
57+
KeywordType.TYPE);
5858
public static final Vocabulary DRAFT_2019_09_META_DATA = new Vocabulary(
5959
"https://json-schema.org/draft/2019-09/vocab/meta-data", new AnnotationKeyword("title"),
6060
new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"),
61-
Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples"));
61+
KeywordType.READ_ONLY, KeywordType.WRITE_ONLY, new AnnotationKeyword("examples"));
6262
public static final Vocabulary DRAFT_2019_09_FORMAT = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/format",
63-
Keywords.FORMAT);
63+
KeywordType.FORMAT);
6464
public static final Vocabulary DRAFT_2019_09_CONTENT = new Vocabulary(
6565
"https://json-schema.org/draft/2019-09/vocab/content", new AnnotationKeyword("contentMediaType"),
6666
new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentSchema"));
6767

6868
// 2020-12
6969
public static final Vocabulary DRAFT_2020_12_CORE = new Vocabulary("https://json-schema.org/draft/2020-12/vocab/core",
70-
new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), Keywords.REF,
71-
new NonValidationKeyword("$anchor"), Keywords.DYNAMIC_REF,
70+
new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), KeywordType.REF,
71+
new NonValidationKeyword("$anchor"), KeywordType.DYNAMIC_REF,
7272
new NonValidationKeyword("$dynamicAnchor"), new NonValidationKeyword("$vocabulary"),
7373
new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs"));
7474
public static final Vocabulary DRAFT_2020_12_APPLICATOR = new Vocabulary(
75-
"https://json-schema.org/draft/2020-12/vocab/applicator", Keywords.PREFIX_ITEMS,
76-
Keywords.ITEMS_202012, Keywords.CONTAINS, Keywords.ADDITIONAL_PROPERTIES,
77-
Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS,
78-
Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"),
79-
new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF,
80-
Keywords.ONE_OF, Keywords.NOT);
75+
"https://json-schema.org/draft/2020-12/vocab/applicator", KeywordType.PREFIX_ITEMS,
76+
KeywordType.ITEMS_202012, KeywordType.CONTAINS, KeywordType.ADDITIONAL_PROPERTIES,
77+
KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS,
78+
KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"),
79+
new NonValidationKeyword("else"), KeywordType.ALL_OF, KeywordType.ANY_OF,
80+
KeywordType.ONE_OF, KeywordType.NOT);
8181
public static final Vocabulary DRAFT_2020_12_UNEVALUATED = new Vocabulary(
82-
"https://json-schema.org/draft/2020-12/vocab/unevaluated", Keywords.UNEVALUATED_ITEMS,
83-
Keywords.UNEVALUATED_PROPERTIES);
82+
"https://json-schema.org/draft/2020-12/vocab/unevaluated", KeywordType.UNEVALUATED_ITEMS,
83+
KeywordType.UNEVALUATED_PROPERTIES);
8484
public static final Vocabulary DRAFT_2020_12_VALIDATION = new Vocabulary(
85-
"https://json-schema.org/draft/2020-12/vocab/validation", Keywords.TYPE, Keywords.CONST,
86-
Keywords.ENUM, Keywords.MULTIPLE_OF, Keywords.MAXIMUM,
87-
Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM, Keywords.EXCLUSIVE_MINIMUM,
88-
Keywords.MAX_LENGTH, Keywords.MIN_LENGTH, Keywords.PATTERN,
89-
Keywords.MAX_ITEMS, Keywords.MIN_ITEMS, Keywords.UNIQUE_ITEMS,
90-
Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS, Keywords.MAX_PROPERTIES,
91-
Keywords.MIN_PROPERTIES, Keywords.REQUIRED, Keywords.DEPENDENT_REQUIRED);
85+
"https://json-schema.org/draft/2020-12/vocab/validation", KeywordType.TYPE, KeywordType.CONST,
86+
KeywordType.ENUM, KeywordType.MULTIPLE_OF, KeywordType.MAXIMUM,
87+
KeywordType.EXCLUSIVE_MAXIMUM, KeywordType.MINIMUM, KeywordType.EXCLUSIVE_MINIMUM,
88+
KeywordType.MAX_LENGTH, KeywordType.MIN_LENGTH, KeywordType.PATTERN,
89+
KeywordType.MAX_ITEMS, KeywordType.MIN_ITEMS, KeywordType.UNIQUE_ITEMS,
90+
KeywordType.MAX_CONTAINS, KeywordType.MIN_CONTAINS, KeywordType.MAX_PROPERTIES,
91+
KeywordType.MIN_PROPERTIES, KeywordType.REQUIRED, KeywordType.DEPENDENT_REQUIRED);
9292
public static final Vocabulary DRAFT_2020_12_META_DATA = new Vocabulary(
9393
"https://json-schema.org/draft/2020-12/vocab/meta-data", new AnnotationKeyword("title"),
9494
new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"),
95-
Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples"));
95+
KeywordType.READ_ONLY, KeywordType.WRITE_ONLY, new AnnotationKeyword("examples"));
9696
public static final Vocabulary DRAFT_2020_12_FORMAT_ANNOTATION = new Vocabulary(
97-
"https://json-schema.org/draft/2020-12/vocab/format-annotation", Keywords.FORMAT);
97+
"https://json-schema.org/draft/2020-12/vocab/format-annotation", KeywordType.FORMAT);
9898
public static final Vocabulary DRAFT_2020_12_FORMAT_ASSERTION = new Vocabulary(
99-
"https://json-schema.org/draft/2020-12/vocab/format-assertion", Keywords.FORMAT);
99+
"https://json-schema.org/draft/2020-12/vocab/format-assertion", KeywordType.FORMAT);
100100
public static final Vocabulary DRAFT_2020_12_CONTENT = new Vocabulary(
101101
"https://json-schema.org/draft/2020-12/vocab/content", new AnnotationKeyword("contentEncoding"),
102102
new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentSchema"));
103103

104104
// OpenAPI 3.1
105105
public static final Vocabulary OPENAPI_3_1_BASE = new Vocabulary("https://spec.openapis.org/oas/3.1/vocab/base",
106-
new AnnotationKeyword("example"), Keywords.DISCRIMINATOR, new AnnotationKeyword("externalDocs"),
106+
new AnnotationKeyword("example"), KeywordType.DISCRIMINATOR, new AnnotationKeyword("externalDocs"),
107107
new AnnotationKeyword("xml"));
108108

109109
private final String iri;

src/main/java/com/networknt/schema/dialect/Dialect.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.networknt.schema.keyword.KeywordFactory;
3535
import com.networknt.schema.keyword.KeywordValidator;
3636
import com.networknt.schema.keyword.UnknownKeywordFactory;
37-
import com.networknt.schema.keyword.Keywords;
37+
import com.networknt.schema.keyword.KeywordType;
3838
import com.networknt.schema.utils.StringUtils;
3939
import org.slf4j.Logger;
4040
import org.slf4j.LoggerFactory;
@@ -93,8 +93,8 @@ private Map<String, Keyword> createKeywordsMap(Map<String, Keyword> kwords, Map<
9393
for (Map.Entry<String, Keyword> type : kwords.entrySet()) {
9494
String keywordName = type.getKey();
9595
Keyword keyword = type.getValue();
96-
if (Keywords.FORMAT.getValue().equals(keywordName)) {
97-
if (!(keyword instanceof FormatKeyword) && !Keywords.FORMAT.equals(keyword)) {
96+
if (KeywordType.FORMAT.getValue().equals(keywordName)) {
97+
if (!(keyword instanceof FormatKeyword) && !KeywordType.FORMAT.equals(keyword)) {
9898
throw new IllegalArgumentException("Overriding the keyword 'format' is not supported. Use the formatKeywordFactory and extend the FormatKeyword.");
9999
}
100100
// Indicate that the format keyword needs to be created
@@ -455,9 +455,9 @@ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation
455455
if (schemaContext.isNullableKeywordEnabled() && "nullable".equals(keyword)) {
456456
return null;
457457
}
458-
if (Keywords.DISCRIMINATOR.getValue().equals(keyword)
458+
if (KeywordType.DISCRIMINATOR.getValue().equals(keyword)
459459
&& schemaContext.isDiscriminatorKeywordEnabled()) {
460-
return Keywords.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode,
460+
return KeywordType.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode,
461461
parentSchema, schemaContext);
462462
}
463463
kw = this.builder.unknownKeywordFactory != null

src/main/java/com/networknt/schema/dialect/Draft201909.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.networknt.schema.Formats;
88
import com.networknt.schema.SpecificationVersion;
99
import com.networknt.schema.keyword.NonValidationKeyword;
10-
import com.networknt.schema.keyword.Keywords;
10+
import com.networknt.schema.keyword.KeywordType;
1111

1212
/**
1313
* Draft 2019-09 dialect.
@@ -35,7 +35,7 @@ private static class Holder {
3535
.specificationVersion(SpecificationVersion.DRAFT_2019_09)
3636
.idKeyword(ID_KEYWORD)
3737
.formats(Formats.DEFAULT)
38-
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2019_09))
38+
.keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_2019_09))
3939
// keywords that may validly exist, but have no validation aspect to them
4040
.keywords(Collections.singletonList(
4141
new NonValidationKeyword("definitions")

src/main/java/com/networknt/schema/dialect/Draft202012.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.networknt.schema.Formats;
88
import com.networknt.schema.SpecificationVersion;
99
import com.networknt.schema.keyword.NonValidationKeyword;
10-
import com.networknt.schema.keyword.Keywords;
10+
import com.networknt.schema.keyword.KeywordType;
1111

1212
/**
1313
* Draft 2020-12 dialect.
@@ -36,7 +36,7 @@ private static class Holder {
3636
.specificationVersion(SpecificationVersion.DRAFT_2020_12)
3737
.idKeyword(ID_KEYWORD)
3838
.formats(Formats.DEFAULT)
39-
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2020_12))
39+
.keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_2020_12))
4040
// keywords that may validly exist, but have no validation aspect to them
4141
.keywords(Collections.singletonList(
4242
new NonValidationKeyword("definitions")

src/main/java/com/networknt/schema/dialect/Draft4.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.networknt.schema.SpecificationVersion;
77
import com.networknt.schema.keyword.AnnotationKeyword;
88
import com.networknt.schema.keyword.NonValidationKeyword;
9-
import com.networknt.schema.keyword.Keywords;
9+
import com.networknt.schema.keyword.KeywordType;
1010

1111
/**
1212
* Draft 4 dialect.
@@ -22,7 +22,7 @@ private static class Holder {
2222
.specificationVersion(SpecificationVersion.DRAFT_4)
2323
.idKeyword(ID_KEYWORD)
2424
.formats(Formats.DEFAULT)
25-
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_4))
25+
.keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_4))
2626
// keywords that may validly exist, but have no validation aspect to them
2727
.keywords(Arrays.asList(
2828
new NonValidationKeyword("$schema"),

src/main/java/com/networknt/schema/dialect/Draft6.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.networknt.schema.SpecificationVersion;
77
import com.networknt.schema.keyword.AnnotationKeyword;
88
import com.networknt.schema.keyword.NonValidationKeyword;
9-
import com.networknt.schema.keyword.Keywords;
9+
import com.networknt.schema.keyword.KeywordType;
1010

1111
/**
1212
* Draft 6 dialect.
@@ -23,7 +23,7 @@ private static class Holder {
2323
.specificationVersion(SpecificationVersion.DRAFT_6)
2424
.idKeyword(ID_KEYWORD)
2525
.formats(Formats.DEFAULT)
26-
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_6))
26+
.keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_6))
2727
// keywords that may validly exist, but have no validation aspect to them
2828
.keywords(Arrays.asList(
2929
new NonValidationKeyword("$schema"),

src/main/java/com/networknt/schema/dialect/Draft7.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.networknt.schema.SpecificationVersion;
77
import com.networknt.schema.keyword.AnnotationKeyword;
88
import com.networknt.schema.keyword.NonValidationKeyword;
9-
import com.networknt.schema.keyword.Keywords;
9+
import com.networknt.schema.keyword.KeywordType;
1010

1111
/**
1212
* Draft 7 dialect.
@@ -22,7 +22,7 @@ private static class Holder {
2222
.specificationVersion(SpecificationVersion.DRAFT_7)
2323
.idKeyword(ID_KEYWORD)
2424
.formats(Formats.DEFAULT)
25-
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_7))
25+
.keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_7))
2626
// keywords that may validly exist, but have no validation aspect to them
2727
.keywords(Arrays.asList(
2828
new NonValidationKeyword("$schema"),

0 commit comments

Comments
 (0)