github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/idl/example3.thrift (about) 1 include "base.thrift" 2 include "ref.thrift" 3 4 namespace go example3 5 6 enum FOO { 7 A = 1; 8 } 9 10 struct InnerBase { 11 1: bool Bool, 12 2: byte Byte, 13 3: i16 Int16, 14 4: i32 Int32, 15 5: i64 Int64, 16 6: double Double, 17 7: string String (api.cookie="inner_string", api.path="inner_string", api.query="inner_string", api.header="inner_string"), 18 8: list<i32> ListInt32, 19 9: map<string, string> MapStringString, 20 10: set<i32> SetInt32, 21 11: FOO Foo, 22 12: map<i32, string> MapInt32String, 23 13: binary Binary, 24 14: map<byte, string> MapInt8String, 25 15: map<i16, string> MapInt16String, 26 16: map<i64, string> MapInt64String, 27 28 18: list<InnerBase> ListInnerBase, 29 19: map<string, InnerBase> MapStringInnerBase, 30 31 20: string InnerQuery (api.query = "inner_query"), 32 33 255: base.Base Base, 34 } 35 36 struct ExampleReq { 37 1: optional string Msg (go.tag="json:\"msg\""), 38 2: optional double Cookie (api.cookie = "cookie"), 39 3: required string Path (api.path = "path"), 40 4: optional list<string> Query (api.query = "query"), 41 5: optional bool Header (api.header = "heeader"), 42 6: i64 Code (api.js_conv = "", go.tag="json:\"code_code\""), 43 7: InnerBase InnerBase, 44 8: string RawUri (api.raw_uri = ""), 45 46 32767: double Subfix, 47 48 255: base.Base Base 49 } 50 51 struct ExampleResp { 52 1: string Msg (api.body = "msg"), 53 2: optional double Cookie (api.cookie = "cookie"), 54 3: required i32 Status (api.http_code = "status"), 55 4: optional bool Header (api.header = "heeader"), 56 6: i64 Code (api.js_conv = "", go.tag="json:\"code_code\""), 57 32767: double Subfix, 58 7: InnerBase InnerBase, 59 60 255: base.BaseResp BaseResp 61 } 62 63 exception Exception { 64 1: i32 code 65 255: string msg 66 } 67 68 struct ExampleError { 69 1: map<InnerBase, InnerBase> MapInnerBaseInnerBase 70 2: binary Base64 71 3: required string Query (api.query = "query"), 72 4: string Header (api.header = "header"), 73 5: i32 Q2 (api.query = "q2"), 74 } 75 76 struct ExampleErrorResp { 77 2: i64 Int64 78 4: string Xjson (agw.body_dynamic = ""), 79 } 80 81 struct ExampleInt2Float { 82 1: i32 Int32 (api.js_conv = ""), 83 2: double Float64 (api.js_conv = ""), 84 3: string String (go.tag="json:\"中文\"", api.js_conv = "") 85 4: i64 Int64 86 32767: double Subfix 87 } 88 89 struct JSONObject { 90 1: string A (go.tag="json:\"a\""), 91 2: i8 B (go.tag="json:\"b\""), 92 } 93 94 struct ExampleJSONString { 95 1: JSONObject Query (api.query = "query"), 96 2: required list<string> Query2 (api.query = "query2"), 97 3: required JSONObject Header (api.header = "header"), 98 4: required map<i32,string> Header2 (api.header = "header2"), 99 5: JSONObject Cookie (api.cookie = "cookie"), 100 6: required set<i32> Cookie2 (api.cookie = "cookie2"), 101 } 102 103 struct ExamplePartial { 104 1: string Msg (api.body = "msxxg", go.tag="json:\"msg\""), 105 } 106 107 struct ExamplePartial2 { 108 1: string Msg (api.body = "msxxg", go.tag="json:\"msg\""), 109 2: optional double Cookie (api.cookie = "cookie"), 110 3: required i32 Status (api.http_code = "status"), 111 4: optional bool Header (api.header = "heeader"), 112 6: i64 Code (api.js_conv = "", go.tag="json:\"code_code\""), 113 32767: double Subfix, 114 7: InnerBasePartial InnerBase, 115 116 255: base.BaseResp BaseResp 117 } 118 119 struct InnerBasePartial { 120 1: bool Bool, 121 255: base.Base Base, 122 } 123 124 struct ExampleFallback { 125 2: string Msg (api.query = "A", api.path = "B"), 126 3: string Heeader (api.header = "heeader"), 127 } 128 129 struct InnerCode { 130 1: i64 C1 (api.body = "code"), 131 2: i16 C2 (go.tag="json:\"code\""), 132 3: list<InnerCode> C3, 133 } 134 135 struct ExampleApiBody { 136 1: i64 Code (api.body = "code"), 137 2: i16 Code2 (go.tag="json:\"code\""), 138 3: InnerCode InnerCode, 139 } 140 141 struct InnerJSON { 142 1: string A (go.tag="json:\"a\""), 143 2: i64 B (go.tag="json:\"b\""), 144 3: double inner_form 145 } 146 147 struct ExamplePostForm { 148 1: string Query (api.query = "query"), 149 2: string Form (api.form = "form"), 150 3: InnerJSON JSON, 151 } 152 153 struct InnerStruct { 154 1: string InnerJSON (go.tag="json:\"inner_json\"", agw.body_dynamic = ""), 155 2: required string Must, 156 } 157 158 struct ExampleDynamicStruct { 159 1: required string Query (api.query = "query"), 160 2: string JSON (go.tag="json:\"json\"", agw.body_dynamic = ""), 161 3: InnerStruct InnerStruct (go.tag="json:\"inner_struct\""), 162 } 163 164 struct ExampleBase64Binary { 165 1: binary Binary, 166 2: binary Binary2 (api.header = "Binary2"), 167 } 168 169 struct ExampleDefaultValue { 170 1: string A = "hello", 171 2: i32 B = ref.FOO.A, 172 3: double C = 1.2 (api.header = "c"), 173 4: string D = ref.ConstString (api.cookie = "d"), 174 } 175 176 struct ExampleOptionalDefaultValue { 177 1: optional string A = "hello", 178 2: required i32 B = ref.FOO.A, 179 3: optional double C = 1.2 (api.header = "c"), 180 4: required string D = ref.ConstString (api.cookie = "d"), 181 5: optional string E, 182 6: optional string F (api.header = "f"), 183 } 184 185 struct ExampleNoBodyStruct { 186 1: NoBodyStruct NoBodyStruct (agw.source = "not_body_struct"), 187 } 188 189 struct NoBodyStruct { 190 1: optional i32 A, 191 2: optional i32 B (api.query = "b"), 192 3: optional i32 C = 1 (api.header = "c"), 193 } 194 195 service ExampleService { 196 ExampleResp ExampleMethod(1: ExampleReq req)throws(1: Exception err) (api.post = "/example/set"), 197 ExampleErrorResp ErrorMethod(1: ExampleError req) (api.get = "/example/get"), 198 ExampleInt2Float Int2FloatMethod(1: ExampleInt2Float req), 199 ExampleJSONString JSONStringMethod(1: ExampleJSONString req), 200 ExamplePartial PartialMethod(1: ExamplePartial2 req), 201 ExampleFallback FallbackMethod(1: ExampleFallback req), 202 ExampleApiBody ApiBodyMethod(1: ExampleApiBody req), 203 ExamplePostForm PostFormMethod(1: ExamplePostForm req), 204 ExampleDynamicStruct DynamicStructMethod(1: ExampleDynamicStruct req), 205 ExampleBase64Binary Base64BinaryMethod(1: ExampleBase64Binary req), 206 ExampleDefaultValue DefaultValueMethod(1: ExampleDefaultValue req), 207 ExampleOptionalDefaultValue OptionalDefaultValueMethod(1: ExampleOptionalDefaultValue req), 208 ExampleNoBodyStruct NoBodyStructMethod(1: ExampleNoBodyStruct req), 209 string String(1: string req), 210 i64 I64(1: i64 req), 211 }