|
| 1 | +$version: "2.0" |
| 2 | + |
| 3 | +namespace com.amazonaws.bignumbers |
| 4 | + |
| 5 | +use aws.protocols#restJson1 |
| 6 | +use smithy.test#httpRequestTests |
| 7 | +use smithy.test#httpResponseTests |
| 8 | + |
| 9 | +@restJson1 |
| 10 | +service BigNumberService { |
| 11 | + version: "2023-01-01" |
| 12 | + operations: [ProcessBigNumbers] |
| 13 | +} |
| 14 | + |
| 15 | +@http(uri: "/process", method: "POST") |
| 16 | +@httpRequestTests([ |
| 17 | + { |
| 18 | + id: "BigNumbersInJsonRequest", |
| 19 | + protocol: restJson1, |
| 20 | + method: "POST", |
| 21 | + uri: "/process", |
| 22 | + body: "{\"bigInt\":123456789,\"bigDec\":123.456789}", |
| 23 | + bodyMediaType: "application/json", |
| 24 | + headers: {"Content-Type": "application/json"}, |
| 25 | + params: { |
| 26 | + bigInt: 123456789, |
| 27 | + bigDec: 123.456789 |
| 28 | + } |
| 29 | + }, |
| 30 | + { |
| 31 | + id: "NegativeBigNumbersInJsonRequest", |
| 32 | + protocol: restJson1, |
| 33 | + method: "POST", |
| 34 | + uri: "/process", |
| 35 | + body: "{\"bigInt\":-987654321,\"bigDec\":-0.000000001}", |
| 36 | + bodyMediaType: "application/json", |
| 37 | + headers: {"Content-Type": "application/json"}, |
| 38 | + params: { |
| 39 | + bigInt: -987654321, |
| 40 | + bigDec: -0.000000001 |
| 41 | + } |
| 42 | + }, |
| 43 | + { |
| 44 | + id: "ZeroBigNumbersInJsonRequest", |
| 45 | + protocol: restJson1, |
| 46 | + method: "POST", |
| 47 | + uri: "/process", |
| 48 | + body: "{\"bigInt\":0,\"bigDec\":0.0}", |
| 49 | + bodyMediaType: "application/json", |
| 50 | + headers: {"Content-Type": "application/json"}, |
| 51 | + params: { |
| 52 | + bigInt: 0, |
| 53 | + bigDec: 0.0 |
| 54 | + } |
| 55 | + }, |
| 56 | + { |
| 57 | + id: "VeryLargeBigNumbersInJsonRequest", |
| 58 | + protocol: restJson1, |
| 59 | + method: "POST", |
| 60 | + uri: "/process", |
| 61 | + body: "{\"bigInt\":9007199254740991,\"bigDec\":123456.789}", |
| 62 | + bodyMediaType: "application/json", |
| 63 | + headers: {"Content-Type": "application/json"}, |
| 64 | + params: { |
| 65 | + bigInt: 9007199254740991, |
| 66 | + bigDec: 123456.789 |
| 67 | + } |
| 68 | + } |
| 69 | +]) |
| 70 | +@httpResponseTests([ |
| 71 | + { |
| 72 | + id: "BigNumbersInJsonResponse", |
| 73 | + protocol: restJson1, |
| 74 | + code: 200, |
| 75 | + body: "{\"result\":999999999,\"ratio\":0.123456789}", |
| 76 | + bodyMediaType: "application/json", |
| 77 | + headers: {"Content-Type": "application/json"}, |
| 78 | + params: { |
| 79 | + result: 999999999, |
| 80 | + ratio: 0.123456789 |
| 81 | + } |
| 82 | + }, |
| 83 | + { |
| 84 | + id: "NegativeBigNumbersInJsonResponse", |
| 85 | + protocol: restJson1, |
| 86 | + code: 200, |
| 87 | + body: "{\"result\":-123456789,\"ratio\":-999.999}", |
| 88 | + bodyMediaType: "application/json", |
| 89 | + headers: {"Content-Type": "application/json"}, |
| 90 | + params: { |
| 91 | + result: -123456789, |
| 92 | + ratio: -999.999 |
| 93 | + } |
| 94 | + }, |
| 95 | + { |
| 96 | + id: "VeryLargeBigNumbersInJsonResponse", |
| 97 | + protocol: restJson1, |
| 98 | + code: 200, |
| 99 | + body: "{\"result\":9007199254740991,\"ratio\":123456.789}", |
| 100 | + bodyMediaType: "application/json", |
| 101 | + headers: {"Content-Type": "application/json"}, |
| 102 | + params: { |
| 103 | + result: 9007199254740991, |
| 104 | + ratio: 123456.789 |
| 105 | + } |
| 106 | + }, |
| 107 | + { |
| 108 | + id: "ZeroBigNumbersInJsonResponse", |
| 109 | + protocol: restJson1, |
| 110 | + code: 200, |
| 111 | + body: "{\"result\":0,\"ratio\":0.0}", |
| 112 | + bodyMediaType: "application/json", |
| 113 | + headers: {"Content-Type": "application/json"}, |
| 114 | + params: { |
| 115 | + result: 0, |
| 116 | + ratio: 0.0 |
| 117 | + } |
| 118 | + }, |
| 119 | + { |
| 120 | + id: "NullBigNumbersInJsonResponse", |
| 121 | + protocol: restJson1, |
| 122 | + code: 200, |
| 123 | + body: "{\"result\":null,\"ratio\":null}", |
| 124 | + bodyMediaType: "application/json", |
| 125 | + headers: {"Content-Type": "application/json"}, |
| 126 | + params: {} |
| 127 | + } |
| 128 | +]) |
| 129 | +
|
| 130 | +operation ProcessBigNumbers { |
| 131 | + input: BigNumberInput |
| 132 | + output: BigNumberOutput |
| 133 | +} |
| 134 | +
|
| 135 | +structure BigNumberInput { |
| 136 | + bigInt: BigInteger |
| 137 | + bigDec: BigDecimal |
| 138 | +} |
| 139 | +
|
| 140 | +structure BigNumberOutput { |
| 141 | + result: BigInteger |
| 142 | + ratio: BigDecimal |
| 143 | +} |
0 commit comments