Skip to content

Update language around the defined types and their usages #186

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

Merged
merged 7 commits into from
Jul 31, 2023

Conversation

decentralgabe
Copy link
Collaborator

@decentralgabe decentralgabe commented Jul 25, 2023

Fix #172 #178

I believe this needs a change to the core vocab to add a new property jsonSchema with the type as @json


Preview | Diff

@decentralgabe
Copy link
Collaborator Author

As discussed on the call today I've updated CredentialSchema2023 to make use of a new property in a VC, jsonSchema instead of the credentialSubject.

My understanding -- and please correct me otherwise -- is that to make this work in LD-land there needs to be a definition in a context file that adds a property to VerifiableCredential such as:

 "jsonSchema": {
  "id": "https://www.w3.org/TR/vc-json-schema#jsonSchema"
  "type": "@json"
}

which should go here.

But it seems like then the data model would need some text on the jsonSchema property.

I would like to avoid this specification shipping its own context which will then need to be included with each VC that intends to use this specification....is there another way to accomplish this? @msporny @OR13

index.html Outdated
@@ -301,7 +322,7 @@ <h3>VerifiableCredentialSchema2023</h3>
"type": ["VerifiableCredential", "VerifiableCredentialSchema2023"],
"issuer": "https://example.com/issuers/14",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"jsonSchema": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 to this approach.

The credentialSubject property is required in the VCDM, so removing results in an object that isn't a VC.

As an alternative, I suggest taking the same approach as the one taken in StatusList2021Credential. That is, make credentialSubject.type mandatory. An example of my suggestion below. This would make the vc graph much more palatable, and I believe this uses the more typical JSON-LD patterns.

{
  "@context": [
      "https://www.w3.org/ns/credentials/v2",
      "https://www.w3.org/ns/credentials/examples/v2"
  ],
  "id": "https://example.com/credentials/3734",
  "type": ["VerifiableCredential", "VerifiableCredentialSchema2023"],
  "issuer": "https://example.com/issuers/14",
  "issuanceDate": "2010-01-01T19:23:24Z",
  "credentialSubject": {
    "id": "https://example.com/credentials/schema/12",
    "type": "JsonSchema2023",
    "jsonSchema": {
      "$id": "https://example.com/schemas/email-credential-schema.json",
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "name": "EmailCredential",
      "description": "EmailCredential using VerifiableCredentialSchema2023",
      "type": "object",
      "properties": {
        "credentialSubject": {
          "type": "object",
          "properties": {
            "emailAddress": {
              "type": "string",
              "format": "email"
            }
          },
          "required": ["emailAddress"]
        }
      }
    }
  }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to what @andresuribe87 said above. That's a better way to do it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great suggestion! thank you

@msporny
Copy link
Member

msporny commented Jul 25, 2023

As discussed on the call today I've updated CredentialSchema2023 to make use of a new property in a VC, jsonSchema instead of the credentialSubject.

@andresuribe87 proposes something cleaner above.

Given @andresuribe87 example... you're probably better off renaming VerifiableCredentialSchema2023 to JsonSchemaCredential... that would bring it almost entirely inline w/ a bog standard VC.

My understanding -- and please correct me otherwise -- is that to make this work in LD-land there needs to be a definition in a context file that adds a property to VerifiableCredential such as:

I expect that might get push back from the WG. I suggest that @andresuribe87's approach is a better design.

But it seems like then the data model would need some text on the jsonSchema property.

No, the vocabulary could just point to your JSON Schema spec... we wouldn't need to document anything in vc-data-model.

I would like to avoid this specification shipping its own context which will then need to be included with each VC that intends to use this specification....is there another way to accomplish this?

Yes, put your definition in the core VC context (so you don't need to ship your own vocabulary/context), triggered by type... so, something like this:

    "JsonSchemaCredential": "https://www.w3.org/2018/credentials#JsonSchemaCredential",
    "JsonSchema": {
      "@id": "https://www.w3.org/2018/credentials#JsonSchema", <-- ideally, this would be defined by the JSON Schema community, not us.
      "@context": {
        "@protected": true,

        "id": "@id",
        "type": "@type",

         "jsonSchema": {
           "id": "https://www.w3.org/2018/credentials#jsonSchema" <-- ideally, this would be defined by the JSON Schema community, not us.
           "type": "@json"
       }
    },

Then your example becomes:

{
  "@context": [
      "https://www.w3.org/ns/credentials/v2",
      "https://www.w3.org/ns/credentials/examples/v2"
  ],
  "id": "https://example.com/credentials/3734",
  "type": ["VerifiableCredential", "JsonSchemaCredential"],
  "issuer": "https://example.com/issuers/14",
  "validFrom": "2023-01-01T19:23:24Z",
  "credentialSubject": {
    "id": "https://example.com/credentials/schema/12",
    "type": "JsonSchema",
    "jsonSchema": {
      "$id": "https://example.com/schemas/email-credential-schema.json",
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "name": "EmailCredential",
      "description": "EmailCredential using VerifiableCredentialSchema2023",
      "type": "object",
      "properties": {
        "credentialSubject": {
          "type": "object",
          "properties": {
            "emailAddress": {
              "type": "string",
              "format": "email"
            }
          },
          "required": ["emailAddress"]
        }
      }
    }
  }
}

@decentralgabe
Copy link
Collaborator Author

thank you @andresuribe87 @msporny I've updated the PR with your suggestions. I also included the term definition for jsonSchema here (which I think is better than no where) until it can be defined by the json schema org itself.

Follow-up PR for the VCDM w3c/vc-data-model#1215

@iherman
Copy link
Member

iherman commented Jul 26, 2023

Once merged, not only the @context must be changed but the credential vocabulary must be updated as well. I am happy to make the change when the time comes, though I would prefer to do that after w3c/vc-data-model#1209 is finalized and merged.

Co-authored-by: Manu Sporny <msporny@digitalbazaar.com>
@decentralgabe
Copy link
Collaborator Author

thanks @iherman I'm happy to transfer ownership of w3c/vc-data-model#1215 to you after this and 1209 are merged

@decentralgabe
Copy link
Collaborator Author

@msporny @OR13 @andresuribe87 please take a look and see if you're ready to approve

}
}
</pre>
</p>
<p>
<p>
Upon dereferencing the value of the <code>id</code> <code>https://example.com/credentials/3734</code>,
a process also be referred to as <a>schema resolution</a>, the following verifiable credential,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call out the schema resolution as a separate process? Isn't it a simple URL fetch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is but it's a necessary step in using the spec, so it can be given a name which would be useful in enumerating the steps to process like

  1. get credential
  2. perform schema resolution
  3. evaluate schema against credential

@decentralgabe decentralgabe merged commit 157d68e into main Jul 31, 2023
@decentralgabe decentralgabe deleted the issue-172-178 branch July 31, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

What is the difference between JsonSchema2023 and CredentialSchema2023?
5 participants