Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoweiss committed Dec 2, 2024
2 parents a1f0c8b + dd2a75f commit aac6b98
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"title": "CatalogRequestMessageSchema",
"type": "object",
"allOf": [
{
"$ref": "#/definitions/CatalogRequestMessage"
}
],
"$id": "https://w3id.org/dspace/2024/1/catalog/catalog-request-message-schema.json",
"definitions": {
"CatalogRequestMessage": {
"type": "object",
"properties": {
"@context": {
"$ref": "https://w3id.org/dspace/2024/1/common/context-schema.json"
},
"@type": {
"type": "string",
"const": "CatalogRequestMessage"
},
"filter": {
"type": "array"
}
},
"required": [
"@context",
"@type"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": [
"https://w3id.org/dspace/2024/1/context.json"
],
"@type": "CatalogRequestMessage",
"filter": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"protocolVersions": [
{
"version": "1.0",
"path": "/some/path/v1"
}
]
}
35 changes: 35 additions & 0 deletions artifacts/src/main/resources/common/protocol-version-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"title": "VersionSchema",
"type": "object",
"allOf": [
{
"$ref": "#/definitions/Version"
}
],
"$id": "https://w3id.org/dspace/2024/1/common/version-schema.json",
"definitions": {
"Version": {
"type": "object",
"properties": {
"protocolVersions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"path": {
"type": "string"
}
},
"required": ["version", "path"]
},
"minItems": 1
}
},
"required": ["protocolVersions"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ void verifyNestedCatalog() {
verifyRoundTrip("/catalog/example/nested-catalog.json",
"/catalog/catalog-schema.json");
}

@Test
void verifyCatalogRequestMessage() {
verifyRoundTrip("/catalog/example/catalog-request-message.json",
"/catalog/catalog-request-message-schema.json");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2024 SAP SE
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* SAP SE - extension to catalog request message
*
*/

package org.eclipse.dsp.schema.catalog;

import org.eclipse.dsp.schema.fixtures.AbstractSchemaTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;

public class CatalogRequestMessageSchemaTest extends AbstractSchemaTest {

@Test
void verifySchema() throws IOException {
var node = mapper.readTree(getClass().getResourceAsStream("/catalog/example/catalog-request-message.json"));
assertThat(schema.validate(node)).isEmpty();
}

@BeforeEach
void setUp() {
setUp("/catalog/catalog-request-message-schema.json");
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2024 Metaform Systems, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Metaform Systems, Inc. - initial API and implementation
*
*/

package org.eclipse.dsp.schema.common;

import org.eclipse.dsp.schema.fixtures.AbstractSchemaTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static com.networknt.schema.InputFormat.JSON;
import static org.assertj.core.api.Assertions.assertThat;

public class InvalidVersionSchemaTest extends AbstractSchemaTest {

@Test
void verifyInvalidCases() throws IOException {
assertThat(schema.validate(INVALID_NO_VERSIONS, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_EMPTY_VERSIONS, JSON).iterator().next().getType()).isEqualTo(MIN_ITEMS);
assertThat(schema.validate(INVALID_NO_VERSION, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_NO_PATH, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
}

@BeforeEach
void setUp() {
setUp("/common/protocol-version-schema.json");
}

private static final String INVALID_NO_VERSIONS = """
{}
""";

private static final String INVALID_EMPTY_VERSIONS = """
{
"protocolVersions": []
}
""";

private static final String INVALID_NO_VERSION = """
{
"protocolVersions": [
{
"path": "/some/path/v1"
}
]
}
""";

private static final String INVALID_NO_PATH = """
{
"protocolVersions": [
{
"version": "1.0"
}
]
}
""";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Metaform Systems, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Metaform Systems, Inc. - initial API and implementation
*
*/

package org.eclipse.dsp.schema.common;

import org.eclipse.dsp.schema.fixtures.AbstractSchemaTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;

public class VersionSchemaTest extends AbstractSchemaTest {

@Test
void verifySchema() throws IOException {
var node = mapper.readTree(getClass().getResourceAsStream("/common/example/protocol-version.json"));
assertThat(schema.validate(node)).isEmpty();
}

@BeforeEach
void setUp() {
setUp("/common/protocol-version-schema.json");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
public abstract class AbstractSchemaTest {
protected static final String MIN_CONTAINS = "minContains";
protected static final String MIN_ITEMS = "minItems";
protected static final String REQUIRED = "required";
protected static final String ONE_OF = "oneOf";
protected static final String TYPE = "type";
Expand Down
26 changes: 16 additions & 10 deletions specifications/common/common.protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@

## Exposure of Dataspace Protocol Versions

[=Connectors=] implementing the Dataspace Protocol may operate on different versions. Therefore, it is necessary that they can discover the supported versions of each other reliably and unambiguously. Each [=Connector=] must expose information of at least one Dataspace Protocol Version it supports. The specifics of how this information is obtained its defined by specific protocol bindings.
[=Connectors=] implementing the Dataspace Protocol may operate on different versions. Therefore, it is necessary that
they can discover the supported versions of each other reliably and unambiguously. Each [=Connector=] must expose
information of at least one Dataspace Protocol Version it supports. The specifics of how this information is obtained
its defined by specific protocol bindings.

A [=Connector=] must respond to a respective request by providing a JSON-LD object containing an array of supported versions with at least one item. The item connects the version tag (`version` attribute) with the absolute URL path segment of the root path for all endpoints of this version. The following example specifies that this [=Connector=] offers version `1.0` endpoints at `<host>/some/path/v1`.
A [=Connector=] must respond to a respective request by providing a JSON object containing an array of supported
versions with at least one item. The item connects the version tag (`version` attribute) with the absolute URL path
segment of the root path for all endpoints of this version. The following example specifies that this [=Connector=]
offers version `1.0` endpoints at `<host>/some/path/v1`.

```json
{
"@context": "https://w3id.org/dspace/2024/1/context.json",
"protocolVersions": [
{
"version": "1.0",
"path": "/some/path/v1"
}
]
"protocolVersions": [
{
"version": "1.0",
"path": "/some/path/v1"
}
]
}
```

This data object must comply to the [JSON Schema](schema/version-schema.json).

The requesting [=Connector=] may select from the endpoints in the response. If the [=Connector=] can't identify a matching Dataspace Protocol Version, it must terminate the communication.
The requesting [=Connector=] may select from the endpoints in the response. If the [=Connector=] can't identify a
matching Dataspace Protocol Version, it must terminate the communication.

0 comments on commit aac6b98

Please sign in to comment.