From 7c2b38e6312aee210fbaa92182ec984e439c8bb8 Mon Sep 17 00:00:00 2001 From: Sebastian Toepfer <61313468+sebastian-toepfer@users.noreply.github.com> Date: Tue, 3 Oct 2023 19:48:39 +0200 Subject: [PATCH] define interface for subschema --- .../jsonschema/JsonSubSchema.java | 32 +++++++++++++++++++ .../jsonschema/keyword/KeywordType.java | 3 +- .../jsonschema/keyword/KeywordTypeTest.java | 3 +- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSubSchema.java diff --git a/api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSubSchema.java b/api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSubSchema.java new file mode 100644 index 00000000..0c4ca96b --- /dev/null +++ b/api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSubSchema.java @@ -0,0 +1,32 @@ +/* + * 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; + +/** + * + * see: https://json-schema.org/draft/2020-12/json-schema-core#name-root-schema-and-subschemas- + */ +public interface JsonSubSchema extends JsonSchema { + JsonSchema owner(); +} diff --git a/api/src/main/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordType.java b/api/src/main/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordType.java index edb6a275..ec84aba6 100644 --- a/api/src/main/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordType.java +++ b/api/src/main/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordType.java @@ -23,6 +23,7 @@ */ package io.github.sebastiantoepfer.jsonschema.keyword; +import io.github.sebastiantoepfer.jsonschema.JsonSchema; import jakarta.json.JsonValue; import java.util.Objects; @@ -33,5 +34,5 @@ default boolean hasName(String name) { String name(); - Keyword createKeyword(JsonValue value); + Keyword createKeyword(JsonSchema schema, JsonValue value); } diff --git a/api/src/test/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordTypeTest.java b/api/src/test/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordTypeTest.java index 028e7290..af5e8364 100644 --- a/api/src/test/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordTypeTest.java +++ b/api/src/test/java/io/github/sebastiantoepfer/jsonschema/keyword/KeywordTypeTest.java @@ -26,6 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import io.github.sebastiantoepfer.jsonschema.JsonSchema; import jakarta.json.JsonValue; import org.junit.jupiter.api.Test; @@ -45,7 +46,7 @@ public String name() { } @Override - public Keyword createKeyword(JsonValue value) { + public Keyword createKeyword(final JsonSchema schema, final JsonValue value) { throw new UnsupportedOperationException("Not supported yet."); } }