diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabulary.java new file mode 100644 index 00000000..4dc6adc8 --- /dev/null +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabulary.java @@ -0,0 +1,42 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; +import java.net.URI; +import java.util.Optional; + +final class BasicVocabulary implements Vocabulary { + + @Override + public URI id() { + return URI.create("http://https://github.com/sebastian-toepfer/json-schema/basic"); + } + + @Override + public Optional findKeywordTypeByName(final String name) { + return Optional.of(new UnknowKeywordType(name)); + } +} diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java index 793afba5..558ec122 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java @@ -28,8 +28,9 @@ import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.Vocabulary; -import io.github.sebastiantoepfer.jsonschema.core.vocab.basic.BasicVocabulary; -import io.github.sebastiantoepfer.jsonschema.core.vocab.core.CoreLazyVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.applicator.ApplicatorVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.core.CoreVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.ValidationVocabulary; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.VocabularyDefinition; import jakarta.json.JsonValue; @@ -46,13 +47,16 @@ final class Keywords { private static final Map MANDANTORY_VOCABS; + private static final Collection DEFAULT_VOCABS; static { MANDANTORY_VOCABS = List - .of(new BasicVocabulary(), new CoreLazyVocabulary().vocab()) + .of(new BasicVocabulary(), new CoreVocabulary()) .stream() .collect(toMap(Vocabulary::id, Function.identity())); + + DEFAULT_VOCABS = List.of(new ValidationVocabulary(), new ApplicatorVocabulary()); } private final Collection vocabularies; @@ -69,7 +73,7 @@ public Keywords(final Collection vocabDefs) { vocabularies = Stream .concat( - MANDANTORY_VOCABS.values().stream(), + Stream.concat(MANDANTORY_VOCABS.values().stream(), DEFAULT_VOCABS.stream()), vocabDefs.stream().map(VocabularyDefinition::findVocabulary).flatMap(Optional::stream) ) .collect( diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/UnknowKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/UnknowKeywordType.java similarity index 96% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/UnknowKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/UnknowKeywordType.java index cad85212..a23d3541 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/UnknowKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/UnknowKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core; import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.keyword.DefaultAnnotation; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabularies.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabularies.java new file mode 100644 index 00000000..269de07c --- /dev/null +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabularies.java @@ -0,0 +1,61 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.applicator.ApplicatorVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.content.ContentVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.core.CoreVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.format.FormatVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.meta.MetaDataVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.unevaluated.UnevaluatedVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.ValidationVocabulary; +import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies; +import java.net.URI; +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +public final class OfficialVocabularies implements LazyVocabularies { + + private static final Collection OFFICEAL_VOCABS; + + static { + OFFICEAL_VOCABS = + List.of( + new CoreVocabulary(), + new ApplicatorVocabulary(), + new ValidationVocabulary(), + new MetaDataVocabulary(), + new FormatVocabulary(), + new UnevaluatedVocabulary(), + new ContentVocabulary() + ); + } + + @Override + public Optional loadVocabularyWithId(final URI id) { + return OFFICEAL_VOCABS.stream().filter(vocab -> vocab.id().equals(id)).findFirst(); + } +} diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabulary.java new file mode 100644 index 00000000..ff10d6ee --- /dev/null +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabulary.java @@ -0,0 +1,53 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab.applicator; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; +import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.DefaultVocabulary; +import java.net.URI; +import java.util.Optional; + +public final class ApplicatorVocabulary implements Vocabulary { + + private final Vocabulary vocab; + + public ApplicatorVocabulary() { + this.vocab = + new DefaultVocabulary( + URI.create("https://json-schema.org/draft/2020-12/vocab/applicator"), + new ItemsKeywordType() + ); + } + + @Override + public URI id() { + return vocab.id(); + } + + @Override + public Optional findKeywordTypeByName(final String name) { + return vocab.findKeywordTypeByName(name); + } +} diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ItemsKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordType.java similarity index 98% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ItemsKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordType.java index 16a2f1fa..e74e8764 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ItemsKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.applicator; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/content/ContentVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/content/ContentVocabulary.java new file mode 100644 index 00000000..25c46fb4 --- /dev/null +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/content/ContentVocabulary.java @@ -0,0 +1,49 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab.content; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; +import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.DefaultVocabulary; +import java.net.URI; +import java.util.Optional; + +public final class ContentVocabulary implements Vocabulary { + + private final Vocabulary vocab; + + public ContentVocabulary() { + this.vocab = new DefaultVocabulary(URI.create("https://json-schema.org/draft/2020-12/vocab/content")); + } + + @Override + public URI id() { + return vocab.id(); + } + + @Override + public Optional findKeywordTypeByName(final String name) { + return Optional.empty(); + } +} diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreLazyVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabulary.java similarity index 77% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreLazyVocabulary.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabulary.java index 9e0ea27c..ddbfe001 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreLazyVocabulary.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabulary.java @@ -24,17 +24,16 @@ package io.github.sebastiantoepfer.jsonschema.core.vocab.core; import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.DefaultVocabulary; -import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies; import java.net.URI; -import java.util.Objects; import java.util.Optional; -public final class CoreLazyVocabulary implements LazyVocabularies { +public final class CoreVocabulary implements Vocabulary { private final Vocabulary vocab; - public CoreLazyVocabulary() { + public CoreVocabulary() { this.vocab = new DefaultVocabulary( URI.create("https://json-schema.org/draft/2020-12/vocab/core"), @@ -48,18 +47,13 @@ public CoreLazyVocabulary() { ); } - public Vocabulary vocab() { - return vocab; + @Override + public URI id() { + return vocab.id(); } @Override - public Optional loadVocabularyWithId(final URI id) { - final Optional result; - if (Objects.equals(id, vocab.id())) { - result = Optional.of(vocab); - } else { - result = Optional.empty(); - } - return result; + public Optional findKeywordTypeByName(final String name) { + return vocab.findKeywordTypeByName(name); } } diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/format/FormatVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/format/FormatVocabulary.java new file mode 100644 index 00000000..db418b97 --- /dev/null +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/format/FormatVocabulary.java @@ -0,0 +1,49 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab.format; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; +import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.DefaultVocabulary; +import java.net.URI; +import java.util.Optional; + +public final class FormatVocabulary implements Vocabulary { + + private final Vocabulary vocab; + + public FormatVocabulary() { + this.vocab = new DefaultVocabulary(URI.create("https://json-schema.org/draft/2020-12/vocab/format-annotation")); + } + + @Override + public URI id() { + return vocab.id(); + } + + @Override + public Optional findKeywordTypeByName(final String name) { + return Optional.empty(); + } +} diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/meta/MetaDataVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/meta/MetaDataVocabulary.java new file mode 100644 index 00000000..95f6df78 --- /dev/null +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/meta/MetaDataVocabulary.java @@ -0,0 +1,49 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab.meta; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; +import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.DefaultVocabulary; +import java.net.URI; +import java.util.Optional; + +public final class MetaDataVocabulary implements Vocabulary { + + private final Vocabulary vocab; + + public MetaDataVocabulary() { + this.vocab = new DefaultVocabulary(URI.create("https://json-schema.org/draft/2020-12/vocab/meta-data")); + } + + @Override + public URI id() { + return vocab.id(); + } + + @Override + public Optional findKeywordTypeByName(final String name) { + return Optional.empty(); + } +} diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/unevaluated/UnevaluatedVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/unevaluated/UnevaluatedVocabulary.java new file mode 100644 index 00000000..75bc746f --- /dev/null +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/unevaluated/UnevaluatedVocabulary.java @@ -0,0 +1,49 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab.unevaluated; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; +import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.DefaultVocabulary; +import java.net.URI; +import java.util.Optional; + +public final class UnevaluatedVocabulary implements Vocabulary { + + private final Vocabulary vocab; + + public UnevaluatedVocabulary() { + this.vocab = new DefaultVocabulary(URI.create("https://json-schema.org/draft/2020-12/vocab/unevaluated")); + } + + @Override + public URI id() { + return vocab.id(); + } + + @Override + public Optional findKeywordTypeByName(final String name) { + return Optional.empty(); + } +} diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMaximumKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMaximumKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordType.java index ae18dca2..1fd6c958 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMaximumKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMinimumKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMinimumKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordType.java index 938fa196..561d5b64 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMinimumKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaxLengthKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaxLengthKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordType.java index b10564ab..2a022d33 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaxLengthKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaximumKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaximumKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordType.java index b04dc35e..c78f2197 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaximumKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinLengthKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinLengthKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordType.java index 010b9068..0f5b91d7 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinLengthKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinimumKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinimumKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordType.java index 99ecbb78..0f09579d 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinimumKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MultipleOfKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MultipleOfKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordType.java index aae9fdbf..e2a6f962 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MultipleOfKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/PatternKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordType.java similarity index 97% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/PatternKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordType.java index 800c734a..9066c6e9 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/PatternKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.ConstraintViolation; import io.github.sebastiantoepfer.jsonschema.InstanceType; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/TypeKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordType.java similarity index 98% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/TypeKeywordType.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordType.java index 6395b236..0a00beef 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/TypeKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordType.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/BasicVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ValidationVocabulary.java similarity index 79% rename from core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/BasicVocabulary.java rename to core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ValidationVocabulary.java index ec37ea62..26a3ba21 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/BasicVocabulary.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ValidationVocabulary.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import io.github.sebastiantoepfer.jsonschema.Vocabulary; import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; @@ -29,25 +29,23 @@ import java.net.URI; import java.util.Optional; -public final class BasicVocabulary implements Vocabulary { +public final class ValidationVocabulary implements Vocabulary { - private final DefaultVocabulary vocab; + private final Vocabulary vocab; - public BasicVocabulary() { + public ValidationVocabulary() { this.vocab = new DefaultVocabulary( - URI.create("http://https://github.com/sebastian-toepfer/json-schema/basic"), + URI.create("https://json-schema.org/draft/2020-12/vocab/validation"), new TypeKeywordType(), new MinLengthKeywordType(), new MaxLengthKeywordType(), new PatternKeywordType(), - new PatternKeywordType(), new MinimumKeywordType(), new ExclusiveMinimumKeywordType(), new MaximumKeywordType(), new ExclusiveMaximumKeywordType(), - new MultipleOfKeywordType(), - new ItemsKeywordType() + new MultipleOfKeywordType() ); } @@ -58,6 +56,6 @@ public URI id() { @Override public Optional findKeywordTypeByName(final String name) { - return Optional.of(vocab.findKeywordTypeByName(name).orElseGet(() -> new UnknowKeywordType(name))); + return vocab.findKeywordTypeByName(name); } } diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index 8b5dbe51..51f87de4 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -30,5 +30,5 @@ with io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; provides io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies - with io.github.sebastiantoepfer.jsonschema.core.vocab.core.CoreLazyVocabulary; + with io.github.sebastiantoepfer.jsonschema.core.vocab.OfficialVocabularies; } diff --git a/core/src/main/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies b/core/src/main/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies index 7924e0ef..701a4011 100644 --- a/core/src/main/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies +++ b/core/src/main/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies @@ -1 +1 @@ -io.github.sebastiantoepfer.jsonschema.core.vocab.core.CoreLazyVocabulary +io.github.sebastiantoepfer.jsonschema.core.vocab.OfficialVocabularies diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/BasicVocabularyTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabularyTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/BasicVocabularyTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabularyTest.java index c5369f86..869180d6 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/BasicVocabularyTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabularyTest.java @@ -21,12 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import com.github.npathai.hamcrestopt.OptionalMatchers; +import io.github.sebastiantoepfer.jsonschema.core.BasicVocabulary; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; import jakarta.json.JsonValue; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/KeywordsTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/KeywordsTest.java index fd6b3c02..beae460c 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/KeywordsTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/KeywordsTest.java @@ -29,8 +29,7 @@ import static org.hamcrest.Matchers.nullValue; import static org.junit.jupiter.api.Assertions.assertThrows; -import io.github.sebastiantoepfer.jsonschema.core.vocab.basic.BasicVocabulary; -import io.github.sebastiantoepfer.jsonschema.core.vocab.core.CoreLazyVocabulary; +import io.github.sebastiantoepfer.jsonschema.core.vocab.core.CoreVocabulary; import io.github.sebastiantoepfer.jsonschema.vocabulary.spi.VocabularyDefinition; import java.net.URI; import java.util.Collection; @@ -42,7 +41,7 @@ class KeywordsTest { @Test void should_not_be_createbale_without_mandantory_core_vocabulary() { final Collection vocabDefs = List.of( - new VocabularyDefinition(new CoreLazyVocabulary().vocab().id(), false) + new VocabularyDefinition(new CoreVocabulary().id(), false) ); assertThrows(IllegalArgumentException.class, () -> new Keywords(vocabDefs)); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabulariesTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabulariesTest.java new file mode 100644 index 00000000..08e48286 --- /dev/null +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabulariesTest.java @@ -0,0 +1,54 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab; + +import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresentAndIs; +import static org.hamcrest.MatcherAssert.assertThat; + +import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import java.net.URI; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class OfficialVocabulariesTest { + + @ParameterizedTest + @ValueSource( + strings = { + "https://json-schema.org/draft/2020-12/vocab/core", + "https://json-schema.org/draft/2020-12/vocab/applicator", + "https://json-schema.org/draft/2020-12/vocab/validation", + "https://json-schema.org/draft/2020-12/vocab/meta-data", + "https://json-schema.org/draft/2020-12/vocab/format-annotation", + "https://json-schema.org/draft/2020-12/vocab/unevaluated", + "https://json-schema.org/draft/2020-12/vocab/content", + } + ) + void should_load_all_offical_vocabs(final String id) { + assertThat( + new OfficialVocabularies().loadVocabularyWithId(URI.create(id)).map(Vocabulary::id).map(URI::toString), + isPresentAndIs(id) + ); + } +} diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabularyTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabularyTest.java new file mode 100644 index 00000000..8ad288fd --- /dev/null +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabularyTest.java @@ -0,0 +1,41 @@ +/* + * The MIT License + * + * Copyright 2023 sebastian. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package io.github.sebastiantoepfer.jsonschema.core.vocab.applicator; + +import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresentAndIs; +import static org.hamcrest.MatcherAssert.assertThat; + +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; +import org.junit.jupiter.api.Test; + +class ApplicatorVocabularyTest { + + @Test + void should_find_items_keyword() { + assertThat( + new ApplicatorVocabulary().findKeywordTypeByName("items").map(KeywordType::name), + isPresentAndIs("items") + ); + } +} diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ItemsKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordTypeTest.java similarity index 98% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ItemsKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordTypeTest.java index 52e6eedf..d74ec437 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ItemsKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordTypeTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.applicator; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreLazyVocabularyTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabularyTest.java similarity index 68% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreLazyVocabularyTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabularyTest.java index a862b625..34142a9b 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreLazyVocabularyTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabularyTest.java @@ -23,28 +23,26 @@ */ package io.github.sebastiantoepfer.jsonschema.core.vocab.core; -import static com.github.npathai.hamcrestopt.OptionalMatchers.isEmpty; -import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresentAndIs; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; -import io.github.sebastiantoepfer.jsonschema.Vocabulary; +import com.github.npathai.hamcrestopt.OptionalMatchers; +import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType; import java.net.URI; import org.junit.jupiter.api.Test; -class CoreLazyVocabularyTest { +class CoreVocabularyTest { @Test - void should_return_empty_for_non_core_id() { - assertThat(new CoreLazyVocabulary().loadVocabularyWithId(URI.create("")), isEmpty()); + void should_return_core_vocabulary_for_core_id() { + assertThat(new CoreVocabulary().id(), is(URI.create("https://json-schema.org/draft/2020-12/vocab/core"))); } @Test - void should_return_core_vocabulary_for_core_id() { + void should_load_schema_keyword() { assertThat( - new CoreLazyVocabulary() - .loadVocabularyWithId(URI.create("https://json-schema.org/draft/2020-12/vocab/core")) - .map(Vocabulary::id), - isPresentAndIs(URI.create("https://json-schema.org/draft/2020-12/vocab/core")) + new CoreVocabulary().findKeywordTypeByName("$schema").map(KeywordType::name), + OptionalMatchers.isPresentAndIs("$schema") ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMaximumKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordTypeTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMaximumKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordTypeTest.java index 907374d7..3beab264 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMaximumKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordTypeTest.java @@ -21,13 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.ExclusiveMaximumKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonValue; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMinimumKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordTypeTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMinimumKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordTypeTest.java index ea1d0ebd..fdfff96d 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/ExclusiveMinimumKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordTypeTest.java @@ -21,13 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.ExclusiveMinimumKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonValue; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaxLengthKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordTypeTest.java similarity index 93% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaxLengthKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordTypeTest.java index 37d9b75f..db537124 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaxLengthKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordTypeTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -29,6 +29,8 @@ import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.MaxLengthKeywordType; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.MinLengthKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonNumber; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaximumKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordTypeTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaximumKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordTypeTest.java index 6748c608..e8ccbc6a 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MaximumKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordTypeTest.java @@ -21,13 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.MaximumKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonValue; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinLengthKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordTypeTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinLengthKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordTypeTest.java index 807c1be3..1bb69a83 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinLengthKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordTypeTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -29,6 +29,7 @@ import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.MinLengthKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonNumber; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinimumKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordTypeTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinimumKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordTypeTest.java index 23b85aa1..c7d35244 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MinimumKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordTypeTest.java @@ -21,12 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.MinimumKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonValue; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MultipleOfKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordTypeTest.java similarity index 96% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MultipleOfKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordTypeTest.java index 2f818951..36a10488 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/MultipleOfKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordTypeTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -29,6 +29,7 @@ import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.MultipleOfKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonValue; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/PatternKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordTypeTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/PatternKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordTypeTest.java index 57ff8dc1..09031c6d 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/PatternKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordTypeTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -29,6 +29,7 @@ import io.github.sebastiantoepfer.jsonschema.JsonSchema; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.PatternKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Keyword; import jakarta.json.Json; import jakarta.json.JsonValue; diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/TypeKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordTypeTest.java similarity index 95% rename from core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/TypeKeywordTypeTest.java rename to core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordTypeTest.java index 3fc93b7d..5b56cc7a 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/basic/TypeKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordTypeTest.java @@ -21,12 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package io.github.sebastiantoepfer.jsonschema.core.vocab.basic; +package io.github.sebastiantoepfer.jsonschema.core.vocab.validation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import io.github.sebastiantoepfer.jsonschema.core.DefaultJsonSchemaFactory; +import io.github.sebastiantoepfer.jsonschema.core.vocab.validation.TypeKeywordType; import io.github.sebastiantoepfer.jsonschema.keyword.Assertion; import jakarta.json.Json; import jakarta.json.JsonValue;