Debian Codegraph @

demo/kitchen-sink/docs/smithy.smithy

raw
1 namespace example.weather
2
3 /// Provides weather forecasts.
4 @paginated(inputToken: "nextToken", outputToken: "nextToken",
5 pageSize: "pageSize")
6 service Weather {
7 version: "2006-03-01",
8 resources: [City],
9 operations: [GetCurrentTime]
10 }
11
12 resource City {
13 identifiers: { cityId: CityId },
14 read: GetCity,
15 list: ListCities,
16 resources: [Forecast],
17 }
18
19 resource Forecast {
20 identifiers: { cityId: CityId },
21 read: GetForecast,
22 }
23
24 // "pattern" is a trait.
25 @pattern("^[A-Za-z0-9 ]+$")
26 string CityId
27
28 @readonly
29 operation GetCity {
30 input: GetCityInput,
31 output: GetCityOutput,
32 errors: [NoSuchResource]
33 }
34
35 structure GetCityInput {
36 // "cityId" provides the identifier for the resource and
37 // has to be marked as required.
38 @required
39 cityId: CityId
40 }
41
42 structure GetCityOutput {
43 // "required" is used on output to indicate if the service
44 // will always provide a value for the member.
45 @required
46 name: String,
47
48 @required
49 coordinates: CityCoordinates,
50 }
51
52 // This structure is nested within GetCityOutput.
53 structure CityCoordinates {
54 @required
55 latitude: Float,
56
57 @required
58 longitude: Float,
59 }
60
61 // "error" is a trait that is used to specialize
62 // a structure as an error.
63 @error("client")
64 structure NoSuchResource {
65 @required
66 resourceType: String
67 }
68
69 // The paginated trait indicates that the operation may
70 // return truncated results.
71 @readonly
72 @paginated(items: "items")
73 operation ListCities {
74 input: ListCitiesInput,
75 output: ListCitiesOutput
76 }
77
78 structure ListCitiesInput {
79 nextToken: String,
80 pageSize: Integer
81 }
82
83 structure ListCitiesOutput {
84 nextToken: String,
85
86 @required
87 items: CitySummaries,
88 }
89
90 // CitySummaries is a list of CitySummary structures.
91 list CitySummaries {
92 member: CitySummary
93 }
94
95 // CitySummary contains a reference to a City.
96 @references([{resource: City}])
97 structure CitySummary {
98 @required
99 cityId: CityId,
100
101 @required
102 name: String,
103 }
104
105 @readonly
106 operation GetCurrentTime {
107 output: GetCurrentTimeOutput
108 }
109
110 structure GetCurrentTimeOutput {
111 @required
112 time: Timestamp
113 }
114
115 @readonly
116 operation GetForecast {
117 input: GetForecastInput,
118 output: GetForecastOutput
119 }
120
121 // "cityId" provides the only identifier for the resource since
122 // a Forecast doesn't have its own.
123 structure GetForecastInput {
124 @required
125 cityId: CityId,
126 }
127
128 structure GetForecastOutput {
129 chanceOfRain: Float
130 }