application/jrd+json¶
This page tests the application/jrd+json schema using python and doctests.
Some convenience methods are included from tools.
>>> from jsonschema import validate
>>> from tools import load_schema, dump
>>> from tools.application_jrd_json import *
>>> schema = load_schema("application-jrd-json")
Background on the format¶
The application/jrd+json format is defined in RFC 7033 Webfinger.
RFC 7033 in turns reference RFC 6415 Web Host Metadata
for the definition of the format. RFC 6415 delegates the definition further
to the OASIS standard
Extensible Resource Descriptor (XRD) Version 1.0.
Validation of the wild¶
The following examples check that the result of the webfinger request conforms
to schema and has the content type application/jrd+json.
| name | acct_uri | result |
|---|---|---|
| cattle_grid | acct:cow_says_moo@dev.bovine.social | ✅ |
| mitra | acct:weekinfediverse@mitra.social | ✅ |
| mastodon | acct:Mastodon@mastodon.social | ✅ |
| sharkey | acct:julia@eepy.moe | ✅ |
| wordpress | acct:pfefferle@notiz.blog | ✅ |
| piefed | acct:casualconversation@piefed.social | ✅ |
Adding additional applications.¶
This can be done by editing data/webfinger and opening a pull request.
Examples¶
These example are taken from RFC 7033
>>> validate(instance=example1, schema=schema)
>>> validate(instance=example2, schema=schema)
>>> validate(instance=example3, schema=schema)
>>> validate(instance=example4, schema=schema)
Example 1
{
"subject": "acct:carol@example.com",
"links": [
{
"rel": "http://openid.net/specs/connect/1.0/issuer",
"href": "https://openid.example.com"
}
]
}
Example 2
{
"subject": "http://blog.example.com/article/id/314",
"aliases": [
"http://blog.example.com/cool_new_thing",
"http://blog.example.com/steve/article/7"
],
"properties": {
"http://blgx.example.net/ns/version": "1.3",
"http://blgx.example.net/ns/ext": null
},
"links": [
{
"rel": "copyright",
"href": "http://www.example.com/copyright"
},
{
"rel": "author",
"href": "http://blog.example.com/author/steve",
"titles": {
"en-us": "The Magical World of Steve",
"fr": "Le Monde Magique de Steve"
},
"properties": {
"http://example.com/role": "editor"
}
}
]
}
Example 3
{
"subject": "acct:bob@example.com",
"aliases": [
"https://www.example.com/~bob/"
],
"properties": {
"http://example.com/ns/role": "employee"
},
"links": [
{
"rel": "http://webfinger.example/rel/profile-page",
"href": "https://www.example.com/~bob/"
},
{
"rel": "http://webfinger.example/rel/businesscard",
"href": "https://www.example.com/~bob/bob.vcf"
}
]
}
Example 4
{
"subject": "http://blog.example.com/article/id/314",
"expires": "2010-01-30T09:30:00Z",
"aliases": [
"http://blog.example.com/cool_new_thing",
"http://blog.example.com/steve/article/7"
],
"properties": {
"http://blgx.example.net/ns/version": "1.3",
"http://blgx.example.net/ns/ext": null
},
"links": [
{
"rel": "author",
"type": "text/html",
"href": "http://blog.example.com/author/steve",
"titles": {
"default": "About the Author",
"en-us": "Author Information"
},
"properties": {
"http://example.com/role": "editor"
}
},
{
"rel": "author",
"href": "http://example.com/author/john",
"titles": {
"default": "The other author"
}
},
{
"rel": "copyright",
"template": "http://example.com/copyright?id={uri}"
}
]
}
Invalid examples¶
>>> validate(instance=invalid1, schema=schema)
Traceback (most recent call last):
...
jsonschema.exceptions.ValidationError: None is not of type 'object'
Invalid Example 1
{
"subject": "acct:cow_says_moo@dev.bovine.social",
"expires": null,
"aliases": null,
"properties": null,
"links": [
{
"rel": "self",
"type": "application/activity+json",
"href": "https://dev.bovine.social/actor/VPaytKixWivWjbsoo7Fszw",
"titles": null,
"properties": null,
"template": null
}
]
}