Example

Presented below is the Message of the Day Example with the corresponding Smithy and RDF sections side by side for comparison. You can download the Turtle source file as well.

Smithy IDL RDF Representation
1
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix smithy: <https://awslabs.github.io/smithy/rdf-1.0#> .
@prefix api: <urn:smithy:smithy.api:> .
@prefix : <urn:smithy:example.motd:> .
2
$version: "1.0"

namespace example.motd
[]
  a smithy:Model ;
  smithy:smithy_version "1.0" ;
  smithy:shape
    :GetMessageOutput ,
    :Message ,
    :GetMessageInput ,
    :BadDateValue ,
    :GetMessage ,
    :MessageOfTheDay ,
    :Date .
3
@pattern(
  "^\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d$"
)
string Date
:Date
  a smithy:String ;
  smithy:apply [
    smithy:trait api:pattern ;
    smithy:value "^\\d\\d\\d\\d\\-\\d\\d-\\d\\d$"
  ] .
4
resource Message {
   identifiers: {
      date: Date
   }
   read: GetMessage
}
:Message
  a smithy:Resource ;
  smithy:identifiers [
    a rdf:Bag ;
    rdf:_1 [
      smithy:key "date" ;
      smithy:target :Date
    ]
  ] ;
  smithy:read :GetMessage .
5
structure GetMessageInput {
   date: Date
}
:GetMessageInput
  a smithy:Structure ;
  smithy:member [
    a :Date ;
    smithy:name "date"^^xsd:string
  ] .
6
structure GetMessageOutput {
   @required
   message: String
}
:GetMessageOutput
  a smithy:Structure ;
  smithy:member [
    a api:String ;
    smithy:name "message"^^xsd:string ;
    smithy:apply [ smithy:trait api:required ] ;
  ] .
7
@error("client")
structure BadDateValue {
   @required
   errorMessage: String
}
:BadDateValue
  a smithy:Structure ;
  smithy:apply [
    smithy:trait api:error ;
    smithy:value "client"
  ] ;
  smithy:member [
    a api:String ;
    smithy:name "errorMessage"^^xsd:string ;
    smithy:apply [ smithy:trait <urn:smithy:smithy.api:required> ] ;
  ] .
8
@readonly
operation GetMessage {
   input: GetMessageInput
   output: GetMessageInput
   errors: [ BadDateValue ]
}
:GetMessage
  a smithy:Operation ;
  smithy:input :GetMessageInput ;
  smithy:output :GetMessageOutput ;
  smithy:error :BadDateValue .
9
@documentation(
  "Provides a Message of the day."
)
service MessageOfTheDay {
   version: "2020-06-21"
   resources: [ Message ]
}
:MessageOfTheDay
  a smithy:Service ;
  smithy:apply [
    smithy:trait api:documentation ;
    smithy:value "Provides a Message of the day."
  ] ;
  smithy:version "2020-06-21" ;
  smithy:resource :Message .