diff --git a/artifacts/src/main/resources/presentation/presentation-query-message-schema.json b/artifacts/src/main/resources/presentation/presentation-query-message-schema.json index 99c38e6..d5ab541 100644 --- a/artifacts/src/main/resources/presentation/presentation-query-message-schema.json +++ b/artifacts/src/main/resources/presentation/presentation-query-message-schema.json @@ -14,41 +14,65 @@ "properties": { "@context": { "$ref": "https://w3id.org/dspace-dcp/v0.8/common/context-schema.json" - }, - "scope": { - "type": "array", - "items": { - "type": "string" - } } }, - "oneOf": [ + "allOf": [ { - "properties": { - "@type": { - "type": "string", - "const": "PresentationQueryMessage" + "oneOf": [ + { + "properties": { + "scope": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "scope" + ] + }, + { + "properties": { + "presentationDefinition": { + "type": "object" + } + }, + "required": [ + "presentationDefinition" + ] } - }, - "required": [ - "@type" ] }, { - "properties": { - "type": { - "type": "string", - "const": "PresentationQueryMessage" + "oneOf": [ + { + "properties": { + "@type": { + "type": "string", + "const": "PresentationQueryMessage" + } + }, + "required": [ + "@type" + ] + }, + { + "properties": { + "type": { + "type": "string", + "const": "PresentationQueryMessage" + } + }, + "required": [ + "type" + ] } - }, - "required": [ - "type" ] } ], "required": [ - "@context", - "scope" + "@context" ] } } diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationQueryMessageSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationQueryMessageSchemaTest.java index f6f96dc..0437ecd 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationQueryMessageSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationQueryMessageSchemaTest.java @@ -30,6 +30,13 @@ public class PresentationQueryMessageSchemaTest extends AbstractSchemaTest { "scope": ["scope1", "scope2"] }"""; + private static final String PRESENTATION_QUERY_MESSAGE_WITH_PRESENTATION_DEF = """ + { + "@context": ["https://w3id.org/dspace-dcp/v0.8"], + "@type": "PresentationQueryMessage", + "presentationDefinition": {} + }"""; + private static final String INVALID_PRESENTATION_QUERY_MESSAGE_NO_SCOPE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], @@ -45,10 +52,13 @@ public class PresentationQueryMessageSchemaTest extends AbstractSchemaTest { @Test void verifySchema() { assertThat(schema.validate(PRESENTATION_QUERY_MESSAGE, JSON)).isEmpty(); + assertThat(schema.validate(PRESENTATION_QUERY_MESSAGE_WITH_PRESENTATION_DEF, JSON)).isEmpty(); assertThat(schema.validate(INVALID_PRESENTATION_QUERY_MESSAGE_NO_SCOPE, JSON)) .extracting(this::errorExtractor) - .containsExactly(error("scope", REQUIRED)); + .contains(error("scope", REQUIRED), error("presentationDefinition", REQUIRED)); + + assertThat(schema.validate(INVALID_PRESENTATION_QUERY_MESSAGE_NO_TYPE_AND_CONTEXT, JSON)) .hasSize(4) .extracting(this::errorExtractor)