Skip to content
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 @@ -26,35 +26,7 @@
"type": "string"
},
"offer": {
"oneOf": [
{
"$ref": "https://w3id.org/dspace/2025/1/negotiation/contract-schema.json#/definitions/MessageOffer"
},
{
"properties": {
"@id": {
"type": "string"
}
},
"required": [
"@id"
],
"not": {
"anyOf": [
{
"required": [
"permission"
]
},
{
"required": [
"prohibition"
]
}
]
}
}
]
"$ref": "https://w3id.org/dspace/2025/1/negotiation/contract-schema.json#/definitions/MessageOffer"
},
"callbackAddress": {
"type": "string",
Expand Down
27 changes: 26 additions & 1 deletion artifacts/src/main/resources/negotiation/contract-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"@type": {
"type": "string",
"const": "Offer"
},
"target": {
"type": "string"
}
}
},
Expand All @@ -95,7 +98,29 @@
"type": "object",
"allOf": [
{
"$ref": "#/definitions/MessageOffer"
"$ref": "#/definitions/PolicyClass"
},
{
"properties": {
"@type": {
"type": "string",
"const": "Offer"
}
}
},
{
"anyOf": [
{
"required": [
"permission"
]
},
{
"required": [
"prohibition"
]
}
]
}
],
"not": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.IOException;

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

public class ContractRequestMessageSchemaTest extends AbstractSchemaTest {
Expand All @@ -37,43 +36,9 @@ void verifyInitialRequestSchema() throws IOException {
assertThat(schema.validate(node)).isEmpty();
}

@Test
void verifyIdRequest() {
assertThat(schema.validate(REQUEST_ID, JSON)).isEmpty();
assertThat(schema.validate(REQUEST_INITIAL_ID, JSON)).isEmpty();
}

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

private static final String REQUEST_ID = """
{
"@context": [
"https://w3id.org/dspace/2025/1/context.jsonld"
],
"@type": "ContractRequestMessage",
"providerPid": "urn:uuid:a343fcbf-99fc-4ce8-8e9b-148c97605aab",
"consumerPid": "urn:uuid:32541fe6-c580-409e-85a8-8a9a32fbe833",
"offer": {
"@id": "urn:uuid:d526561f-528e-4d5a-ae12-9a9dd9b7a815"
},
"callbackAddress": "https://example.com/callback"
}
""";

private static final String REQUEST_INITIAL_ID = """
{
"@context": [
"https://w3id.org/dspace/2025/1/context.jsonld"
],
"@type": "ContractRequestMessage",
"consumerPid": "urn:uuid:32541fe6-c580-409e-85a8-8a9a32fbe833",
"offer": {
"@id": "urn:uuid:d526561f-528e-4d5a-ae12-9a9dd9b7a815"
},
"callbackAddress": "https://example.com/callback"
}
""";
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class InvalidContractRequestMessageSchemaTest extends AbstractSchemaTest
@Test
void verifyInvalidCases() {
assertThat(schema.validate(INVALID_REQUEST_NO_OFFER, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_REQUEST_NO_ID, JSON).iterator().next().getType()).isEqualTo(ONE_OF);
assertThat(schema.validate(INVALID_REQUEST_NO_ID, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_REQUEST_NO_CONSUMER_ID, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_REQUEST_NO_CALLBACK, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_REQUEST_NO_TYPE, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_REQUEST_NO_CONTEXT, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
assertThat(schema.validate(INVALID_REQUEST_JUST_ID, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
}

@BeforeEach
Expand Down Expand Up @@ -113,4 +114,19 @@ void setUp() {
"callbackAddress": "https://example.com/callback"
}
""";

private static final String INVALID_REQUEST_JUST_ID = """
{
"@context": [
"https://w3id.org/dspace/2025/1/context.jsonld"
],
"@type": "ContractRequestMessage",
"providerPid": "urn:uuid:a343fcbf-99fc-4ce8-8e9b-148c97605aab",
"consumerPid": "urn:uuid:32541fe6-c580-409e-85a8-8a9a32fbe833",
"offer": {
"@id": "urn:uuid:d526561f-528e-4d5a-ae12-9a9dd9b7a815"
},
"callbackAddress": "https://example.com/callback"
}
""";
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ to `negotiations/request`:
<aside class="example" title="Contract Request">
<pre class="http">POST https://provider.com/negotiations/request
Authorization: ...</pre>
<pre class="json" data-include="message/example/contract-request-message.json">
<pre class="json" data-include="message/example/contract-request-message_initial.json">
</pre>
</aside>

Expand Down Expand Up @@ -252,7 +252,7 @@ a [Contract Offer Message](#contract-offer-message) to `negotiations/offers`:
<aside class="example" title="Contract Offer Request">
<pre class="http">POST https://consumer.com/negotiations/offers
Authorization: ...</pre>
<pre class="json" data-include="message/example/contract-offer-message.json">
<pre class="json" data-include="message/example/contract-offer-message_initial.json">
</pre>
</aside>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ a [Contract Offer Message](#contract-offer-message) sent by a [=Provider=].
an appropriate `providerPid`.
- An `offer.@id` will generally refer to an [=Offer=] contained in a [=Catalog=]. If the [=Provider=] is not aware of
the `offer.@id` value, it must respond with an error message.
- `offer.obligation` and `offer.permission` signify the terms at which a [=Consumer=] would accept an [=Offer=].
- The `callbackAddress` is a URL indicating where messages to the [=Consumer=] should be sent in asynchronous settings.
If the address is not understood, the [=Provider=] MUST return an UNRECOVERABLE error.
- Different to a [=Catalog=] or [=Dataset=], the [=Offer=] inside
Expand Down
Loading