diff --git a/artifacts/src/main/resources/issuance/credential-message-schema.json b/artifacts/src/main/resources/issuance/credential-message-schema.json index ea4ec4a..df0d710 100644 --- a/artifacts/src/main/resources/issuance/credential-message-schema.json +++ b/artifacts/src/main/resources/issuance/credential-message-schema.json @@ -23,34 +23,15 @@ }, "requestId": { "type": "string" - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "CredentialMessage" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "CredentialMessage" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "CredentialMessage" } - ], + }, "required": [ "@context", + "type", "credentials", "requestId" ] @@ -62,34 +43,15 @@ "type": [ "string" ] - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "CredentialContainer" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "CredentialContainer" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "CredentialContainer" } - ], + }, "required": [ - "payload" + "payload", + "type" ] } } diff --git a/artifacts/src/main/resources/issuance/credential-object-schema.json b/artifacts/src/main/resources/issuance/credential-object-schema.json index 8baf38b..41d8e88 100644 --- a/artifacts/src/main/resources/issuance/credential-object-schema.json +++ b/artifacts/src/main/resources/issuance/credential-object-schema.json @@ -36,38 +36,19 @@ "issuancePolicy": { "type": "object", "$ref": "https://identity.foundation/presentation-exchange/schemas/presentation-definition.json" - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "CredentialObject" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "CredentialObject" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "CredentialObject" } - ], + }, "required": [ "credentialType", "offerReason", "bindingMethods", "cryptography", - "issuancePolicy" + "issuancePolicy", + "type" ] } } diff --git a/artifacts/src/main/resources/issuance/credential-offer-message-schema.json b/artifacts/src/main/resources/issuance/credential-offer-message-schema.json index b146e2c..4e10ee7 100644 --- a/artifacts/src/main/resources/issuance/credential-offer-message-schema.json +++ b/artifacts/src/main/resources/issuance/credential-offer-message-schema.json @@ -23,36 +23,17 @@ "items": { "$ref": "https://w3id.org/dspace-dcp/v0.8/issuance/credential-object-schema.json#/definitions/CredentialObject" } - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "CredentialOfferMessage" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "CredentialOfferMessage" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "CredentialOfferMessage" } - ], + }, "required": [ "@context", "credentialIssuer", - "credentials" + "credentials", + "type" ] } } diff --git a/artifacts/src/main/resources/issuance/credential-request-message-schema.json b/artifacts/src/main/resources/issuance/credential-request-message-schema.json index adc8895..82ac6e7 100644 --- a/artifacts/src/main/resources/issuance/credential-request-message-schema.json +++ b/artifacts/src/main/resources/issuance/credential-request-message-schema.json @@ -23,34 +23,15 @@ "items": { "type": "string" } - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "CredentialRequestMessage" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "CredentialRequestMessage" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "CredentialRequestMessage" } - ], + }, "required": [ "@context", + "type", "format", "credentialType" ] diff --git a/artifacts/src/main/resources/issuance/credential-status-schema.json b/artifacts/src/main/resources/issuance/credential-status-schema.json index be6d578..ded99f6 100644 --- a/artifacts/src/main/resources/issuance/credential-status-schema.json +++ b/artifacts/src/main/resources/issuance/credential-status-schema.json @@ -22,35 +22,16 @@ "REJECTED", "ISSUED" ] - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "CredentialStatus" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "CredentialStatus" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "CredentialStatus" } - ], + }, "required": [ "requestId", - "status" + "status", + "type" ] }, "CredentialStatus": { diff --git a/artifacts/src/main/resources/issuance/issuer-metadata-schema.json b/artifacts/src/main/resources/issuance/issuer-metadata-schema.json index 83b9f46..d235fdd 100644 --- a/artifacts/src/main/resources/issuance/issuer-metadata-schema.json +++ b/artifacts/src/main/resources/issuance/issuer-metadata-schema.json @@ -20,36 +20,17 @@ "items": { "$ref": "https://w3id.org/dspace-dcp/v0.8/issuance/credential-object-schema.json#/definitions/CredentialObject" } - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "IssuerMetadata" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "IssuerMetadata" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "IssuerMetadata" } - ], + }, "required": [ "@context", "credentialIssuer", - "credentialsSupported" + "credentialsSupported", + "type" ] } } 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 ea1180d..b0d8a95 100644 --- a/artifacts/src/main/resources/presentation/presentation-query-message-schema.json +++ b/artifacts/src/main/resources/presentation/presentation-query-message-schema.json @@ -14,6 +14,10 @@ "properties": { "@context": { "$ref": "https://w3id.org/dspace-dcp/v0.8/common/context-schema.json" + }, + "type": { + "type": "string", + "const": "PresentationQueryMessage" } }, "allOf": [ @@ -44,36 +48,11 @@ ] } ] - }, - { - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "PresentationQueryMessage" - } - }, - "required": [ - "@type" - ] - }, - { - "properties": { - "type": { - "type": "string", - "const": "PresentationQueryMessage" - } - }, - "required": [ - "type" - ] - } - ] } ], "required": [ - "@context" + "@context", + "type" ] } } diff --git a/artifacts/src/main/resources/presentation/presentation-response-message-schema.json b/artifacts/src/main/resources/presentation/presentation-response-message-schema.json index d7e9e30..098c638 100644 --- a/artifacts/src/main/resources/presentation/presentation-response-message-schema.json +++ b/artifacts/src/main/resources/presentation/presentation-response-message-schema.json @@ -23,34 +23,15 @@ "string" ] } - } - }, - "oneOf": [ - { - "properties": { - "@type": { - "type": "string", - "const": "PresentationResponseMessage" - } - }, - "required": [ - "@type" - ] }, - { - "properties": { - "type": { - "type": "string", - "const": "PresentationResponseMessage" - } - }, - "required": [ - "type" - ] + "type": { + "type": "string", + "const": "PresentationResponseMessage" } - ], + }, "required": [ "@context", + "type", "presentation" ] } diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialMessageSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialMessageSchemaTest.java index 7c7ef31..0fd11f8 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialMessageSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialMessageSchemaTest.java @@ -28,10 +28,10 @@ public class CredentialMessageSchemaTest extends AbstractSchemaTest { "@context": [ "https://w3id.org/dspace-dcp/v0.8" ], - "@type": "CredentialMessage", + "type": "CredentialMessage", "credentials": [ { - "@type": "CredentialContainer", + "type": "CredentialContainer", "payload": "jwt" } ], @@ -41,16 +41,16 @@ public class CredentialMessageSchemaTest extends AbstractSchemaTest { private static final String INVALID_CREDENTIAL_MESSAGE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialMessage" + "type": "CredentialMessage" }"""; private static final String INVALID_CREDENTIAL_MESSAGE_INVALID_CREDENTIAL_CONTAINER = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialMessage", + "type": "CredentialMessage", "credentials": [ { - "@type": "CredentialContainer" + "type": "CredentialContainer" } ], "requestId": "requestId" @@ -61,7 +61,7 @@ public class CredentialMessageSchemaTest extends AbstractSchemaTest { { "credentials": [ { - "@type": "CredentialContainer", + "type": "CredentialContainer", "payload": "jwt" } ], @@ -80,9 +80,9 @@ void verifySchema() { .containsExactly(error("payload", REQUIRED)); assertThat(schema.validate(INVALID_CREDENTIAL_MESSAGE_NO_TYPE_AND_CONTEXT, JSON)) - .hasSize(4) + .hasSize(2) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED), error("@context", REQUIRED)); + .contains(error("type", REQUIRED), error("@context", REQUIRED)); } @BeforeEach diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialObjectSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialObjectSchemaTest.java index 73bbac9..a6657b4 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialObjectSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialObjectSchemaTest.java @@ -25,8 +25,7 @@ public class CredentialObjectSchemaTest extends AbstractSchemaTest { public static final String CREDENTIAL_OBJECT = """ { - "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialObject", + "type": "CredentialObject", "credentialType": ["VerifiableCredential"], "offerReason": "reissue", "bindingMethods": [ @@ -61,8 +60,7 @@ public class CredentialObjectSchemaTest extends AbstractSchemaTest { private static final String INVALID_CREDENTIAL_OBJECT = """ { - "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialObject" + "type": "CredentialObject" }"""; private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT = """ @@ -110,9 +108,9 @@ void verifySchema() { error("issuancePolicy", REQUIRED)); assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT, JSON)) - .hasSize(3) + .hasSize(1) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED)); + .contains(error("type", REQUIRED)); } diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialOfferMessageSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialOfferMessageSchemaTest.java index 7cdabab..2f8cede 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialOfferMessageSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialOfferMessageSchemaTest.java @@ -27,7 +27,7 @@ public class CredentialOfferMessageSchemaTest extends AbstractSchemaTest { private static final String CREDENTIAL_OFFER_MESSAGE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialOfferMessage", + "type": "CredentialOfferMessage", "credentialIssuer": "issuer", "credentials": [%s] }"""; @@ -35,14 +35,14 @@ public class CredentialOfferMessageSchemaTest extends AbstractSchemaTest { private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_CREDENTIAL_ISSUER = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialOfferMessage", + "type": "CredentialOfferMessage", "credentials": [%s] }"""; private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_CREDENTIALS = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialOfferMessage", + "type": "CredentialOfferMessage", "credentialIssuer": "issuer" }"""; @@ -66,9 +66,9 @@ void verifySchema() { .containsExactly(error("credentials", REQUIRED)); assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT.formatted(CREDENTIAL_OBJECT), JSON)) - .hasSize(4) + .hasSize(2) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED), error("@context", REQUIRED)); + .contains(error("type", REQUIRED), error("@context", REQUIRED)); } diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialRequestMessageSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialRequestMessageSchemaTest.java index 650604a..afd66bb 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialRequestMessageSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialRequestMessageSchemaTest.java @@ -26,7 +26,7 @@ public class CredentialRequestMessageSchemaTest extends AbstractSchemaTest { private static final String CREDENTIAL_REQUEST_MESSAGE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialRequestMessage", + "type": "CredentialRequestMessage", "format": "jwt", "credentialType": ["VerifiableCredential"] }"""; @@ -34,14 +34,14 @@ public class CredentialRequestMessageSchemaTest extends AbstractSchemaTest { private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_FORMAT = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialRequestMessage", + "type": "CredentialRequestMessage", "credentialType": ["VerifiableCredential"] }"""; private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_CREDENTIAL_TYPE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialRequestMessage", + "type": "CredentialRequestMessage", "format": "jwt" }"""; @@ -64,9 +64,9 @@ void verifySchema() { .containsExactly(error("credentialType", REQUIRED)); assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT, JSON)) - .hasSize(4) + .hasSize(2) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED), error("@context", REQUIRED)); + .contains(error("type", REQUIRED), error("@context", REQUIRED)); } diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialStatusSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialStatusSchemaTest.java index a485411..4d3d954 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialStatusSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialStatusSchemaTest.java @@ -28,7 +28,7 @@ public class CredentialStatusSchemaTest extends AbstractSchemaTest { private static final String CREDENTIAL_STATUS = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialStatus", + "type": "CredentialStatus", "requestId": "requestId", "status": "%s" }"""; @@ -36,7 +36,7 @@ public class CredentialStatusSchemaTest extends AbstractSchemaTest { private static final String INVALID_CREDENTIAL_STATUS = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "CredentialStatus" + "type": "CredentialStatus" }"""; private static final String INVALID_CREDENTIAL_STATUS_MESSAGE_NO_TYPE_AND_CONTEXT = """ @@ -55,9 +55,9 @@ void verifySchema() { .containsExactly(error("requestId", REQUIRED), error("status", REQUIRED)); assertThat(schema.validate(INVALID_CREDENTIAL_STATUS_MESSAGE_NO_TYPE_AND_CONTEXT, JSON)) - .hasSize(4) + .hasSize(2) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED), error("@context", REQUIRED)); + .contains(error("type", REQUIRED), error("@context", REQUIRED)); } @ParameterizedTest diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/IssuerMetadataSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/IssuerMetadataSchemaTest.java index 9cf03ca..122c3cd 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/IssuerMetadataSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/issuance/IssuerMetadataSchemaTest.java @@ -27,7 +27,7 @@ public class IssuerMetadataSchemaTest extends AbstractSchemaTest { public static final String ISSUER_METADATA = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "IssuerMetadata", + "type": "IssuerMetadata", "credentialIssuer": "did:web:issuer-url", "credentialsSupported": [%s] }"""; @@ -35,7 +35,7 @@ public class IssuerMetadataSchemaTest extends AbstractSchemaTest { private static final String INVALID_ISSUER_METADATA = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "IssuerMetadata" + "type": "IssuerMetadata" }"""; private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT = """ @@ -52,9 +52,9 @@ void verifySchema() { .containsExactly(error("credentialIssuer", REQUIRED), error("credentialsSupported", REQUIRED)); assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT.formatted(CREDENTIAL_OBJECT), JSON)) - .hasSize(4) + .hasSize(2) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED), error("@context", REQUIRED)); + .contains(error("type", REQUIRED), error("@context", REQUIRED)); } @BeforeEach 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 c465684..fb588e7 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 @@ -26,14 +26,14 @@ public class PresentationQueryMessageSchemaTest extends AbstractSchemaTest { private static final String PRESENTATION_QUERY_MESSAGE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "PresentationQueryMessage", + "type": "PresentationQueryMessage", "scope": ["scope1", "scope2"] }"""; private static final String PRESENTATION_QUERY_MESSAGE_WITH_PRESENTATION_DEF = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "PresentationQueryMessage", + "type": "PresentationQueryMessage", "presentationDefinition": { "id": "presentation1", "input_descriptors": [ @@ -67,7 +67,7 @@ public class PresentationQueryMessageSchemaTest extends AbstractSchemaTest { private static final String INVALID_PRESENTATION_QUERY_MESSAGE_NO_SCOPE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "PresentationQueryMessage" + "type": "PresentationQueryMessage" }"""; @@ -87,9 +87,9 @@ void verifySchema() { assertThat(schema.validate(INVALID_PRESENTATION_QUERY_MESSAGE_NO_TYPE_AND_CONTEXT, JSON)) - .hasSize(4) + .hasSize(2) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED), error("@context", REQUIRED)); + .contains(error("type", REQUIRED), error("@context", REQUIRED)); } @BeforeEach diff --git a/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationResponseMessageSchemaTest.java b/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationResponseMessageSchemaTest.java index 8a8572e..ed2edad 100644 --- a/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationResponseMessageSchemaTest.java +++ b/artifacts/src/test/java/org/eclipse/dcp/schema/presentation/PresentationResponseMessageSchemaTest.java @@ -26,21 +26,21 @@ public class PresentationResponseMessageSchemaTest extends AbstractSchemaTest { private static final String PRESENTATION_RESPONSE_MESSAGE = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "PresentationResponseMessage", + "type": "PresentationResponseMessage", "presentation": ["presentation1", "presentation2"] }"""; private static final String PRESENTATION_RESPONSE_MESSAGE_WITH_OBJECT = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "PresentationResponseMessage", + "type": "PresentationResponseMessage", "presentation": ["presentation1", {"@id": "presentation2"}] }"""; private static final String INVALID_PRESENTATION_RESPONSE_MESSAGE_NO_PRESENTATION = """ { "@context": ["https://w3id.org/dspace-dcp/v0.8"], - "@type": "PresentationResponseMessage" + "type": "PresentationResponseMessage" }"""; private static final String INVALID_PRESENTATION_RESPONSE_MESSAGE_NO_TYPE_AND_CONTEXT = """ @@ -57,9 +57,9 @@ void verifySchema() { .containsExactly(error("presentation", REQUIRED)); assertThat(schema.validate(INVALID_PRESENTATION_RESPONSE_MESSAGE_NO_TYPE_AND_CONTEXT, JSON)) - .hasSize(4) + .hasSize(2) .extracting(this::errorExtractor) - .contains(error("type", REQUIRED), error("@type", REQUIRED), error("@context", REQUIRED)); + .contains(error("type", REQUIRED), error("@context", REQUIRED)); } @BeforeEach