Skip to content

Commit 6bcf579

Browse files
Format examples test
1 parent 6576cff commit 6bcf579

File tree

1 file changed

+146
-158
lines changed
  • smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/protocols

1 file changed

+146
-158
lines changed

smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/protocols/examples-test.smithy

Lines changed: 146 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,94 @@ use aws.protocols#restJson1
44

55
@restJson1
66
service Banking {
7-
version: "2022-06-26",
8-
operations: [Deposit, Withdraw]
7+
version: "2022-06-26"
8+
operations: [
9+
Deposit
10+
Withdraw
11+
]
912
}
1013

1114
@idempotent
1215
@http(method: "PUT", uri: "/account/{username}", code: 200)
1316
operation Deposit {
14-
input: DepositInput,
15-
output: DepositOutput,
16-
errors: [InvalidUsername, InvalidAmount]
17+
input := {
18+
@httpHeader("accountNumber")
19+
accountNumber: String
20+
21+
@required
22+
@httpLabel
23+
username: String
24+
25+
@httpQuery("accountHistory")
26+
accountHistory: ExampleList
27+
28+
@httpPayload
29+
depositAmount: String
30+
}
31+
32+
output := {
33+
@httpHeader("username")
34+
username: String
35+
36+
@httpHeader("authenticationResult")
37+
authenticationResult: ExampleList
38+
39+
textMessage: String
40+
41+
emailMessage: String
42+
}
43+
44+
errors: [
45+
InvalidUsername
46+
InvalidAmount
47+
]
1748
}
1849

1950
@idempotent
2051
@http(method: "PATCH", uri: "/account/withdraw", code: 200)
2152
operation Withdraw {
22-
input: WithdrawInput,
23-
output: WithdrawOutput,
24-
errors: [InvalidUsername]
25-
}
53+
input := {
54+
@httpHeader("accountNumber")
55+
accountNumber: String
2656

27-
@input
28-
structure DepositInput {
29-
@httpHeader("accountNumber")
30-
accountNumber: String,
57+
@httpHeader("username")
58+
username: String
3159

32-
@required
33-
@httpLabel
34-
username: String,
60+
@httpQueryParams
61+
withdrawParams: ExampleMap
3562

36-
@httpQuery("accountHistory")
37-
accountHistory: ExampleList,
63+
time: date
3864

39-
@httpPayload
40-
depositAmount: String
41-
}
65+
withdrawAmount: String
66+
67+
withdrawOption: String
68+
}
4269

43-
@input
44-
structure WithdrawInput {
45-
@httpHeader("accountNumber")
46-
accountNumber: String,
70+
output := {
71+
@httpHeader("branch")
72+
branch: String
4773

48-
@httpHeader("username")
49-
username: String,
74+
@httpHeader("result")
75+
accountHistory: ExampleList
5076

51-
@httpQueryParams()
52-
withdrawParams: ExampleMap,
77+
location: String
5378

54-
time: date,
55-
withdrawAmount: String,
56-
withdrawOption: String
79+
bankName: String
80+
81+
atmRecording: exampleVideo
82+
}
83+
84+
errors: [
85+
InvalidUsername
86+
]
5787
}
5888

5989
list ExampleList {
6090
member: String
6191
}
6292

6393
map ExampleMap {
64-
key: String,
94+
key: String
6595
value: String
6696
}
6797

@@ -71,143 +101,101 @@ blob exampleVideo
71101
@timestampFormat("http-date")
72102
timestamp date
73103

74-
@output
75-
structure DepositOutput {
76-
@httpHeader("username")
77-
username: String,
78-
79-
@httpHeader("authenticationResult")
80-
authenticationResult: ExampleList,
81-
82-
textMessage: String,
83-
emailMessage: String
84-
}
85-
86-
@output
87-
structure WithdrawOutput {
88-
@httpHeader("branch")
89-
branch: String,
90-
91-
@httpHeader("result")
92-
accountHistory: ExampleList,
93-
94-
location: String,
95-
bankName: String,
96-
atmRecording: exampleVideo
97-
}
98-
99104
@error("client")
100105
structure InvalidUsername {
101106
@httpHeader("internalErrorCode")
102-
internalErrorCode: String,
107+
internalErrorCode: String
103108

104109
@httpPayload
105110
errorMessage: String
106111
}
107112

108113
@error("server")
109114
structure InvalidAmount {
110-
errorMessage1: String,
111-
errorMessage2: String,
115+
errorMessage1: String
116+
errorMessage2: String
112117
errorMessage3: String
113118
}
114119

115-
apply Deposit @examples(
116-
[
117-
{
118-
title: "Deposit valid example",
119-
documentation: "depositTestDoc",
120-
input: {
121-
accountNumber: "102935",
122-
username: "sichanyoo",
123-
accountHistory: ["10", "-25", "50"],
124-
depositAmount: "200"
125-
},
126-
output: {
127-
username: "sichanyoo",
128-
authenticationResult: ["pass1", "pass2", "pass3"],
129-
textMessage: "You deposited 200-text",
130-
emailMessage: "You deposited 200-email"
131-
},
132-
},
133-
134-
{
135-
title: "Deposit invalid username example",
136-
documentation: "depositTestDoc2",
137-
input: {
138-
username: "sichanyoo",
139-
accountHistory: ["-200", "200", "10"],
140-
depositAmount: "-200"
141-
},
142-
error: {
143-
shapeId: InvalidUsername,
144-
content: {
145-
internalErrorCode: "4gsw2-34",
146-
errorMessage: "ERROR: Invalid username."
147-
}
148-
},
149-
},
150-
151-
{
152-
title: "Deposit invalid amount example",
153-
documentation: "depositTestDoc3",
154-
input: {
155-
accountNumber: "203952",
156-
username: "obidos",
157-
accountHistory: ["2000", "50000", "100"],
158-
depositAmount: "-100"
159-
},
160-
error: {
161-
shapeId: InvalidAmount,
162-
content: {
163-
errorMessage1: "ERROR: Invalid amount.",
164-
errorMessage2: "2gdx4-34",
165-
errorMessage3: "2gcbe-98"
166-
}
167-
},
120+
apply Deposit @examples([
121+
{
122+
title: "Deposit valid example"
123+
documentation: "depositTestDoc"
124+
input: {
125+
accountNumber: "102935"
126+
username: "sichanyoo"
127+
accountHistory: ["10", "-25", "50"]
128+
depositAmount: "200"
168129
}
169-
]
170-
)
171-
172-
apply Withdraw @examples(
173-
[
174-
{
175-
title: "Withdraw valid example",
176-
documentation: "withdrawTestDoc",
177-
input: {
178-
accountNumber: "124634",
179-
username: "amazon",
180-
withdrawParams: {"location" : "Denver", "bankName" : "Chase"},
181-
time: "Tue, 29 Apr 2014 18:30:38 GMT",
182-
withdrawAmount: "-35",
183-
withdrawOption: "ATM"
184-
},
185-
output: {
186-
branch: "Denver-203",
187-
accountHistory: ["34", "5", "-250"],
188-
location: "Denver",
189-
bankName: "Chase",
190-
atmRecording: "dGVzdHZpZGVv"
191-
},
192-
},
193-
194-
{
195-
title: "Withdraw invalid username example",
196-
documentation: "withdrawTestDoc2",
197-
input: {
198-
accountNumber: "231565",
199-
username: "peccy",
200-
withdrawParams: {"location" : "Seoul", "bankName" : "Chase"},
201-
withdrawAmount: "-450",
202-
withdrawOption: "Venmo"
203-
},
204-
error: {
205-
shapeId: InvalidUsername,
206-
content: {
207-
internalErrorCode: "8dfws-21",
208-
errorMessage: "ERROR: Invalid username."
209-
}
210-
},
130+
output: {
131+
username: "sichanyoo"
132+
authenticationResult: ["pass1", "pass2", "pass3"]
133+
textMessage: "You deposited 200-text"
134+
emailMessage: "You deposited 200-email"
211135
}
212-
]
213-
)
136+
}
137+
{
138+
title: "Deposit invalid username example"
139+
documentation: "depositTestDoc2"
140+
input: {
141+
username: "sichanyoo"
142+
accountHistory: ["-200", "200", "10"]
143+
depositAmount: "-200"
144+
}
145+
error: {
146+
shapeId: InvalidUsername
147+
content: { internalErrorCode: "4gsw2-34", errorMessage: "ERROR: Invalid username." }
148+
}
149+
}
150+
{
151+
title: "Deposit invalid amount example"
152+
documentation: "depositTestDoc3"
153+
input: {
154+
accountNumber: "203952"
155+
username: "obidos"
156+
accountHistory: ["2000", "50000", "100"]
157+
depositAmount: "-100"
158+
}
159+
error: {
160+
shapeId: InvalidAmount
161+
content: { errorMessage1: "ERROR: Invalid amount.", errorMessage2: "2gdx4-34", errorMessage3: "2gcbe-98" }
162+
}
163+
}
164+
])
165+
166+
apply Withdraw @examples([
167+
{
168+
title: "Withdraw valid example"
169+
documentation: "withdrawTestDoc"
170+
input: {
171+
accountNumber: "124634"
172+
username: "amazon"
173+
withdrawParams: { location: "Denver", bankName: "Chase" }
174+
time: "Tue, 29 Apr 2014 18:30:38 GMT"
175+
withdrawAmount: "-35"
176+
withdrawOption: "ATM"
177+
}
178+
output: {
179+
branch: "Denver-203"
180+
accountHistory: ["34", "5", "-250"]
181+
location: "Denver"
182+
bankName: "Chase"
183+
atmRecording: "dGVzdHZpZGVv"
184+
}
185+
}
186+
{
187+
title: "Withdraw invalid username example"
188+
documentation: "withdrawTestDoc2"
189+
input: {
190+
accountNumber: "231565"
191+
username: "peccy"
192+
withdrawParams: { location: "Seoul", bankName: "Chase" }
193+
withdrawAmount: "-450"
194+
withdrawOption: "Venmo"
195+
}
196+
error: {
197+
shapeId: InvalidUsername
198+
content: { internalErrorCode: "8dfws-21", errorMessage: "ERROR: Invalid username." }
199+
}
200+
}
201+
])

0 commit comments

Comments
 (0)