Skip to content

Commit

Permalink
fix missing presentation def in json schema (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood authored Nov 18, 2024
1 parent c0472d9 commit 82c9e57
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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)
Expand Down

0 comments on commit 82c9e57

Please sign in to comment.