Skip to content

Instantly share code, notes, and snippets.

@westurner
Last active December 18, 2015 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westurner/5704379 to your computer and use it in GitHub Desktop.
Save westurner/5704379 to your computer and use it in GitHub Desktop.
Draft 00: HTTP Problem JSON Object --> HTTP Problem RDFS/OWL Ontology in Turtle

ldpnotes

Linked Data Platform notes, ontologies, and resources.

Re: Proposal to close ISSUE-19: Adressing more error cases, as is

Impetus

Interaction Sequence

  1. Client makes HTTP request
  2. HTTP request is routed, balanced, and proxied
  3. HTTP request received by application
  4. Application routes URL to an application function
  5. Application function executes logic across system
  6. System presents complex errors and exceptions
  7. Application catches errors and exceptions
  8. Application returns HTTP Response with Status Code and Body
  9. Client sees "fail whale", wants to know more
  10. Devops and sysops point to CWE-200 and CWE-209 (... 200-215, 550)

Observations

  • At any step in the interaction, Errors or Exceptions may be encountered.
  • Errors and Exceptions are propagated up the stack
  • Exceptions should contain enough information to diagnose the problem
  • Most Proxies, balancers, etc. understand HTTP (some HTML)
  • Why would I need to look up the List of HTTP status codes?
  • HTTP 2?? status codes are not errors or exceptions.
  • What to do when status_code != 200 OK
  • What to do when (status_code not in range(200,300))

Mapping to Existing Ontologies

Mapping to schema.org

A WebApplication SoftwareApplication returns a WebPage (which could be a CollectionPage, a SearchResultsPage, a ...) potentially containing error message metadata.

Beyond that, there is currently no notion of HTTP or an Error message in schema.org. http://www.w3.org/wiki/WebSchemas/SchemaDotOrgProposals

Mapping to HTTP-in-RDF

http://w3.org/TR/HTTP-in-RDF/

It would be convenient if http:httpStatusCode etc had an rdfs:domain of rdfs:Resource and/or prob:Problem and/or prob:ProblemType were just http:Responses.

References

#### http-problem.ttl
# a conversion of the HTTP Problem JSON schema defined at
# https://tools.ietf.org/html/draft-nottingham-http-problem-04
# to RDFS/OWL in Turtle.
#
# Changelog
# -----------
#
# 2013-06-05 -- Draft 01
#
# * Updated ``rdfs:isDefinedBy`` properties
# * Updated example ``dct:hasFormat`` values
# * Updated ``ex:accounts`` value
# * Added normative references
# * Added extensively unscoped documentation regarding the domain
#
# 2013-06-04 -- Draft 00
#
# * Manually generated (rough) Turtle OWL Ontology.
#
### <ontology>
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix dct: <http://purl.org/dc/terms/>.
@prefix http: <http://www.w3.org/TR/HTTP-in-RDF/>.
@prefix httpsc: <http://www.w3.org/2011/http-statusCodes#>.
@prefix prob: <http://example.org/ns/prob#>.
@prefix ex: <http://example.org/ns/example#>.
<http://example.org/ns/prob> a owl:Ontology;
dct:title "The Problem Details JSON terms in RDFS+OWL"@en;
dct:description "This is a conversion of the terms defined at https://tools.ietf.org/html/draft-nottingham-http-problem-04 to RDFS and OWL."@en;
foaf:page <https://tools.ietf.org/html/draft-nottingham-http-problem-04>;
rdfs:seeAlso <http://www.w3.org/TR/HTTP-in-RDF/>;
dct:hasFormat <http://example.org/ns/prob.ttl>;
dct:hasFormat <http://example.org/ns/prob.rdf>;
dct:hasFormat <http://example.org/ns/prob.nt>;
dct:hasFormat <http://example.org/ns/prob.xml>;
dct:hasFormat <http://example.org/ns/prob.json>;
dct:hasFormat <http://example.org/ns/prob.jsonld>;
dct:source <https://tools.ietf.org/html/draft-nottingham-http-problem-04>;
dct:license <https://tools.ietf.org/html/draft-nottingham-http-problem-04>;
#dct:valid "2013-06-04"^^xsd:date;
.
prob:ProblemType a rdfs:Class;
rdfs:label "ProblemType"@en;
rdfs:comment "A type of Problem"@en;
rdfs:isDefinedBy <http://example.org/ns/prob>;
.
prob:Problem a rdfs:Class;
rdfs:label "Problem"@en;
rdfs:comment "An instance of a Problem"@en;
rdfs:isDefinedBy <http://example.org/ns/prob>;
.
prob:problemType a rdf:Property;
rdfs:label "Problem Type"@en;
rdfs:comment "The ProblemType of the Problem"@en;
rdfs:domain prob:Problem;
rdfs:range prob:ProblemType;
rdfs:isDefinedBy <http://example.org/ns/prob>;
.
prob:title a rdf:Property;
rdfs:label "Title"@en;
rdfs:comment "The title of the Problem"@en;
rdfs:domain prob:ProblemType;
rdfs:range xsd:string;
rdfs:isDefinedBy <http://example.org/ns/prob>;
#? ... rdfs:subPropertyOf dct:title;
#? ... rdfs:subPropertyOf rdfs:label;
.
prob:detail a rdf:Property;
rdfs:label "Problem Detail"@en;
rdfs:comment "The details of the problem"@en;
rdfs:domain [ a owl:Class; owl:UnionOf (prob:ProblemType prob:Problem) ];
rdfs:range xsd:string;
rdfs:isDefinedBy <http://example.org/ns/prob>;
#? ... rdfs:subPropertyOf http:reasonPhrase;
.
prob:httpStatus a rdf:Property;
rdfs:label "HTTP Status Code"@en;
rdfs:comment "The type of the problem"@en;
rdfs:domain prob:ProblemType;
rdfs:range xsd:integer;
rdfs:isDefinedBy <http://example.org/ns/prob>;
#? ... rdfs:subPropertyOf http:statusCodeValue; ?
.
#</ontology>
#<resources>
### Example: HTTP Error 418
<http://example.org/error/418> a prob:ProblemType;
rdfs:isDefinedBy <>;
prob:title "This is a 418 error"@en;
prob:detail "I am a teapot"@en;
prob:httpStatus 418;
#? a http:Response;
#? a httpsc:StatusCode4xx;
#? dct:title "This is a 418 error"@en;
#? rdfs:label "This is a 418 error"@en;
#? http:statusCodeValue 418;
#? http:reasonPhrase "I am a teapot"@en;
.
<http://example.org/errors/id/xyz123> a prob:Problem;
prob:problemType <http://example.org/error/418>;
prob:detail "I am a special teapot."@en;
.
### conversion of current example
# HTTP/1.1 403 Forbidden
# Content-Type: application/api-problem+json
# Content-Language: en
#
# {
# "problemType": "http://example.com/probs/out-of-credit",
# "title": "You do not have enough credit.",
# "detail": "Your current balance is 30, but that costs 50.",
# "problemInstance": "http://example.net/account/12345/msgs/abc",
# "balance": 30,
# "accounts": ["http://example.net/account/12345",
# "http://example.net/account/67890"]
# }
<http://example.com/probs/out-of-credit> a prob:ProblemType;
prob:title "You do not have enough credit"@en;
prob:httpStatus 403;
.
<http://example.com/account/12345/msgs/abc> a prob:Problem;
prob:problemType <http://example.com/probs/out-of-credit>;
prob:detail "Your current balance is 30, but that costs 50"@en;
ex:balance 30;
ex:accounts (
<http://example.net/account/12345>
<http://example.net/account/67890> );
.
#</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment