Service#

About#

This section will provide information on the service type. This is not one of the main OIH types. However, we will provide guidance here on describing services using schema.org.

It should be noted that this might be a simple link to an OpenAPI or some other descriptor document. Also, schema.org is not rich enough for complex descriptions and itself borrows from the Hydra vocabulary. It may be required to leverage Hydra if complex descriptions are needed.

The graph describes a service than can be invoked with:

curl --data-binary "@yourfile.jpg" -X POST https://us-central1-top-operand-112611.cloudfunctions.net/function-1

This with POST a jpeg to the service and get back a simple text response with some information about the image.

  1{
  2  "@context": {
  3    "@vocab": "https://schema.org/"
  4  },
  5  "@type": "Service",
  6  "@id": "https://example.org/id/XYZ",
  7  "aggregateRating": {
  8    "@type": "https://schema.org/aggregateRating"
  9  },
 10  "areaServed": [
 11    "Text: The geographic area where the service is provided.",
 12    {
 13      "@type": "https://schema.org/Place"
 14    },
 15    {
 16      "@type": "https://schema.org/GeoShape"
 17    },
 18    {
 19      "@type": "https://schema.org/AdministrativeArea"
 20    }
 21  ],
 22  "audience": {
 23    "@type": "https://schema.org/Audience"
 24  },
 25  "availableChannel": {
 26    "@type": "https://schema.org/ServiceChannel"
 27  },
 28  "award": "Text: An award won by or for this service.",
 29  "brand": [
 30    "Text: The brand(s) associated with the service, or the brand(s) maintained by an organization or business person.",
 31    {
 32      "@type": "https://schema.org/Brand"
 33    },
 34    {
 35      "@type": "https://schema.org/Organization"
 36    }
 37  ],
 38  "broker": [
 39    {
 40      "@type": "https://schema.org/Person"
 41    },
 42    {
 43      "@type": "https://schema.org/Organization"
 44    }
 45  ],
 46  "category": [
 47    "Text: A category for the service.",
 48    "URL",
 49    {
 50      "@type": "https://schema.org/CategoryCode"
 51    },
 52    {
 53      "@type": "https://schema.org/PhysicalActivityCategory"
 54    },
 55    {
 56      "@type": "https://schema.org/Thing"
 57    }
 58  ],
 59  "hasOfferCatalog": "https://schema.org/OfferCatalog",
 60  "hoursAvailable": "https://schema.org/OpeningHoursSpecification",
 61  "isRelatedTo": [
 62    {
 63      "@type": "https://schema.org/Product"
 64    },
 65    {
 66      "@type": "https://schema.org/Service"
 67    }
 68  ],
 69  "isSimilarTo": [
 70    {
 71      "@type": "https://schema.org/Product"
 72    },
 73    {
 74      "@type": "https://schema.org/Service"
 75    }
 76  ],
 77  "logo": [
 78    {
 79      "@type": "https://schema.org/ImageObject"
 80    },
 81    "URL"
 82  ],
 83  "offers": [
 84    {
 85      "@type": "https://schema.org/Demand"
 86    },
 87    {
 88      "@type": "https://schema.org/Offer"
 89    }
 90  ],
 91  "provider": [
 92    "Text: The service provider, service operator, or service performer; the goods producer. Another party (a seller) may offer those services or goods on behalf of the provider.",
 93    {
 94      "@type": "https://schema.org/Person"
 95    },
 96    {
 97      "@type": "https://schema.org/Organization"
 98    }
 99  ],
100  "providerMobility": "Text: Indicates the mobility of a provided service (e.g. 'static', 'dynamic').",
101  "review": {
102    "@type": "https://schema.org/Review"
103  },
104  "serviceOutput": {
105    "@type": "https://schema.org/Thing"
106  },
107  "serviceType": [
108    "Text: Human-readable terms of service documentation",
109    {
110      "@type": "https://schema.org/GovernmentBenefitsType"
111    }
112  ],
113  "slogan": "Text: A slogan or motto associated with the item.",
114  "termsOfService": [
115    "Text: Human-readable terms of service documentation",
116    {
117      "@type": "https://schema.org/Url"
118    }
119  ],
120  "additionalType": [
121    "Text: An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax.",
122    "URL"
123  ],
124  "alternateName": "Text: An alternative name for this Thing.",
125  "description": "Text: Free text which describes this Thing.",
126  "disambiguatingDescription": "Text: A sub property of description. A short description of the item used to disambiguate from other, similar items. Information from other properties (in particular, name) may be necessary for the description to be useful for disambiguation",
127  "identifier": [
128    {
129      "@type": "https://schema.org/PropertyValue"
130    },
131    "Text - The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See background notes for more details.",
132    "URL"
133  ],
134  "image": [
135    "URL",
136    {
137      "@type": "https://schema.org/ImageObject"
138    }
139  ],
140  "mainEntityOfPage": [
141    "URL",
142    {
143      "@type": "https://schema.org/CreativeWork"
144    }
145  ],
146  "name": "Text: The name of the item.",
147  "potentialAction": {
148    "@type": "https://schema.org/Action"
149  },
150  "sameAs": "URL",
151  "subjectOf": "URL",
152  "url": "URL - the URL to the item described by this JSON-LD document"
153}
Hide code cell source
import json
from pyld import jsonld
import os, sys

currentdir = os.path.dirname(os.path.abspath(''))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from lib import jbutils

with open("../../../odis-in/dataGraphs/thematics/services/graphs/serviceBase.json") as dgraph:
    doc = json.load(dgraph)

context = {
    "@vocab": "https://schema.org/",
}

compacted = jsonld.compact(doc, context)
jbutils.show_graph(compacted)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/tmp/ipykernel_3639/3126244140.py in <module>
     16 
     17 compacted = jsonld.compact(doc, context)
---> 18 jbutils.show_graph(compacted)

~/work/odis-arch/odis-arch/book/lib/jbutils.py in show_graph(doc, size)
     44     for edge in rdf:
     45         subj = short_name(edge['subject'])
---> 46         obj = short_name(edge['object'])
     47         pred = short_name(edge['predicate'])
     48         if subj and obj and pred:

~/work/odis-arch/odis-arch/book/lib/jbutils.py in short_name(value, max_length)
     22             # If the URL is too long, hide it
     23             if len(short_url) > max_length:
---> 24                 pieces = split_uri(short_url)
     25                 return join_uri(pieces[0], '...')
     26             else:

NameError: name 'split_uri' is not defined

References#