[{"data":1,"prerenderedAt":1917},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fserialization":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1916,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fserialization.md",{},"Configure serialization",{"type":8,"value":9,"toc":1892},"minimark",[10,14,17,22,34,508,523,527,548,676,684,688,826,838,842,852,889,901,905,931,1115,1127,1204,1208,1222,1293,1308,1317,1430,1475,1485,1489,1493,1508,1541,1544,1559,1647,1661,1665,1672,1704,1710,1713,1718,1738,1743,1752,1755,1766,1769,1786,1790,1815,1838,1861,1865],[11,12,13],"p",{},"Configure how the generated Ky client serializes OpenAPI parameters and encodes request and response bodies by media type.",[11,15,16],{},"Each generated call carries its parameter styles and content types, so most specs need no setup.",[18,19,21],"h2",{"id":20},"parameter-styles","Parameter styles",[11,23,24,25,29,30,33],{},"A parameter without ",[26,27,28],"code",{},"style"," or ",[26,31,32],{},"explode"," in the spec uses its location's default.",[35,36,37,216,326,401],"tabs",{},[38,39,41,48,198],"tabs-item",{"label":40},"Query",[11,42,43,44,47],{},"For a query parameter named ",[26,45,46],{},"id",":",[49,50,51,71],"table",{},[52,53,54],"thead",{},[55,56,57,61,65,68],"tr",{},[58,59,60],"th",{},"Style",[58,62,63],{},[26,64,32],{},[58,66,67],{},"Input",[58,69,70],{},"Sent",[72,73,74,98,118,138,158,178],"tbody",{},[55,75,76,83,88,93],{},[77,78,79,82],"td",{},[26,80,81],{},"form"," (default)",[77,84,85],{},[26,86,87],{},"true",[77,89,90],{},[26,91,92],{},"[3, 4, 5]",[77,94,95],{},[26,96,97],{},"id=3&id=4&id=5",[55,99,100,104,109,113],{},[77,101,102],{},[26,103,81],{},[77,105,106],{},[26,107,108],{},"false",[77,110,111],{},[26,112,92],{},[77,114,115],{},[26,116,117],{},"id=3,4,5",[55,119,120,124,128,133],{},[77,121,122,82],{},[26,123,81],{},[77,125,126],{},[26,127,87],{},[77,129,130],{},[26,131,132],{},"{ a: 1, b: 2 }",[77,134,135],{},[26,136,137],{},"a=1&b=2",[55,139,140,145,149,153],{},[77,141,142],{},[26,143,144],{},"spaceDelimited",[77,146,147],{},[26,148,108],{},[77,150,151],{},[26,152,92],{},[77,154,155],{},[26,156,157],{},"id=3%204%205",[55,159,160,165,169,173],{},[77,161,162],{},[26,163,164],{},"pipeDelimited",[77,166,167],{},[26,168,108],{},[77,170,171],{},[26,172,92],{},[77,174,175],{},[26,176,177],{},"id=3%7C4%7C5",[55,179,180,185,188,193],{},[77,181,182],{},[26,183,184],{},"deepObject",[77,186,187],{},"n\u002Fa",[77,189,190],{},[26,191,192],{},"{ a: 1 }",[77,194,195],{},[26,196,197],{},"id%5Ba%5D=1",[11,199,200,202,203,205,206,208,209,211,212,215],{},[26,201,144],{}," and ",[26,204,164],{}," default ",[26,207,32],{}," to ",[26,210,108],{},". A space in a value goes out as ",[26,213,214],{},"%20",".",[38,217,219,228],{"label":218},"Path",[11,220,221,222,224,225,47],{},"For a path parameter named ",[26,223,46],{},", the segment that replaces ",[26,226,227],{},"{id}",[49,229,230,244],{},[52,231,232],{},[55,233,234,236,240,242],{},[58,235,60],{},[58,237,238],{},[26,239,32],{},[58,241,67],{},[58,243,70],{},[72,245,246,266,286,306],{},[55,247,248,253,257,261],{},[77,249,250,82],{},[26,251,252],{},"simple",[77,254,255],{},[26,256,108],{},[77,258,259],{},[26,260,92],{},[77,262,263],{},[26,264,265],{},"3,4,5",[55,267,268,272,276,281],{},[77,269,270,82],{},[26,271,252],{},[77,273,274],{},[26,275,108],{},[77,277,278],{},[26,279,280],{},"{ x: 1, y: 2 }",[77,282,283],{},[26,284,285],{},"x,1,y,2",[55,287,288,293,297,301],{},[77,289,290],{},[26,291,292],{},"label",[77,294,295],{},[26,296,87],{},[77,298,299],{},[26,300,92],{},[77,302,303],{},[26,304,305],{},".3.4.5",[55,307,308,313,317,321],{},[77,309,310],{},[26,311,312],{},"matrix",[77,314,315],{},[26,316,87],{},[77,318,319],{},[26,320,92],{},[77,322,323],{},[26,324,325],{},";id=3;id=4;id=5",[38,327,329,338],{"label":328},"Header",[11,330,331,332,334,335,337],{},"Headers always use the ",[26,333,252],{}," style. Only ",[26,336,32],{}," varies, and values are sent as they are.",[49,339,340,352],{},[52,341,342],{},[55,343,344,348,350],{},[58,345,346],{},[26,347,32],{},[58,349,67],{},[58,351,70],{},[72,353,354,370,386],{},[55,355,356,360,365],{},[77,357,358,82],{},[26,359,108],{},[77,361,362],{},[26,363,364],{},"'X-Ids': [3, 4]",[77,366,367],{},[26,368,369],{},"X-Ids: 3,4",[55,371,372,376,381],{},[77,373,374,82],{},[26,375,108],{},[77,377,378],{},[26,379,380],{},"'X-Filter': { role: 'admin' }",[77,382,383],{},[26,384,385],{},"X-Filter: role,admin",[55,387,388,392,396],{},[77,389,390],{},[26,391,87],{},[77,393,394],{},[26,395,380],{},[77,397,398],{},[26,399,400],{},"X-Filter: role=admin",[38,402,404,417,493],{"label":403},"Cookie",[11,405,406,407,409,410,413,414,416],{},"Cookies use the ",[26,408,81],{}," style, or the OpenAPI 3.2 ",[26,411,412],{},"cookie"," style, joined into one ",[26,415,403],{}," header.",[49,418,419,433],{},[52,420,421],{},[55,422,423,425,429,431],{},[58,424,60],{},[58,426,427],{},[26,428,32],{},[58,430,67],{},[58,432,70],{},[72,434,435,455,475],{},[55,436,437,441,445,450],{},[77,438,439,82],{},[26,440,81],{},[77,442,443],{},[26,444,108],{},[77,446,447],{},[26,448,449],{},"{ session: 'abc', ids: [1, 2] }",[77,451,452],{},[26,453,454],{},"session=abc; ids=1,2",[55,456,457,461,465,470],{},[77,458,459],{},[26,460,81],{},[77,462,463],{},[26,464,87],{},[77,466,467],{},[26,468,469],{},"{ ids: [1, 2] }",[77,471,472],{},[26,473,474],{},"ids=1; ids=2",[55,476,477,481,485,489],{},[77,478,479],{},[26,480,412],{},[77,482,483],{},[26,484,87],{},[77,486,487],{},[26,488,469],{},[77,490,491],{},[26,492,474],{},[11,494,495,497,498,500,501,504,505,215],{},[26,496,81],{}," percent-encodes values. ",[26,499,412],{}," sends them as they are, and a value it cannot send, such as one with ",[26,502,503],{},";",", throws a ",[26,506,507],{},"TypeError",[11,509,510,511,202,514,517,518,215],{},"For ",[26,512,513],{},"allowReserved",[26,515,516],{},"explode: true"," on delimited styles, see ",[519,520,522],"a",{"href":521},"#delimited-styles-and-allowreserved","Delimited styles and allowReserved",[18,524,526],{"id":525},"override-parameter-serialization","Override parameter serialization",[11,528,529,530,533,534,537,538,537,541,544,545,547],{},"Set a ",[26,531,532],{},"serializer"," key on the client to replace that serializer for every call, or on one call. The keys are ",[26,535,536],{},"query",", ",[26,539,540],{},"path",[26,542,543],{},"header",", and ",[26,546,412],{},", and the other keys keep theirs:",[549,550,554],"pre",{"language":551,"code":552,"class":553},"typescript","import qs from 'qs'\nimport { client } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({\n  serializer: { query: (params) => qs.stringify(params, { arrayFormat: 'brackets' }) },\n})","highlights",[26,555,557,577,578,577,597,577,599,577,613,577,671],{"class":556},"language-typescript",[558,559,562,566,570,573],"span",{"class":560,"style":561},"line","display: inline",[558,563,565],{"style":564},"color:#d73a49;--hls-dark:#f97583","import ",[558,567,569],{"style":568},"color:#24292e;--hls-dark:#e1e4e8","qs ",[558,571,572],{"style":564},"from ",[558,574,576],{"style":575},"color:#032f62;--hls-dark:#9ecbff","'qs'","\n",[558,579,580,582,586,589,592,594],{"class":560,"style":561},[558,581,565],{"style":564},[558,583,585],{"style":584},"color:#005cc5;--hls-dark:#79b8ff","{ ",[558,587,588],{"style":568},"client ",[558,590,591],{"style":584},"} ",[558,593,572],{"style":564},[558,595,596],{"style":575},"'.\u002Fgen\u002F.kubb\u002Fclient'",[558,598],{"class":560,"style":561},[558,600,601,604,606,610],{"class":560,"style":561},[558,602,603],{"style":568},"client",[558,605,215],{"style":564},[558,607,609],{"style":608},"color:#6f42c1;--hls-dark:#b392f0","setConfig",[558,611,612],{"style":584},"({",[558,614,615,618,620,623,625,627,629,632,635,638,641,644,646,649,651,653,655,657,660,662,665,668],{"class":560,"style":561},[558,616,617],{"style":584},"  ",[558,619,532],{"style":584},[558,621,622],{"style":564},": ",[558,624,585],{"style":584},[558,626,536],{"style":584},[558,628,622],{"style":564},[558,630,631],{"style":584},"(",[558,633,634],{"style":568},"params",[558,636,637],{"style":584},") ",[558,639,640],{"style":564},"=> ",[558,642,643],{"style":568},"qs",[558,645,215],{"style":564},[558,647,648],{"style":608},"stringify",[558,650,631],{"style":584},[558,652,634],{"style":568},[558,654,537],{"style":564},[558,656,585],{"style":584},[558,658,659],{"style":584},"arrayFormat",[558,661,622],{"style":564},[558,663,664],{"style":575},"'brackets' ",[558,666,667],{"style":584},"}) }",[558,669,670],{"style":564},",",[558,672,673],{"class":560,"style":561},[558,674,675],{"style":584},"})",[11,677,678,679,683],{},"Kubb writes only the serializers a spec needs. See ",[519,680,682],{"href":681},"#serializer-files","Serializer files"," for which files it writes.",[18,685,687],{"id":686},"built-in-media-types","Built-in media types",[49,689,690,703],{},[52,691,692],{},[55,693,694,697,700],{},[58,695,696],{},"Keys",[58,698,699],{},"Encodes",[58,701,702],{},"Decodes",[72,704,705,723,736,759,789,813],{},[55,706,707,718,721],{},[77,708,709,537,712,537,715],{},[26,710,711],{},"application\u002Fjson",[26,713,714],{},"application\u002F*+json",[26,716,717],{},"text\u002Fjson",[77,719,720],{},"JSON",[77,722,720],{},[55,724,725,730,733],{},[77,726,727],{},[26,728,729],{},"text\u002F*",[77,731,732],{},"a string as is",[77,734,735],{},"text",[55,737,738,746,755],{},[77,739,740,537,743],{},[26,741,742],{},"multipart\u002Fform-data",[26,744,745],{},"application\u002Fx-www-form-urlencoded",[77,747,748,29,751,754],{},[26,749,750],{},"FormData",[26,752,753],{},"URLSearchParams"," from an object",[77,756,757],{},[26,758,750],{},[55,760,761,778,785],{},[77,762,763,537,766,537,769,537,772,537,775],{},[26,764,765],{},"application\u002Foctet-stream",[26,767,768],{},"application\u002Fpdf",[26,770,771],{},"image\u002F*",[26,773,774],{},"audio\u002F*",[26,776,777],{},"video\u002F*",[77,779,780,781,784],{},"a ",[26,782,783],{},"Blob"," as is",[77,786,787],{},[26,788,783],{},[55,790,791,805,807],{},[77,792,793,537,796,537,799,537,802],{},[26,794,795],{},"text\u002Fevent-stream",[26,797,798],{},"application\u002Fjsonl",[26,800,801],{},"application\u002Fx-ndjson",[26,803,804],{},"application\u002Fjson-seq",[77,806],{},[77,808,809,810],{},"text, or item by item with ",[26,811,812],{},"client.stream",[55,814,815,820,823],{},[77,816,817],{},[26,818,819],{},"*\u002F*",[77,821,822],{},"JSON for objects, strings and binary bodies as is",[77,824,825],{},"JSON, or text when the body is not JSON",[11,827,828,829,831,832,834,835,837],{},"The runtime matches the lower-cased type without its parameters: the exact type, then a suffix such as ",[26,830,714],{},", then a wildcard such as ",[26,833,729],{},", then ",[26,836,819],{},". Write your own keys in lower case.",[18,839,841],{"id":840},"encode-request-bodies","Encode request bodies",[11,843,844,845,848,849,851],{},"For an operation with several request content types, set ",[26,846,847],{},"contentType"," on the call. A body without a content type goes out as ",[26,850,711],{},", unless it is already encoded.",[853,854,855,869,879],"ul",{},[856,857,858,859,537,861,537,863,537,865,868],"li",{},"An encoded body passes every built-in media type as is: ",[26,860,750],{},[26,862,753],{},[26,864,783],{},[26,866,867],{},"ArrayBuffer",", typed arrays, streams, and strings. Under a JSON media type, a string is JSON-encoded.",[856,870,871,872,874,875,878],{},"For a ",[26,873,750],{}," body, the runtime removes ",[26,876,877],{},"Content-Type",", so the transport sets it with the multipart boundary.",[856,880,881,882,884,885,888],{},"XML, YAML, and CSV have no built-in encoder, so an object under one throws a ",[26,883,507],{},". Pass the encoded string, cast to the body type (",[26,886,887],{},"body: xml as unknown as AddPetBodyXml","), or add a media type.",[11,890,510,891,894,895,215],{},[26,892,893],{},"bigint"," bodies, see ",[519,896,898,900],{"href":897},"#bigint-request-bodies",[26,899,893],{}," request bodies",[18,902,904],{"id":903},"add-a-media-type","Add a media type",[11,906,907,908,911,912,915,916,918,919,922,923,926,927,930],{},"Register a handler under its media type in ",[26,909,910],{},"mediaTypes",". ",[26,913,914],{},"encode"," gets the body and a context with the full ",[26,917,847],{},", and returns what ",[26,920,921],{},"fetch"," can send. ",[26,924,925],{},"decode"," gets the ",[26,928,929],{},"Response",", so a binary format can read bytes:",[549,932,934],{"language":551,"code":933,"class":553},"import { XMLBuilder, XMLParser } from 'fast-xml-parser'\nimport { client } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({\n  mediaTypes: {\n    'application\u002Fxml': {\n      encode: (body) => new XMLBuilder().build(body),\n      decode: async (response) => new XMLParser().parse(await response.text()),\n    },\n  },\n})",[26,935,936,577,957,577,971,577,973,577,983,577,994,577,1006,577,1046,577,1094,577,1103,577,1111],{"class":556},[558,937,938,940,942,945,947,950,952,954],{"class":560,"style":561},[558,939,565],{"style":564},[558,941,585],{"style":584},[558,943,944],{"style":608},"XMLBuilder",[558,946,537],{"style":564},[558,948,949],{"style":608},"XMLParser ",[558,951,591],{"style":584},[558,953,572],{"style":564},[558,955,956],{"style":575},"'fast-xml-parser'",[558,958,959,961,963,965,967,969],{"class":560,"style":561},[558,960,565],{"style":564},[558,962,585],{"style":584},[558,964,588],{"style":568},[558,966,591],{"style":584},[558,968,572],{"style":564},[558,970,596],{"style":575},[558,972],{"class":560,"style":561},[558,974,975,977,979,981],{"class":560,"style":561},[558,976,603],{"style":568},[558,978,215],{"style":564},[558,980,609],{"style":608},[558,982,612],{"style":584},[558,984,985,987,989,991],{"class":560,"style":561},[558,986,617],{"style":584},[558,988,910],{"style":584},[558,990,622],{"style":564},[558,992,993],{"style":584},"{",[558,995,996,999,1002,1004],{"class":560,"style":561},[558,997,998],{"style":584},"    ",[558,1000,1001],{"style":575},"'application\u002Fxml'",[558,1003,622],{"style":564},[558,1005,993],{"style":584},[558,1007,1008,1011,1013,1015,1017,1020,1022,1024,1027,1029,1032,1034,1037,1039,1041,1044],{"class":560,"style":561},[558,1009,1010],{"style":584},"      ",[558,1012,914],{"style":584},[558,1014,622],{"style":564},[558,1016,631],{"style":584},[558,1018,1019],{"style":568},"body",[558,1021,637],{"style":584},[558,1023,640],{"style":564},[558,1025,1026],{"style":564},"new ",[558,1028,944],{"style":608},[558,1030,1031],{"style":584},"()",[558,1033,215],{"style":564},[558,1035,1036],{"style":608},"build",[558,1038,631],{"style":584},[558,1040,1019],{"style":568},[558,1042,1043],{"style":584},")",[558,1045,670],{"style":564},[558,1047,1048,1050,1052,1054,1057,1059,1062,1064,1066,1068,1071,1073,1075,1078,1080,1083,1085,1087,1089,1092],{"class":560,"style":561},[558,1049,1010],{"style":564},[558,1051,925],{"style":584},[558,1053,622],{"style":564},[558,1055,1056],{"style":564},"async ",[558,1058,631],{"style":584},[558,1060,1061],{"style":568},"response",[558,1063,637],{"style":584},[558,1065,640],{"style":564},[558,1067,1026],{"style":564},[558,1069,1070],{"style":608},"XMLParser",[558,1072,1031],{"style":584},[558,1074,215],{"style":564},[558,1076,1077],{"style":608},"parse",[558,1079,631],{"style":584},[558,1081,1082],{"style":564},"await ",[558,1084,1061],{"style":568},[558,1086,215],{"style":564},[558,1088,735],{"style":608},[558,1090,1091],{"style":584},"())",[558,1093,670],{"style":564},[558,1095,1096,1098,1101],{"class":560,"style":561},[558,1097,998],{"style":564},[558,1099,1100],{"style":584},"}",[558,1102,670],{"style":564},[558,1104,1105,1107,1109],{"class":560,"style":561},[558,1106,617],{"style":564},[558,1108,1100],{"style":584},[558,1110,670],{"style":564},[558,1112,1113],{"class":560,"style":561},[558,1114,675],{"style":584},[11,1116,1117,1118,1122,1123,1126],{},"Handlers merge per key over the built-ins. For the merge order, see ",[519,1119,1121],{"href":1120},"#media-type-merge-order","Media type merge order",". A streaming format adds ",[26,1124,1125],{},"stream",", which reads a 2xx body item by item, and the runtime validates each item:",[549,1128,1130],{"language":551,"code":1129,"class":553},"client.setConfig({\n  mediaTypes: { 'multipart\u002Fmixed': { stream: (body, { contentType }) => readParts(body, boundaryOf(contentType)) } },\n})",[26,1131,1132,577,1142,577,1200],{"class":556},[558,1133,1134,1136,1138,1140],{"class":560,"style":561},[558,1135,603],{"style":568},[558,1137,215],{"style":564},[558,1139,609],{"style":608},[558,1141,612],{"style":584},[558,1143,1144,1146,1148,1150,1152,1155,1157,1159,1161,1163,1165,1167,1169,1171,1174,1177,1179,1182,1184,1186,1188,1191,1193,1195,1198],{"class":560,"style":561},[558,1145,617],{"style":584},[558,1147,910],{"style":584},[558,1149,622],{"style":564},[558,1151,585],{"style":584},[558,1153,1154],{"style":575},"'multipart\u002Fmixed'",[558,1156,622],{"style":564},[558,1158,585],{"style":584},[558,1160,1125],{"style":584},[558,1162,622],{"style":564},[558,1164,631],{"style":584},[558,1166,1019],{"style":568},[558,1168,537],{"style":564},[558,1170,585],{"style":584},[558,1172,1173],{"style":568},"contentType ",[558,1175,1176],{"style":584},"}) ",[558,1178,640],{"style":564},[558,1180,1181],{"style":608},"readParts",[558,1183,631],{"style":584},[558,1185,1019],{"style":568},[558,1187,537],{"style":564},[558,1189,1190],{"style":608},"boundaryOf",[558,1192,631],{"style":584},[558,1194,847],{"style":568},[558,1196,1197],{"style":584},")) } }",[558,1199,670],{"style":564},[558,1201,1202],{"class":560,"style":561},[558,1203,675],{"style":584},[18,1205,1207],{"id":1206},"decode-responses","Decode responses",[11,1209,1210,1211,1213,1214,1217,1218,1221],{},"The runtime decodes each body by the response ",[26,1212,877],{},". A ",[26,1215,1216],{},"switch (result.contentType)"," narrows ",[26,1219,1220],{},"data"," for an operation that returns several media types.",[49,1223,1224,1234],{},[52,1225,1226],{},[55,1227,1228,1230],{},[58,1229,929],{},[58,1231,1232],{},[26,1233,1220],{},[72,1235,1236,1250,1265],{},[55,1237,1238,1245],{},[77,1239,1240,1241,1244],{},"204, 205, or 304, a ",[26,1242,1243],{},"HEAD"," request, or an empty body",[77,1246,1247],{},[26,1248,1249],{},"undefined",[55,1251,1252,1255],{},[77,1253,1254],{},"Invalid JSON under a JSON media type",[77,1256,1257,1258,1261,1262,1264],{},"Throws a ",[26,1259,1260],{},"ParseError",". Catch it, or register a lenient ",[26,1263,711],{}," handler.",[55,1266,1267,1274],{},[77,1268,1269,1270,1273],{},"2xx with ",[26,1271,1272],{},"parseAs"," set on the call",[77,1275,1276,1277,537,1280,537,1283,537,1286,1289,1290,215],{},"Read as ",[26,1278,1279],{},"'json'",[26,1281,1282],{},"'text'",[26,1284,1285],{},"'blob'",[26,1287,1288],{},"'arrayBuffer'",", or ",[26,1291,1292],{},"'stream'",[11,1294,1295,1296,1298,1299,1303,1304,215],{},"For a 2xx without a ",[26,1297,877],{},", see ",[519,1300,1302],{"href":1301},"#default-content-types","Default content types",". For binary downloads and vendor types, see ",[519,1305,1307],{"href":1306},"#binary-and-vendor-responses","Binary and vendor responses",[11,1309,1310,1311,1314,1315,47],{},"XML, YAML, and CSV responses are typed ",[26,1312,1313],{},"string",", even with an object schema. A media type you register changes the value but not the type, so cast ",[26,1316,1220],{},[549,1318,1320],{"language":551,"code":1319,"class":553},"const result = await getPetById({ path: { petId: 1 }, contentType: { response: 'application\u002Fxml' } })\nif (result.contentType === 'application\u002Fxml') {\n  const pet = result.data as unknown as Pet\n}",[26,1321,1322,577,1375,577,1397,577,1426],{"class":556},[558,1323,1324,1327,1330,1333,1335,1338,1341,1343,1345,1347,1350,1352,1355,1357,1359,1361,1363,1365,1367,1369,1372],{"class":560,"style":561},[558,1325,1326],{"style":564},"const ",[558,1328,1329],{"style":568},"result ",[558,1331,1332],{"style":564},"= ",[558,1334,1082],{"style":564},[558,1336,1337],{"style":608},"getPetById",[558,1339,1340],{"style":584},"({ ",[558,1342,540],{"style":584},[558,1344,622],{"style":564},[558,1346,585],{"style":584},[558,1348,1349],{"style":584},"petId",[558,1351,622],{"style":564},[558,1353,1354],{"style":584},"1 ",[558,1356,1100],{"style":584},[558,1358,537],{"style":564},[558,1360,847],{"style":584},[558,1362,622],{"style":564},[558,1364,585],{"style":584},[558,1366,1061],{"style":584},[558,1368,622],{"style":564},[558,1370,1371],{"style":575},"'application\u002Fxml' ",[558,1373,1374],{"style":584},"} })",[558,1376,1377,1380,1382,1385,1387,1389,1392,1394],{"class":560,"style":561},[558,1378,1379],{"style":564},"if ",[558,1381,631],{"style":584},[558,1383,1384],{"style":568},"result",[558,1386,215],{"style":564},[558,1388,1173],{"style":584},[558,1390,1391],{"style":564},"=== ",[558,1393,1001],{"style":575},[558,1395,1396],{"style":584},") {",[558,1398,1399,1401,1403,1406,1408,1410,1412,1415,1418,1421,1423],{"class":560,"style":561},[558,1400,617],{"style":584},[558,1402,1326],{"style":564},[558,1404,1405],{"style":568},"pet ",[558,1407,1332],{"style":564},[558,1409,1384],{"style":568},[558,1411,215],{"style":564},[558,1413,1414],{"style":584},"data ",[558,1416,1417],{"style":564},"as ",[558,1419,1420],{"style":568},"unknown ",[558,1422,1417],{"style":564},[558,1424,1425],{"style":608},"Pet",[558,1427,1428],{"class":560,"style":561},[558,1429,1100],{"style":584},[1431,1432,1434,1435,1441,1442,1445,1446,1448,1449,1452,1453,1456,1457,1460,1461,1467,1468,1470,1471,1474],"blockquote",{"as":1433},"note","With the adapter's default ",[519,1436,1438],{"href":1437},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#integertype",[26,1439,1440],{},"integerType: 'bigint'",", an ",[26,1443,1444],{},"int64"," field is typed ",[26,1447,893],{},", but ",[26,1450,1451],{},"JSON.parse"," returns a ",[26,1454,1455],{},"number",". Set ",[26,1458,1459],{},"integerType: 'number'",", or turn on ",[519,1462,1464],{"href":1463},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Foptions#validator",[26,1465,1466],{},"validator: 'zod'",", which converts the field. ",[26,1469,1451],{}," loses precision above ",[26,1472,1473],{},"Number.MAX_SAFE_INTEGER"," either way, so declare an exact 64-bit ID as a string.",[11,1476,1477,1478,1482,1483,215],{},"Next, ",[519,1479,1481],{"href":1480},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fserver-sent-events","Server-sent events"," covers the stream media types and ",[26,1484,812],{},[18,1486,1488],{"id":1487},"less-common-cases","Less common cases",[1490,1491,522],"h3",{"id":1492},"delimited-styles-and-allowreserved",[11,1494,1495,1496,1500,1501,29,1503,1505,1506,47],{},"When a ",[519,1497,1499],{"href":1498},"#parameter-styles","query parameter"," uses ",[26,1502,144],{},[26,1504,164],{},", or sets ",[26,1507,513],{},[853,1509,1510,1526],{},[856,1511,1512,202,1514,205,1516,208,1518,1520,1521,1523,1524,215],{},[26,1513,144],{},[26,1515,164],{},[26,1517,32],{},[26,1519,108],{},". With ",[26,1522,516],{},", they repeat the key, like ",[26,1525,81],{},[856,1527,1528,1529,1531,1532,537,1535,544,1538,215],{},"With ",[26,1530,513],{},", reserved characters stay as they are, except ",[26,1533,1534],{},"#",[26,1536,1537],{},"&",[26,1539,1540],{},"+",[1490,1542,682],{"id":1543},"serializer-files",[11,1545,1546,1547,1550,1551,1554,1555,1558],{},"When you look for a serializer in ",[26,1548,1549],{},".kubb\u002Fserializers\u002F",", Kubb writes only the ones the spec needs and registers them in ",[26,1552,1553],{},".kubb\u002Fconfig.ts",". Set a key from the table to replace one, as ",[519,1556,526],{"href":1557},"#override-parameter-serialization"," shows.",[49,1560,1561,1576],{},[52,1562,1563],{},[55,1564,1565,1570,1573],{},[58,1566,1567,1568],{},"Key in ",[26,1569,532],{},[58,1571,1572],{},"File",[58,1574,1575],{},"Written for",[72,1577,1578,1596,1619,1633],{},[55,1579,1580,1584,1593],{},[77,1581,1582],{},[26,1583,536],{},[77,1585,1586,1289,1589,1592],{},[26,1587,1588],{},"query.ts",[26,1590,1591],{},"queryStyles.ts"," with a styled query parameter",[77,1594,1595],{},"every spec",[55,1597,1598,1602,1617],{},[77,1599,1600],{},[26,1601,540],{},[77,1603,1604,1607,1608,1611,1612,29,1614,1616],{},[26,1605,1606],{},"path.ts",", plus ",[26,1609,1610],{},"pathStyles.ts"," with a ",[26,1613,292],{},[26,1615,312],{}," one",[77,1618,1595],{},[55,1620,1621,1625,1630],{},[77,1622,1623],{},[26,1624,543],{},[77,1626,1627],{},[26,1628,1629],{},"headers.ts",[77,1631,1632],{},"a spec with a header parameter",[55,1634,1635,1639,1644],{},[77,1636,1637],{},[26,1638,412],{},[77,1640,1641],{},[26,1642,1643],{},"cookies.ts",[77,1645,1646],{},"a spec with a cookie parameter",[11,1648,1649,1650,1652,1653,1656,1657,1660],{},"A call that needs a serializer the spec did not register throws a ",[26,1651,507],{}," that names it, such as ",[26,1654,1655],{},"serializer.cookie",". Without ",[26,1658,1659],{},"serializer.header",", an array or object header value goes out as JSON.",[1490,1662,1664],{"id":1663},"form-and-stream-media-types","Form and stream media types",[11,1666,1667,1668,1671],{},"When a form or stream type from ",[519,1669,687],{"href":1670},"#built-in-media-types"," has no handler, the spec does not use it:",[853,1673,1674,1685,1696],{},[856,1675,1676,1678,1679,202,1682,215],{},[26,1677,1553],{}," registers each form type only when the spec has a body of that type, from ",[26,1680,1681],{},".kubb\u002FmediaTypes\u002FformData.ts",[26,1683,1684],{},".kubb\u002FmediaTypes\u002Furlencoded.ts",[856,1686,1687,1688,1691,1692,1695],{},"It registers the stream types, ",[26,1689,1690],{},"streamMediaTypes"," from ",[26,1693,1694],{},".kubb\u002Fsse.ts",", only when the spec streams.",[856,1697,1698,1701,1702,215],{},[26,1699,1700],{},".kubb\u002Fclient.ts"," passes that config to ",[26,1703,609],{},[11,1705,1706,1707,1558],{},"To send a type the spec does not declare, register a handler, as ",[519,1708,904],{"href":1709},"#add-a-media-type",[1490,1711,1302],{"id":1712},"default-content-types",[11,1714,1715,1716,47],{},"When a call sets no ",[26,1717,847],{},[853,1719,1720,1726],{},[856,1721,1722,1723,1725],{},"An operation with one request content type has it built in. For one with several, set ",[26,1724,847],{}," on the call.",[856,1727,1728,1729,1731,1732,1735,1736,215],{},"A 2xx response without a ",[26,1730,877],{}," decodes as the call's ",[26,1733,1734],{},"contentType.response",", then as ",[26,1737,819],{},[1490,1739,1741,900],{"id":1740},"bigint-request-bodies",[26,1742,893],{},[11,1744,1745,1746,1748,1749,1751],{},"When a request body holds a ",[26,1747,893],{},", it goes out as a JSON number. A value outside the safe-integer range throws a ",[26,1750,507],{}," instead of losing precision, so register a media type to send it another way.",[1490,1753,1121],{"id":1754},"media-type-merge-order",[11,1756,1757,1758,1760,1761,1763,1764,215],{},"When you register a handler for a type that already has one, handlers merge per key over the built-ins and over earlier ",[26,1759,609],{}," calls. A handler passed on one call merges over the client's. An entry with only ",[26,1762,925],{}," still encodes through the next match, such as ",[26,1765,819],{},[1490,1767,1307],{"id":1768},"binary-and-vendor-responses",[11,1770,1771,1772,1775,1776,1778,1779,1781,1782,1785],{},"When an operation's success content is only binary, Kubb sets ",[26,1773,1774],{},"parseAs: 'blob'"," on it, so ",[26,1777,1220],{}," is a ",[26,1780,783],{}," whatever its media type. The generated types follow what the built-in media types return. A vendor type such as ",[26,1783,1784],{},"application\u002Fvnd.github.object"," keeps its schema type.",[1490,1787,1789],{"id":1788},"parameter-validation","Parameter validation",[11,1791,1792,1793,1798,1799,1801,1802,537,1805,537,1808,1289,1811,1814],{},"When ",[519,1794,1795],{"href":1463},[26,1796,1797],{},"validator"," checks ",[26,1800,634],{},", the call sends what each ",[26,1803,1804],{},"\u003Coperation>PathSchema",[26,1806,1807],{},"QuerySchema",[26,1809,1810],{},"HeadersSchema",[26,1812,1813],{},"CookiesSchema"," returns:",[853,1816,1817,1824,1827],{},[856,1818,1819,1820,1823],{},"A codec param such as a ",[26,1821,1822],{},"Date"," goes out in its wire form.",[856,1825,1826],{},"Path and query keys the spec does not declare are stripped, such as a cache-buster.",[856,1828,1829,1830,1833,1834,1837],{},"Undeclared headers pass through, and declared ones match in any casing. Client-level ",[26,1831,1832],{},"headers"," are checked too, and ",[26,1835,1836],{},"auth"," values are not.",[11,1839,1840,1841,202,1844,1846,1847,1853,1854,1856,1857,215],{},"With codecs, pair ",[26,1842,1843],{},"request",[26,1845,634],{}," with ",[519,1848,1850],{"href":1849},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-zod\u002Foptions#inferred",[26,1851,1852],{},"pluginZod({ inferred: 'codec' })",", so the request types accept domain values such as a ",[26,1855,1822],{},". To skip the checks, ",[519,1858,1860],{"href":1859},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ferror-handling#turn-validation-off-at-runtime","turn validation off at runtime",[1490,1862,1864],{"id":1863},"error-body-validation","Error body validation",[11,1866,1792,1867,1869,1870,834,1873,1876,1877,1879,1880,1883,1884,1887,1888,215],{},[26,1868,1797],{}," is on and a non-2xx response has a body, the runtime checks it against the schema of its status, then its range such as ",[26,1871,1872],{},"5xx",[26,1874,1875],{},"default",". A status the document leaves out keeps its body unchecked. An error body that fails its schema throws a ",[26,1878,1260],{}," instead of the ",[26,1881,1882],{},"ResponseError",", also with ",[26,1885,1886],{},"throwOnError: false",". To recover, see ",[519,1889,1891],{"href":1890},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ferror-handling#validation-failures","Validation failures",{"title":1893,"searchDepth":1894,"depth":1894,"links":1895},"",5,[1896,1898,1899,1900,1901,1902,1903],{"id":20,"depth":1897,"text":21},2,{"id":525,"depth":1897,"text":526},{"id":686,"depth":1897,"text":687},{"id":840,"depth":1897,"text":841},{"id":903,"depth":1897,"text":904},{"id":1206,"depth":1897,"text":1207},{"id":1487,"depth":1897,"text":1488,"children":1904},[1905,1907,1908,1909,1910,1912,1913,1914,1915],{"id":1492,"depth":1906,"text":522},3,{"id":1543,"depth":1906,"text":682},{"id":1663,"depth":1906,"text":1664},{"id":1712,"depth":1906,"text":1302},{"id":1740,"depth":1906,"text":1911},"bigint request bodies",{"id":1754,"depth":1906,"text":1121},{"id":1768,"depth":1906,"text":1307},{"id":1788,"depth":1906,"text":1789},{"id":1863,"depth":1906,"text":1864},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fserialization",1795091984809]