Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing presentation def in json schema #101

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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