[{"data":1,"prerenderedAt":1803},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fmigrate-to-v6":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1802,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fmigrate-to-v6.md",{},"Migrate to v6",{"type":8,"value":9,"toc":1779},"minimark",[10,23,30,35,153,156,712,721,958,960,977,1208,1214,1217,1237,1252,1262,1265,1270,1285,1300,1315,1325,1329,1332,1540,1543,1661,1668,1672,1687,1691,1695,1698,1734,1738,1741,1763,1767],[11,12,13,14,18,19,22],"p",{},"Upgrade ",[15,16,17],"code",{},"@kubb\u002Fplugin-axios"," from v5 to v6, which runs on the shared client core from ",[15,20,21],{},"@kubb\u002Fplugin-client"," with axios as the transport.",[11,24,25,26,29],{},"Code that only calls the generated functions, SDK classes, or hooks needs a regenerate. Most other edits land in the file that configures ",[15,27,28],{},"client",".",[31,32,34],"h2",{"id":33},"upgrade-steps","Upgrade steps",[36,37,39,44,53,92,96,103,116,120,123,135,139],"steps",{"level":38},"3",[40,41,43],"h3",{"id":42},"upgrade-the-packages","Upgrade the packages",[11,45,13,46,49,50,52],{},[15,47,48],{},"kubb"," and ",[15,51,17],{}," together. v6 needs Kubb 5.19.0 or later:",[54,55,59],"pre",{"language":56,"code":57,"class":58},"bash","npm install --save-dev kubb@latest @kubb\u002Fplugin-axios@6","highlights",[15,60,62],{"class":61},"language-bash",[63,64,67,71,75,78,81,83,86,88],"span",{"class":65,"style":66},"line","display: inline",[63,68,70],{"style":69},"color:#6f42c1;--hls-dark:#b392f0","npm ",[63,72,74],{"style":73},"color:#24292e;--hls-dark:#e1e4e8","install --save-dev kubb",[63,76,77],{"style":73},"@",[63,79,80],{"style":73},"latest ",[63,82,77],{"style":73},[63,84,85],{"style":73},"kubb\u002Fplugin-axios",[63,87,77],{"style":73},[63,89,91],{"style":90},"color:#005cc5;--hls-dark:#79b8ff","6",[40,93,95],{"id":94},"regenerate","Regenerate",[11,97,98,99,102],{},"This rewrites ",[15,100,101],{},".kubb\u002F"," and the operation files:",[54,104,106],{"language":56,"code":105,"class":58},"npx kubb generate",[15,107,108],{"class":61},[63,109,110,113],{"class":65,"style":66},[63,111,112],{"style":69},"npx ",[63,114,115],{"style":73},"kubb generate",[40,117,119],{"id":118},"run-the-type-checker","Run the type checker",[11,121,122],{},"Most breaking changes show up as compile errors:",[54,124,126],{"language":56,"code":125,"class":58},"npx tsc --noEmit",[15,127,128],{"class":61},[63,129,130,132],{"class":65,"style":66},[63,131,112],{"style":69},[63,133,134],{"style":73},"tsc --noEmit",[40,136,138],{"id":137},"fix-each-error","Fix each error",[11,140,141,142,147,148,152],{},"Find its row in ",[143,144,146],"a",{"href":145},"#what-to-change","What to change",". Then check the ",[143,149,151],{"href":150},"#behavior-changes","behavior changes",", which compile without errors.",[31,154,146],{"id":155},"what-to-change",[157,158,159,172],"table",{},[160,161,162],"thead",{},[163,164,165,169],"tr",{},[166,167,168],"th",{},"You used",[166,170,171],{},"Now",[173,174,175,189,209,228,241,258,287,309,325,335,358,372,388,413,425,442,463,484,513,533,552,577,599,624,648,669,692],"tbody",{},[163,176,177,183],{},[178,179,180],"td",{},[15,181,182],{},"@kubb\u002Fplugin-axios\u002Ftemplates\u002Faxios.ts",[178,184,185,188],{},[15,186,187],{},"@kubb\u002Fplugin-axios\u002Ftemplates\u002Fclient.ts",". Types only.",[163,190,191,204],{},[178,192,193,196,197,200,201],{},[15,194,195],{},"@kubb\u002Fplugin-axios\u002Ftemplates\u002Fcore.ts",", ",[15,198,199],{},"serializers.ts",", or ",[15,202,203],{},"standardSchema.ts",[178,205,206,188],{},[15,207,208],{},"@kubb\u002Fplugin-client\u002Ftemplates\u002F*",[163,210,211,217],{},[178,212,213,216],{},[15,214,215],{},"client.interceptors"," handlers that read axios objects",[178,218,219,220,223,224,29],{},"Move them to ",[15,221,222],{},"getAxiosInstance()",", or rewrite them. See ",[143,225,227],{"href":226},"#interceptors","Interceptors",[163,229,230,236],{},[178,231,232,233],{},"An axios instance as ",[15,234,235],{},"transport",[178,237,238],{},[15,239,240],{},"createAxiosTransport(instance)",[163,242,243,248],{},[178,244,245],{},[15,246,247],{},"defaultTransport.defaults",[178,249,250,253,254,257],{},[15,251,252],{},"getAxiosInstance().defaults",". ",[15,255,256],{},"defaultTransport"," is now a function.",[163,259,260,269],{},[178,261,262,263,265,266],{},"A ",[15,264,235],{}," that returns ",[15,267,268],{},"{ data, status, ... }",[178,270,271,272,200,275,278,279,282,283,286],{},"Return a web ",[15,273,274],{},"Response",[15,276,277],{},"{ webResponse, request, response }",". Response interceptors get a ",[15,280,281],{},"DecodedResponse",", the shape ",[15,284,285],{},"TransportResult"," had.",[163,288,289,298],{},[178,290,291,294,295],{},[15,292,293],{},"client.interceptors.error"," handlers that read ",[15,296,297],{},"status",[178,299,300,301,304,305,308],{},"Narrow with ",[15,302,303],{},"ResponseError.is"," first. They also get network errors (",[15,306,307],{},"AxiosError","), aborts, and validation errors.",[163,310,311,316],{},[178,312,313],{},[15,314,315],{},"AxiosOptions",[178,317,318,321,322,29],{},[15,319,320],{},"NativeOptions",", the same type: ",[15,323,324],{},"AxiosRequestConfig",[163,326,327,332],{},[178,328,329],{},[15,330,331],{},"validateStatus",[178,333,334],{},"Removed. The client splits success from error by status.",[163,336,337,345],{},[178,338,339,196,342],{},[15,340,341],{},"AxiosTransport",[15,343,344],{},"InterceptorChannel",[178,346,347,348,196,351,354,355,357],{},"Removed. ",[15,349,350],{},"createClientCore",[15,352,353],{},"ClientInstance",", and ",[15,356,227],{}," come from the core.",[163,359,360,365],{},[178,361,362],{},[15,363,364],{},"InterceptorFn",[178,366,367,368,371],{},"The core's ",[15,369,370],{},"InterceptorFn\u003CT>",", which gets the core objects.",[163,373,374,379],{},[178,375,376],{},[15,377,378],{},"defaultQuerySerializer",[178,380,381,200,384,387],{},[15,382,383],{},"serializeQuery",[15,385,386],{},"serializeStyledQuery"," for a styled query parameter.",[163,389,390,395],{},[178,391,392],{},[15,393,394],{},"defaultPathSerializer",[178,396,397,400,401,404,405,408,409,412],{},[15,398,399],{},"serializePath",", plus ",[15,402,403],{},"serializeStyledPath"," for a ",[15,406,407],{},"label"," or ",[15,410,411],{},"matrix"," parameter.",[163,414,415,420],{},[178,416,417],{},[15,418,419],{},"applyHeaderStyles",[178,421,422],{},[15,423,424],{},"serializeHeaders",[163,426,427,432],{},[178,428,429],{},[15,430,431],{},"codecs",[178,433,434,437,438,29],{},[15,435,436],{},"mediaTypes",". See ",[143,439,441],{"href":440},"#media-types","Media types",[163,443,444,458],{},[178,445,446,196,449,196,452,196,455],{},[15,447,448],{},"Codec",[15,450,451],{},"Deserializer",[15,453,454],{},"ContentBodySerializer",[15,456,457],{},"BodySerializer",[178,459,460],{},[15,461,462],{},"MediaType",[163,464,465,476],{},[178,466,467,196,470,196,473],{},[15,468,469],{},"serializer.body",[15,471,472],{},"defaultBodySerializer",[15,474,475],{},"isDefaultJsonBody",[178,477,262,478,480,481,29],{},[15,479,436],{}," entry, or ",[15,482,483],{},"defaultMediaTypes",[163,485,486,500],{},[178,487,488,196,491,196,494,196,497],{},[15,489,490],{},"responseType",[15,492,493],{},"ResponseType",[15,495,496],{},"ResponseTypeMap",[15,498,499],{},"resolveResponseType",[178,501,502,49,505,508,509,512],{},[15,503,504],{},"parseAs",[15,506,507],{},"ParseAs",", such as ",[15,510,511],{},"parseAs: 'blob'",", or a media type.",[163,514,515,520],{},[178,516,517],{},[15,518,519],{},"formMediaTypes",[178,521,522,49,525,528,529,532],{},[15,523,524],{},"multipartFormData",[15,526,527],{},"urlencoded",", written to ",[15,530,531],{},".kubb\u002FmediaTypes\u002F"," when the spec has a form body.",[163,534,535,546],{},[178,536,537,196,540,196,543],{},[15,538,539],{},"CallResult",[15,541,542],{},"isStreamed",[15,544,545],{},"getResponseContentType",[178,547,548,549,29],{},"Removed. Read ",[15,550,551],{},"result.contentType",[163,553,554,565],{},[178,555,556,196,559,196,562],{},[15,557,558],{},"toEventStream",[15,560,561],{},"EventStreamCall",[15,563,564],{},"EventStreamResult",[178,566,567,49,570,437,573,29],{},[15,568,569],{},"client.stream",[15,571,572],{},"StreamResult",[143,574,576],{"href":575},"#streams","Streams",[163,578,579,593],{},[178,580,581,196,584,200,587,589,590],{},[15,582,583],{},"ServerSentEvent",[15,585,586],{},"TypedEvent",[15,588,572],{}," from ",[15,591,592],{},".kubb\u002Fsse.ts",[178,594,595,596,29],{},"Import them from ",[15,597,598],{},".kubb\u002Fclient.ts",[163,600,601,614],{},[178,602,262,603,606,607,610,611],{},[15,604,605],{},"…Status2XX"," type, or a ",[15,608,609],{},"'2XX'"," key in a responses record or ",[15,612,613],{},"validator.error",[178,615,616,617,49,620,623],{},"Lower case: ",[15,618,619],{},"…Status2xx",[15,621,622],{},"'2xx'",". Upper-case keys are ignored.",[163,625,626,639],{},[178,627,628,631,632,635,636],{},[15,629,630],{},"clients\u002Fpayment\u002F"," for tag ",[15,633,634],{},"payment"," with ",[15,637,638],{},"parent: store",[178,640,641,644,645,29],{},[15,642,643],{},"clients\u002Fstore\u002Fpayment\u002F",". To keep one folder per tag, pass ",[15,646,647],{},"group: { type: 'tag', name: ({ group }) => group }",[163,649,650,663],{},[178,651,652,655,656,659,660],{},[15,653,654],{},"types\u002FPoint.ts"," for operation ",[15,657,658],{},"point"," next to schema ",[15,661,662],{},"Point",[178,664,665,668],{},[15,666,667],{},"types\u002FPointOperation.ts",", whenever a schema file has the same name, in any case.",[163,670,671,682],{},[178,672,673,635,676,49,679],{},[15,674,675],{},"new pet(config)",[15,677,678],{},"sdk",[15,680,681],{},"group: { type: 'tag' }",[178,683,684,687,688,691],{},[15,685,686],{},"new PetClient(config)",". Files and root class fields, such as ",[15,689,690],{},"pet",", stay the same.",[163,693,694,701],{},[178,695,696,589,699],{},[15,697,698],{},"clientGenerator",[15,700,17],{},[178,702,703,704,49,707,589,710,29],{},"Removed. Build on ",[15,705,706],{},"setupClient",[15,708,709],{},"clientDependencies",[15,711,21],{},[11,713,714,715,717,718,720],{},"Runtime values such as ",[15,716,28],{}," still come from the generated ",[15,719,598],{},". The common rewrites:",[722,723,724,757,795,811,916,932],"code-group",{},[54,725,729],{"language":726,"filename":727,"code":728,"class":58},"diff","Imports","- import type { RequestConfig } from '@kubb\u002Fplugin-axios\u002Ftemplates\u002Faxios.ts'\n- import type { ResolvedRequest } from '@kubb\u002Fplugin-axios\u002Ftemplates\u002Fcore.ts'\n+ import type { RequestConfig } from '@kubb\u002Fplugin-axios\u002Ftemplates\u002Fclient.ts'\n+ import type { ResolvedRequest } from '@kubb\u002Fplugin-client\u002Ftemplates\u002Fcore.ts'",[15,730,732,739,740,739,745,739,752],{"class":731},"language-diff",[63,733,735],{"class":734,"style":66},"line diff remove",[63,736,738],{"style":737},"color:#b31d28;--hls-dark:#fdaeb7"," import type { RequestConfig } from '@kubb\u002Fplugin-axios\u002Ftemplates\u002Faxios.ts'","\n",[63,741,742],{"class":734,"style":66},[63,743,744],{"style":737}," import type { ResolvedRequest } from '@kubb\u002Fplugin-axios\u002Ftemplates\u002Fcore.ts'",[63,746,748],{"class":747,"style":66},"line diff add",[63,749,751],{"style":750},"color:#22863a;--hls-dark:#85e89d"," import type { RequestConfig } from '@kubb\u002Fplugin-axios\u002Ftemplates\u002Fclient.ts'",[63,753,754],{"class":747,"style":66},[63,755,756],{"style":750}," import type { ResolvedRequest } from '@kubb\u002Fplugin-client\u002Ftemplates\u002Fcore.ts'",[54,758,761],{"language":726,"filename":759,"code":760,"class":58},"Axios instance","- import { client, defaultTransport } from '.\u002Fgen\u002F.kubb\u002Fclient'\n+ import { client, createAxiosTransport, getAxiosInstance } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\n- defaultTransport.defaults.timeout = 10_000\n- client.setConfig({ transport: axios.create({ baseURL }) })\n+ getAxiosInstance().defaults.timeout = 10_000\n+ client.setConfig({ transport: createAxiosTransport(axios.create({ baseURL })) })",[15,762,763,739,768,739,773,739,775,739,780,739,785,739,790],{"class":731},[63,764,765],{"class":734,"style":66},[63,766,767],{"style":737}," import { client, defaultTransport } from '.\u002Fgen\u002F.kubb\u002Fclient'",[63,769,770],{"class":747,"style":66},[63,771,772],{"style":750}," import { client, createAxiosTransport, getAxiosInstance } from '.\u002Fgen\u002F.kubb\u002Fclient'",[63,774],{"class":65,"style":66},[63,776,777],{"class":734,"style":66},[63,778,779],{"style":737}," defaultTransport.defaults.timeout = 10_000",[63,781,782],{"class":734,"style":66},[63,783,784],{"style":737}," client.setConfig({ transport: axios.create({ baseURL }) })",[63,786,787],{"class":747,"style":66},[63,788,789],{"style":750}," getAxiosInstance().defaults.timeout = 10_000",[63,791,792],{"class":747,"style":66},[63,793,794],{"style":750}," client.setConfig({ transport: createAxiosTransport(axios.create({ baseURL })) })",[54,796,799],{"language":726,"filename":797,"code":798,"class":58},"Transport","- transport: async () => ({ data: { id: 1 }, status: 200, statusText: 'OK', headers: new Headers(), request, response })\n+ transport: async () => Response.json({ id: 1 })",[15,800,801,739,806],{"class":731},[63,802,803],{"class":734,"style":66},[63,804,805],{"style":737}," transport: async () => ({ data: { id: 1 }, status: 200, statusText: 'OK', headers: new Headers(), request, response })",[63,807,808],{"class":747,"style":66},[63,809,810],{"style":750}," transport: async () => Response.json({ id: 1 })",[54,812,816],{"language":813,"filename":814,"code":815,"class":58},"typescript","Error interceptors","client.interceptors.error.use((error) => {\n  if (ResponseError.is(error) && error.status === 401) refreshToken()\n  return error\n})",[15,817,819,739,853,739,902,739,911],{"class":818},"language-typescript",[63,820,821,823,826,829,831,834,836,839,842,844,847,850],{"class":65,"style":66},[63,822,28],{"style":73},[63,824,29],{"style":825},"color:#d73a49;--hls-dark:#f97583",[63,827,828],{"style":90},"interceptors",[63,830,29],{"style":825},[63,832,833],{"style":90},"error",[63,835,29],{"style":825},[63,837,838],{"style":69},"use",[63,840,841],{"style":90},"((",[63,843,833],{"style":73},[63,845,846],{"style":90},") ",[63,848,849],{"style":825},"=> ",[63,851,852],{"style":90},"{",[63,854,855,858,861,864,867,869,872,874,876,878,881,883,885,888,891,894,896,899],{"class":65,"style":66},[63,856,857],{"style":90},"  ",[63,859,860],{"style":825},"if ",[63,862,863],{"style":90},"(",[63,865,866],{"style":69},"ResponseError",[63,868,29],{"style":825},[63,870,871],{"style":69},"is",[63,873,863],{"style":90},[63,875,833],{"style":73},[63,877,846],{"style":90},[63,879,880],{"style":825},"&& ",[63,882,833],{"style":73},[63,884,29],{"style":825},[63,886,887],{"style":90},"status ",[63,889,890],{"style":825},"=== ",[63,892,893],{"style":90},"401",[63,895,846],{"style":90},[63,897,898],{"style":69},"refreshToken",[63,900,901],{"style":90},"()",[63,903,904,906,909],{"class":65,"style":66},[63,905,857],{"style":90},[63,907,908],{"style":825},"return ",[63,910,833],{"style":73},[63,912,913],{"class":65,"style":66},[63,914,915],{"style":90},"})",[54,917,920],{"language":726,"filename":918,"code":919,"class":58},"Status ranges","- import type { ListPetsStatus4XX } from '.\u002Fgen\u002Ftypes\u002FListPets'\n+ import type { ListPetsStatus4xx } from '.\u002Fgen\u002Ftypes\u002FListPets'",[15,921,922,739,927],{"class":731},[63,923,924],{"class":734,"style":66},[63,925,926],{"style":737}," import type { ListPetsStatus4XX } from '.\u002Fgen\u002Ftypes\u002FListPets'",[63,928,929],{"class":747,"style":66},[63,930,931],{"style":750}," import type { ListPetsStatus4xx } from '.\u002Fgen\u002Ftypes\u002FListPets'",[54,933,936],{"language":726,"filename":934,"code":935,"class":58},"SDK classes","- import { pet } from '.\u002Fgen\u002Fsdk\u002Fpet\u002Fpet'\n- const api = new pet({ baseURL })\n+ import { PetClient } from '.\u002Fgen\u002Fsdk\u002Fpet\u002Fpet'\n+ const api = new PetClient({ baseURL })",[15,937,938,739,943,739,948,739,953],{"class":731},[63,939,940],{"class":734,"style":66},[63,941,942],{"style":737}," import { pet } from '.\u002Fgen\u002Fsdk\u002Fpet\u002Fpet'",[63,944,945],{"class":734,"style":66},[63,946,947],{"style":737}," const api = new pet({ baseURL })",[63,949,950],{"class":747,"style":66},[63,951,952],{"style":750}," import { PetClient } from '.\u002Fgen\u002Fsdk\u002Fpet\u002Fpet'",[63,954,955],{"class":747,"style":66},[63,956,957],{"style":750}," const api = new PetClient({ baseURL })",[31,959,227],{"id":828},[11,961,962,964,965,196,968,970,971,973,974,976],{},[15,963,215],{}," handlers now get the core objects: ",[15,966,967],{},"ResolvedRequest",[15,969,281],{},", and the error. The quickest fix moves each handler, unchanged, to ",[15,972,222],{},", the instance v5 called ",[15,975,256],{},":",[722,978,979,1060,1135],{},[54,980,983],{"language":813,"filename":981,"code":982,"class":58},"v5","client.interceptors.request.use((config) => {\n  config.headers.set('X-Request-ID', crypto.randomUUID())\n  return config\n})",[15,984,985,739,1013,739,1048,739,1056],{"class":818},[63,986,987,989,991,993,995,998,1000,1002,1004,1007,1009,1011],{"class":65,"style":66},[63,988,28],{"style":73},[63,990,29],{"style":825},[63,992,828],{"style":90},[63,994,29],{"style":825},[63,996,997],{"style":90},"request",[63,999,29],{"style":825},[63,1001,838],{"style":69},[63,1003,841],{"style":90},[63,1005,1006],{"style":73},"config",[63,1008,846],{"style":90},[63,1010,849],{"style":825},[63,1012,852],{"style":90},[63,1014,1015,1017,1019,1021,1024,1026,1029,1031,1035,1037,1040,1042,1045],{"class":65,"style":66},[63,1016,857],{"style":90},[63,1018,1006],{"style":73},[63,1020,29],{"style":825},[63,1022,1023],{"style":90},"headers",[63,1025,29],{"style":825},[63,1027,1028],{"style":69},"set",[63,1030,863],{"style":90},[63,1032,1034],{"style":1033},"color:#032f62;--hls-dark:#9ecbff","'X-Request-ID'",[63,1036,196],{"style":825},[63,1038,1039],{"style":73},"crypto",[63,1041,29],{"style":825},[63,1043,1044],{"style":69},"randomUUID",[63,1046,1047],{"style":90},"())",[63,1049,1050,1052,1054],{"class":65,"style":66},[63,1051,857],{"style":90},[63,1053,908],{"style":825},[63,1055,1006],{"style":73},[63,1057,1058],{"class":65,"style":66},[63,1059,915],{"style":90},[54,1061,1064],{"language":813,"filename":1062,"code":1063,"class":58},"v6, native axios","getAxiosInstance().interceptors.request.use((config) => {\n  config.headers.set('X-Request-ID', crypto.randomUUID())\n  return config\n})",[15,1065,1066,739,1095,739,1123,739,1131],{"class":818},[63,1067,1068,1071,1073,1075,1077,1079,1081,1083,1085,1087,1089,1091,1093],{"class":65,"style":66},[63,1069,1070],{"style":69},"getAxiosInstance",[63,1072,901],{"style":90},[63,1074,29],{"style":825},[63,1076,828],{"style":90},[63,1078,29],{"style":825},[63,1080,997],{"style":90},[63,1082,29],{"style":825},[63,1084,838],{"style":69},[63,1086,841],{"style":90},[63,1088,1006],{"style":73},[63,1090,846],{"style":90},[63,1092,849],{"style":825},[63,1094,852],{"style":90},[63,1096,1097,1099,1101,1103,1105,1107,1109,1111,1113,1115,1117,1119,1121],{"class":65,"style":66},[63,1098,857],{"style":90},[63,1100,1006],{"style":73},[63,1102,29],{"style":825},[63,1104,1023],{"style":90},[63,1106,29],{"style":825},[63,1108,1028],{"style":69},[63,1110,863],{"style":90},[63,1112,1034],{"style":1033},[63,1114,196],{"style":825},[63,1116,1039],{"style":73},[63,1118,29],{"style":825},[63,1120,1044],{"style":69},[63,1122,1047],{"style":90},[63,1124,1125,1127,1129],{"class":65,"style":66},[63,1126,857],{"style":90},[63,1128,908],{"style":825},[63,1130,1006],{"style":73},[63,1132,1133],{"class":65,"style":66},[63,1134,915],{"style":90},[54,1136,1139],{"language":813,"filename":1137,"code":1138,"class":58},"v6, core objects","client.interceptors.request.use((request) => {\n  request.headers['X-Request-ID'] = crypto.randomUUID()\n  return request\n})",[15,1140,1141,739,1167,739,1196,739,1204],{"class":818},[63,1142,1143,1145,1147,1149,1151,1153,1155,1157,1159,1161,1163,1165],{"class":65,"style":66},[63,1144,28],{"style":73},[63,1146,29],{"style":825},[63,1148,828],{"style":90},[63,1150,29],{"style":825},[63,1152,997],{"style":90},[63,1154,29],{"style":825},[63,1156,838],{"style":69},[63,1158,841],{"style":90},[63,1160,997],{"style":73},[63,1162,846],{"style":90},[63,1164,849],{"style":825},[63,1166,852],{"style":90},[63,1168,1169,1171,1173,1175,1177,1180,1182,1185,1188,1190,1192,1194],{"class":65,"style":66},[63,1170,857],{"style":90},[63,1172,997],{"style":73},[63,1174,29],{"style":825},[63,1176,1023],{"style":90},[63,1178,1179],{"style":90},"[",[63,1181,1034],{"style":1033},[63,1183,1184],{"style":90},"] ",[63,1186,1187],{"style":825},"= ",[63,1189,1039],{"style":73},[63,1191,29],{"style":825},[63,1193,1044],{"style":69},[63,1195,901],{"style":90},[63,1197,1198,1200,1202],{"class":65,"style":66},[63,1199,857],{"style":90},[63,1201,908],{"style":825},[63,1203,997],{"style":73},[63,1205,1206],{"class":65,"style":66},[63,1207,915],{"style":90},[11,1209,1210,1211,29],{},"Native response interceptors see the raw bytes, not the decoded body. The core form also works with ",[15,1212,1213],{},"@kubb\u002Fplugin-fetch",[31,1215,441],{"id":1216},"media-types",[11,1218,1219,1222,1223,1226,1227,253,1230,1233,1234,1236],{},[15,1220,1221],{},"serialize(body, contentType)"," becomes ",[15,1224,1225],{},"encode(body, context)",", with the type in ",[15,1228,1229],{},"context.contentType",[15,1231,1232],{},"decode(response, context)"," gets the ",[15,1235,274],{},", not a parsed body, so read the body yourself:",[54,1238,1240],{"language":726,"code":1239,"class":58},"- client.setConfig({ codecs: { 'application\u002Fxml': { deserialize: (raw) => parseXml(raw as string) } } })\n+ client.setConfig({ mediaTypes: { 'application\u002Fxml': { decode: async (response) => parseXml(await response.text()) } } })",[15,1241,1242,739,1247],{"class":731},[63,1243,1244],{"class":734,"style":66},[63,1245,1246],{"style":737}," client.setConfig({ codecs: { 'application\u002Fxml': { deserialize: (raw) => parseXml(raw as string) } } })",[63,1248,1249],{"class":747,"style":66},[63,1250,1251],{"style":750}," client.setConfig({ mediaTypes: { 'application\u002Fxml': { decode: async (response) => parseXml(await response.text()) } } })",[11,1253,1254,1255,437,1258,29],{},"A key can be a pattern, such as ",[15,1256,1257],{},"text\u002F*",[143,1259,1261],{"href":1260},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fserialization#built-in-media-types","Built-in media types",[31,1263,576],{"id":1264},"streams",[11,1266,1267,1269],{},[15,1268,569],{}," returns the stream directly:",[54,1271,1273],{"language":726,"code":1272,"class":58},"- const { stream } = await toEventStream(client({ method: 'GET', url: '\u002Fevents', responseType: 'stream' }), { shape: 'data' })\n+ const { stream } = await client.stream({ method: 'GET', url: '\u002Fevents', eventShape: 'data' })",[15,1274,1275,739,1280],{"class":731},[63,1276,1277],{"class":734,"style":66},[63,1278,1279],{"style":737}," const { stream } = await toEventStream(client({ method: 'GET', url: '\u002Fevents', responseType: 'stream' }), { shape: 'data' })",[63,1281,1282],{"class":747,"style":66},[63,1283,1284],{"style":750}," const { stream } = await client.stream({ method: 'GET', url: '\u002Fevents', eventShape: 'data' })",[11,1286,1287,49,1289,1292,1293,1295,1296,1299],{},[15,1288,572],{},[15,1290,1291],{},"UnwrappedStreamResult"," take the responses record and the full event type, so wrap a payload in ",[15,1294,583],{},". A ",[15,1297,1298],{},"TypedEvent\u003C…>"," stays as is:",[54,1301,1303],{"language":726,"code":1302,"class":58},"- let result: EventStreamResult\u003CPetEvent>\n+ let result: StreamResult\u003CStreamPetsResponses, true, ServerSentEvent\u003CPetEvent>>",[15,1304,1305,739,1310],{"class":731},[63,1306,1307],{"class":734,"style":66},[63,1308,1309],{"style":737}," let result: EventStreamResult\u003CPetEvent>",[63,1311,1312],{"class":747,"style":66},[63,1313,1314],{"style":750}," let result: StreamResult\u003CStreamPetsResponses, true, ServerSentEvent\u003CPetEvent>>",[11,1316,1317,1318,1320,1321,29],{},"An operation whose only success type is JSON Lines returns a ",[15,1319,572],{}," with one parsed item per line, not a string. For stream responses with headers, see ",[143,1322,1324],{"href":1323},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fserver-sent-events#stream-result-types","Stream result types",[31,1326,1328],{"id":1327},"behavior-changes","Behavior changes",[11,1330,1331],{},"These compile without errors, so check them by hand:",[157,1333,1334,1346],{},[160,1335,1336],{},[163,1337,1338,1341,1343],{},[166,1339,1340],{},"Area",[166,1342,981],{},[166,1344,1345],{},"v6",[173,1347,1348,1362,1384,1408,1432,1447,1462,1488,1508,1527],{},[163,1349,1350,1353,1359],{},[178,1351,1352],{},"Client",[178,1354,1355,1358],{},[15,1356,1357],{},"client.interceptors.request"," handlers ran in reverse, as in axios.",[178,1360,1361],{},"They run in registration order.",[163,1363,1364,1366,1376],{},[178,1365,1352],{},[178,1367,1368,1369,1372,1373,29],{},"A child from ",[15,1370,1371],{},"createClient()"," got its own ",[15,1374,1375],{},"axios.create()",[178,1377,1378,1379,1381,1382,29],{},"It inherits the ",[15,1380,235],{}," of ",[15,1383,28],{},[163,1385,1386,1389,1399],{},[178,1387,1388],{},"Requests",[178,1390,1391,1392,1395,1396,29],{},"A path or operation with its own ",[15,1393,1394],{},"servers"," used the client's ",[15,1397,1398],{},"baseURL",[178,1400,1401,1402,437,1404,29],{},"It calls its own server, unless the call sets ",[15,1403,1398],{},[143,1405,1407],{"href":1406},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests#set-the-base-url","Set the base URL",[163,1409,1410,1412,1422],{},[178,1411,1388],{},[178,1413,1414,1415,1418,1419,29],{},"An object query parameter without ",[15,1416,1417],{},"style",": ",[15,1420,1421],{},"filter[name]=odie",[178,1423,1424,1427,1428,1431],{},[15,1425,1426],{},"name=odie&age=3",". Set ",[15,1429,1430],{},"style: deepObject"," in the spec to keep the brackets.",[163,1433,1434,1436,1442],{},[178,1435,1388],{},[178,1437,1438,1439,1441],{},"An array or object header without ",[15,1440,1417],{}," went out as JSON.",[178,1443,1444],{},[15,1445,1446],{},"X-Ids: 3,4",[163,1448,1449,1451,1457],{},[178,1450,1388],{},[178,1452,1453,1454,29],{},"A space in a query value: ",[15,1455,1456],{},"+",[178,1458,1459],{},[15,1460,1461],{},"%20",[163,1463,1464,1466,1475],{},[178,1465,1388],{},[178,1467,1468,49,1471,1474],{},[15,1469,1470],{},"spaceDelimited",[15,1472,1473],{},"pipeDelimited"," repeated the key.",[178,1476,1477,1480,1481,1484,1485,29],{},[15,1478,1479],{},"explode"," defaults to ",[15,1482,1483],{},"false",", so an array goes out as ",[15,1486,1487],{},"ids=1%7C2",[163,1489,1490,1492,1498],{},[178,1491,1388],{},[178,1493,262,1494,1497],{},[15,1495,1496],{},"style: cookie"," parameter was percent-encoded.",[178,1499,1500,1501,1504,1505,29],{},"Sent as is. A value it cannot send, such as one with ",[15,1502,1503],{},";",", throws a ",[15,1506,1507],{},"TypeError",[163,1509,1510,1513,1516],{},[178,1511,1512],{},"Responses",[178,1514,1515],{},"Invalid JSON under a JSON media type became a string.",[178,1517,1518,1519,1522,1523,1526],{},"Throws a ",[15,1520,1521],{},"ParseError",". Catch it, or register a lenient ",[15,1524,1525],{},"application\u002Fjson"," entry.",[163,1528,1529,1531,1537],{},[178,1530,1512],{},[178,1532,1533,1534,29],{},"An aborted call or stream rejected with axios's ",[15,1535,1536],{},"CanceledError",[178,1538,1539],{},"It rejects with the signal's reason.",[11,1541,1542],{},"Also new in v6:",[1544,1545,1546,1562,1584,1591,1634,1651],"ul",{},[1547,1548,1549,1550,1553,1554,1557,1558,1561],"li",{},"Requests: ",[15,1551,1552],{},"body: null"," is sent as JSON ",[15,1555,1556],{},"null",". A stream call sends ",[15,1559,1560],{},"Accept: text\u002Fevent-stream",", or its JSON Lines media type. An auth requirement with several schemes sends all of them.",[1547,1563,1564,1565,1568,1569,1572,1573,1575,1576,1578,1579,1572,1582,29],{},"Responses: an empty body is ",[15,1566,1567],{},"undefined"," for every media type, text included. A failed call without a body has ",[15,1570,1571],{},"{ status, statusText }"," as ",[15,1574,833],{},". Every result and thrown ",[15,1577,866],{}," has the response ",[15,1580,1581],{},"Headers",[15,1583,1023],{},[1547,1585,1586,1587,1590],{},"Validation: ",[15,1588,1589],{},"ResponseError.data"," holds the validated body.",[1547,1592,1593,1594,1597,1598,1601,1602,1604,1605,1608,1609,1612,1613,1616,1617,1620,1621,1624,1625,253,1628,1630,1631,29],{},"Types: a ",[15,1595,1596],{},"2xx"," key is a success, a range key such as ",[15,1599,1600],{},"4xx"," types ",[15,1603,297],{}," as the codes it covers, and an exact code such as ",[15,1606,1607],{},"200"," wins over a range. XML, YAML, and CSV responses are ",[15,1610,1611],{},"string",", so JSON and XML together give ",[15,1614,1615],{},"data: Pet | string",". Image, audio, video, PDF, and ",[15,1618,1619],{},"application\u002Foctet-stream"," responses are ",[15,1622,1623],{},"Blob",", even with ",[15,1626,1627],{},"type: string",[15,1629,551],{}," is the bare media type, such as ",[15,1632,1633],{},"'text\u002Fhtml'",[1547,1635,1636,1637,354,1640,1643,1644,1646,1647,1650],{},"Serializers: each has its own file in ",[15,1638,1639],{},".kubb\u002Fserializers\u002F",[15,1641,1642],{},"setConfig({ serializer })"," merges per key. A ",[15,1645,350],{}," client gets no serializers, so pass them in its ",[15,1648,1649],{},"serializer"," config.",[1547,1652,1653,1654,1657,1658,29],{},"Servers: ",[15,1655,1656],{},"server.index"," no longer counts a server without a ",[15,1659,1660],{},"url",[11,1662,1663,1664,29],{},"If you upgrade from 5.12 or earlier, also check ",[143,1665,1667],{"href":1666},"#from-512-or-earlier","these changes",[31,1669,1671],{"id":1670},"query-plugins","Query plugins",[11,1673,1674,196,1677,196,1680,354,1683,1686],{},[15,1675,1676],{},"@kubb\u002Fplugin-react-query",[15,1678,1679],{},"@kubb\u002Fplugin-vue-query",[15,1681,1682],{},"@kubb\u002Fplugin-swr",[15,1684,1685],{},"@kubb\u002Fplugin-mcp"," work with v5 and v6, so you can upgrade them separately. They skip hooks for JSON Lines and event stream operations.",[31,1688,1690],{"id":1689},"less-common-cases","Less common cases",[40,1692,1694],{"id":1693},"new-in-v6","New in v6",[11,1696,1697],{},"These v6 features need no code change:",[1544,1699,1700,1709,1723],{},[1547,1701,1586,1702,1704,1705,1708],{},[15,1703,613],{}," takes a map by status, such as ",[15,1706,1707],{},"{ 404: getPetStatus404Schema }",", to check an error body against the schema of its status.",[1547,1710,1711,1712,49,1715,1718,1719,29],{},"Serializers: ",[15,1713,1714],{},"serializer.header",[15,1716,1717],{},"serializer.cookie"," are new. See ",[143,1720,1722],{"href":1721},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fserialization#override-parameter-serialization","Override parameter serialization",[1547,1724,1725,1726,589,1728,437,1730,29],{},"Servers: named servers are exported as ",[15,1727,1394],{},[15,1729,598],{},[143,1731,1733],{"href":1732},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests#named-servers","Named servers",[40,1735,1737],{"id":1736},"from-512-or-earlier","From 5.12 or earlier",[11,1739,1740],{},"These changed in 5.13 and compile without errors:",[1544,1742,1743,1746,1756],{},[1547,1744,1745],{},"A stream call keeps the adapter set on the call or instance, such as a test mock. Only a browser call with the default adapters switches to the fetch adapter.",[1547,1747,1748,1749,1751,1752,1755],{},"A successful stream call with a non-stream body, such as JSON, throws a ",[15,1750,1507],{}," with the body as its ",[15,1753,1754],{},"cause",". A successful answer with no body still ends as an empty stream.",[1547,1757,1758,1759,1762],{},"An event that does not end with a blank line is dropped, as in browser ",[15,1760,1761],{},"EventSource",", so end every event with one.",[40,1764,1766],{"id":1765},"sdk-root-class","SDK root class",[11,1768,1769,1770,1773,1774,29],{},"With an SDK root class, add interceptors on ",[15,1771,1772],{},"api.client",", because the root class shares one client with every tag. See ",[143,1775,1777],{"href":1776},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Foptions#sdk",[15,1778,678],{},{"title":1780,"searchDepth":1781,"depth":1781,"links":1782},"",5,[1783,1791,1792,1793,1794,1795,1796,1797],{"id":33,"depth":1784,"text":34,"children":1785},2,[1786,1788,1789,1790],{"id":42,"depth":1787,"text":43},3,{"id":94,"depth":1787,"text":95},{"id":118,"depth":1787,"text":119},{"id":137,"depth":1787,"text":138},{"id":155,"depth":1784,"text":146},{"id":828,"depth":1784,"text":227},{"id":1216,"depth":1784,"text":441},{"id":1264,"depth":1784,"text":576},{"id":1327,"depth":1784,"text":1328},{"id":1670,"depth":1784,"text":1671},{"id":1689,"depth":1784,"text":1690,"children":1798},[1799,1800,1801],{"id":1693,"depth":1787,"text":1694},{"id":1736,"depth":1787,"text":1737},{"id":1765,"depth":1787,"text":1766},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fmigrate-to-v6",1794776436556]