[{"data":1,"prerenderedAt":867,"buildId":868},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart":3},{"id":4,"title":5,"body":6,"description":847,"extension":848,"frontmatter":849,"heading":857,"meta":858,"navigation":860,"order":853,"path":861,"seo":862,"sitemap":863,"source":864,"stem":865,"__hash__":866},"docs\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart.md","Generate TypeScript from OpenAPI in five steps",{"type":7,"value":8,"toc":837},"minimark",[9,19,807,811],[10,11,12,13,18],"p",{},"Kubb turns a one-operation Petstore spec into TypeScript types and an Axios client. Then you change the spec and run Kubb again. You need npm and a Node.js version from ",[14,15,17],"a",{"href":16},"\u002Fdocs\u002F5.x\u002Fintroduction\u002Finstallation#prerequisites","Prerequisites",".",[20,21,23,28,107,114,118,125,481,485,491,677,690,694,707,717,742,747,751,768,789],"steps",{"level":22},"2",[24,25,27],"h2",{"id":26},"_1-create-a-project","Create a project",[29,30,35],"pre",{"language":31,"filename":32,"code":33,"class":34},"shell","Terminal","mkdir kubb-first-client\ncd kubb-first-client\nnpm init -y\nnpm pkg set type=module\nnpm install -D kubb typescript @kubb\u002Fplugin-ts @kubb\u002Fplugin-axios\nnpm install axios","highlights",[36,37,39,52,53,52,60,52,68,52,82,52,100],"code",{"class":38},"language-shell",[40,41,44,48],"span",{"class":42,"style":43},"line","display: inline",[40,45,47],{"style":46},"color:#6f42c1;--hls-dark:#b392f0","mkdir ",[40,49,51],{"style":50},"color:#24292e;--hls-dark:#e1e4e8","kubb-first-client","\n",[40,54,55,58],{"class":42,"style":43},[40,56,57],{"style":46},"cd ",[40,59,51],{"style":50},[40,61,62,65],{"class":42,"style":43},[40,63,64],{"style":46},"npm ",[40,66,67],{"style":50},"init -y",[40,69,70,72,75,79],{"class":42,"style":43},[40,71,64],{"style":46},[40,73,74],{"style":50},"pkg set type",[40,76,78],{"style":77},"color:#d73a49;--hls-dark:#f97583","=",[40,80,81],{"style":50},"module",[40,83,84,86,89,92,95,97],{"class":42,"style":43},[40,85,64],{"style":46},[40,87,88],{"style":50},"install -D kubb typescript ",[40,90,91],{"style":50},"@",[40,93,94],{"style":50},"kubb\u002Fplugin-ts ",[40,96,91],{"style":50},[40,98,99],{"style":50},"kubb\u002Fplugin-axios",[40,101,102,104],{"class":42,"style":43},[40,103,64],{"style":46},[40,105,106],{"style":50},"install axios",[10,108,109,110,113],{},"The generated client calls ",[36,111,112],{},"axios"," at runtime, so it is a regular dependency.",[24,115,117],{"id":116},"_2-add-the-specification","Add the spec",[10,119,120,121,124],{},"Create ",[36,122,123],{},"petStore.yaml"," in the project root:",[29,126,129],{"language":127,"filename":123,"code":128,"class":34},"yaml","openapi: 3.0.3\ninfo:\n title: Petstore\n version: 1.0.0\nservers:\n - url: https:\u002F\u002Fpetstore.swagger.io\u002Fv2\npaths:\n \u002Fpet\u002F{petId}:\n get:\n operationId: getPetById\n parameters:\n - name: petId\n in: path\n required: true\n schema:\n type: integer\n responses:\n '200':\n description: A pet\n content:\n application\u002Fjson:\n schema:\n $ref: '#\u002Fcomponents\u002Fschemas\u002FPet'\ncomponents:\n schemas:\n Pet:\n type: object\n required: [id, name]\n properties:\n id:\n type: integer\n name:\n type: string",[36,130,132,52,144,52,152,52,166,52,178,52,185,52,198,52,205,52,214,52,224,52,237,52,246,52,259,52,272,52,284,52,293,52,306,52,315,52,325,52,337,52,346,52,355,52,364,52,377,52,384,52,393,52,402,52,413,52,435,52,444,52,452,52,462,52,470],{"class":131},"language-yaml",[40,133,134,138,141],{"class":42,"style":43},[40,135,137],{"style":136},"color:#005cc5;--hls-dark:#79b8ff","openapi",[40,139,140],{"style":77},": ",[40,142,143],{"style":136},"3.0.3",[40,145,146,149],{"class":42,"style":43},[40,147,148],{"style":136},"info",[40,150,151],{"style":77},":",[40,153,154,157,160,162],{"class":42,"style":43},[40,155,156],{"style":77}," ",[40,158,159],{"style":136},"title",[40,161,140],{"style":77},[40,163,165],{"style":164},"color:#032f62;--hls-dark:#9ecbff","Petstore",[40,167,168,170,173,175],{"class":42,"style":43},[40,169,156],{"style":164},[40,171,172],{"style":136},"version",[40,174,140],{"style":77},[40,176,177],{"style":136},"1.0.0",[40,179,180,183],{"class":42,"style":43},[40,181,182],{"style":136},"servers",[40,184,151],{"style":77},[40,186,187,190,193,195],{"class":42,"style":43},[40,188,189],{"style":77}," - ",[40,191,192],{"style":136},"url",[40,194,140],{"style":77},[40,196,197],{"style":164},"https:\u002F\u002Fpetstore.swagger.io\u002Fv2",[40,199,200,203],{"class":42,"style":43},[40,201,202],{"style":136},"paths",[40,204,151],{"style":77},[40,206,207,209,212],{"class":42,"style":43},[40,208,156],{"style":77},[40,210,211],{"style":136},"\u002Fpet\u002F{petId}",[40,213,151],{"style":77},[40,215,216,219,222],{"class":42,"style":43},[40,217,218],{"style":77}," ",[40,220,221],{"style":136},"get",[40,223,151],{"style":77},[40,225,226,229,232,234],{"class":42,"style":43},[40,227,228],{"style":77}," ",[40,230,231],{"style":136},"operationId",[40,233,140],{"style":77},[40,235,236],{"style":164},"getPetById",[40,238,239,241,244],{"class":42,"style":43},[40,240,228],{"style":164},[40,242,243],{"style":136},"parameters",[40,245,151],{"style":77},[40,247,248,251,254,256],{"class":42,"style":43},[40,249,250],{"style":77}," - ",[40,252,253],{"style":136},"name",[40,255,140],{"style":77},[40,257,258],{"style":164},"petId",[40,260,261,264,267,269],{"class":42,"style":43},[40,262,263],{"style":164}," ",[40,265,266],{"style":136},"in",[40,268,140],{"style":77},[40,270,271],{"style":164},"path",[40,273,274,276,279,281],{"class":42,"style":43},[40,275,263],{"style":164},[40,277,278],{"style":136},"required",[40,280,140],{"style":77},[40,282,283],{"style":136},"true",[40,285,286,288,291],{"class":42,"style":43},[40,287,263],{"style":136},[40,289,290],{"style":136},"schema",[40,292,151],{"style":77},[40,294,295,298,301,303],{"class":42,"style":43},[40,296,297],{"style":77}," ",[40,299,300],{"style":136},"type",[40,302,140],{"style":77},[40,304,305],{"style":164},"integer",[40,307,308,310,313],{"class":42,"style":43},[40,309,228],{"style":164},[40,311,312],{"style":136},"responses",[40,314,151],{"style":77},[40,316,317,320,323],{"class":42,"style":43},[40,318,319],{"style":77}," ",[40,321,322],{"style":136},"'200'",[40,324,151],{"style":77},[40,326,327,329,332,334],{"class":42,"style":43},[40,328,263],{"style":77},[40,330,331],{"style":136},"description",[40,333,140],{"style":77},[40,335,336],{"style":164},"A pet",[40,338,339,341,344],{"class":42,"style":43},[40,340,263],{"style":164},[40,342,343],{"style":136},"content",[40,345,151],{"style":77},[40,347,348,350,353],{"class":42,"style":43},[40,349,297],{"style":77},[40,351,352],{"style":136},"application\u002Fjson",[40,354,151],{"style":77},[40,356,357,360,362],{"class":42,"style":43},[40,358,359],{"style":77}," ",[40,361,290],{"style":136},[40,363,151],{"style":77},[40,365,366,369,372,374],{"class":42,"style":43},[40,367,368],{"style":77}," ",[40,370,371],{"style":136},"$ref",[40,373,140],{"style":77},[40,375,376],{"style":164},"'#\u002Fcomponents\u002Fschemas\u002FPet'",[40,378,379,382],{"class":42,"style":43},[40,380,381],{"style":136},"components",[40,383,151],{"style":77},[40,385,386,388,391],{"class":42,"style":43},[40,387,156],{"style":77},[40,389,390],{"style":136},"schemas",[40,392,151],{"style":77},[40,394,395,397,400],{"class":42,"style":43},[40,396,218],{"style":77},[40,398,399],{"style":136},"Pet",[40,401,151],{"style":77},[40,403,404,406,408,410],{"class":42,"style":43},[40,405,228],{"style":77},[40,407,300],{"style":136},[40,409,140],{"style":77},[40,411,412],{"style":164},"object",[40,414,415,417,419,421,424,427,430,432],{"class":42,"style":43},[40,416,228],{"style":164},[40,418,278],{"style":136},[40,420,140],{"style":77},[40,422,423],{"style":136},"[",[40,425,426],{"style":164},"id",[40,428,429],{"style":77},", ",[40,431,253],{"style":164},[40,433,434],{"style":136},"]",[40,436,437,439,442],{"class":42,"style":43},[40,438,228],{"style":136},[40,440,441],{"style":136},"properties",[40,443,151],{"style":77},[40,445,446,448,450],{"class":42,"style":43},[40,447,319],{"style":77},[40,449,426],{"style":136},[40,451,151],{"style":77},[40,453,454,456,458,460],{"class":42,"style":43},[40,455,263],{"style":77},[40,457,300],{"style":136},[40,459,140],{"style":77},[40,461,305],{"style":164},[40,463,464,466,468],{"class":42,"style":43},[40,465,319],{"style":164},[40,467,253],{"style":136},[40,469,151],{"style":77},[40,471,472,474,476,478],{"class":42,"style":43},[40,473,263],{"style":77},[40,475,300],{"style":136},[40,477,140],{"style":77},[40,479,480],{"style":164},"string",[24,482,484],{"id":483},"_3-configure-generation","Configure generation",[10,486,120,487,490],{},[36,488,489],{},"kubb.config.ts"," beside the spec:",[29,492,495],{"language":493,"filename":489,"code":494,"class":34},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { pluginAxios } from '@kubb\u002Fplugin-axios'\n\nexport default defineConfig({\n input: '.\u002FpetStore.yaml',\n output: { path: '.\u002Fsrc\u002Fgen', clean: true },\n plugins: [pluginTs({ output: { path: 'models' } }), pluginAxios({ output: { path: 'clients' } })],\n})",[36,496,498,52,518,52,534,52,550,52,552,52,566,52,581,52,614,52,672],{"class":497},"language-typescript",[40,499,500,503,506,509,512,515],{"class":42,"style":43},[40,501,502],{"style":77},"import ",[40,504,505],{"style":136},"{ ",[40,507,508],{"style":50},"defineConfig ",[40,510,511],{"style":136},"} ",[40,513,514],{"style":77},"from ",[40,516,517],{"style":164},"'kubb\u002Fconfig'",[40,519,520,522,524,527,529,531],{"class":42,"style":43},[40,521,502],{"style":77},[40,523,505],{"style":136},[40,525,526],{"style":50},"pluginTs ",[40,528,511],{"style":136},[40,530,514],{"style":77},[40,532,533],{"style":164},"'@kubb\u002Fplugin-ts'",[40,535,536,538,540,543,545,547],{"class":42,"style":43},[40,537,502],{"style":77},[40,539,505],{"style":136},[40,541,542],{"style":50},"pluginAxios ",[40,544,511],{"style":136},[40,546,514],{"style":77},[40,548,549],{"style":164},"'@kubb\u002Fplugin-axios'",[40,551],{"class":42,"style":43},[40,553,554,557,560,563],{"class":42,"style":43},[40,555,556],{"style":77},"export ",[40,558,559],{"style":77},"default ",[40,561,562],{"style":46},"defineConfig",[40,564,565],{"style":136},"({",[40,567,568,570,573,575,578],{"class":42,"style":43},[40,569,156],{"style":136},[40,571,572],{"style":136},"input",[40,574,140],{"style":77},[40,576,577],{"style":164},"'.\u002FpetStore.yaml'",[40,579,580],{"style":77},",",[40,582,583,585,588,590,592,594,596,599,601,604,606,609,612],{"class":42,"style":43},[40,584,156],{"style":77},[40,586,587],{"style":136},"output",[40,589,140],{"style":77},[40,591,505],{"style":136},[40,593,271],{"style":136},[40,595,140],{"style":77},[40,597,598],{"style":164},"'.\u002Fsrc\u002Fgen'",[40,600,429],{"style":77},[40,602,603],{"style":136},"clean",[40,605,140],{"style":77},[40,607,608],{"style":136},"true ",[40,610,611],{"style":136},"}",[40,613,580],{"style":77},[40,615,616,618,621,623,625,628,631,633,635,637,639,641,644,647,649,652,654,656,658,660,662,664,667,670],{"class":42,"style":43},[40,617,156],{"style":77},[40,619,620],{"style":136},"plugins",[40,622,140],{"style":77},[40,624,423],{"style":136},[40,626,627],{"style":46},"pluginTs",[40,629,630],{"style":136},"({ ",[40,632,587],{"style":136},[40,634,140],{"style":77},[40,636,505],{"style":136},[40,638,271],{"style":136},[40,640,140],{"style":77},[40,642,643],{"style":164},"'models' ",[40,645,646],{"style":136},"} })",[40,648,429],{"style":77},[40,650,651],{"style":46},"pluginAxios",[40,653,630],{"style":136},[40,655,587],{"style":136},[40,657,140],{"style":77},[40,659,505],{"style":136},[40,661,271],{"style":136},[40,663,140],{"style":77},[40,665,666],{"style":164},"'clients' ",[40,668,669],{"style":136},"} })]",[40,671,580],{"style":77},[40,673,674],{"class":42,"style":43},[40,675,676],{"style":136},"})",[678,679,681,682,685,686,689],"blockquote",{"as":680},"warning","",[36,683,684],{},"clean: true"," empties ",[36,687,688],{},"src\u002Fgen"," before each run. Keep your own files elsewhere.",[24,691,693],{"id":692},"_4-generate-the-client","Generate the client",[29,695,697],{"language":31,"filename":32,"code":696,"class":34},"npx kubb generate",[36,698,699],{"class":38},[40,700,701,704],{"class":42,"style":43},[40,702,703],{"style":46},"npx ",[40,705,706],{"style":50},"kubb generate",[10,708,709,710,712,713,716],{},"Kubb writes this tree. ",[36,711,236],{}," in ",[36,714,715],{},"src\u002Fgen\u002Fclients\u002FgetPetById.ts"," takes a typed path parameter and returns a typed result.",[718,719],"file-tree",{":tree":720},[721],{"name":722,"type":723,"children":724},"src","dir",[725],{"name":726,"type":723,"children":727},"gen",[728,730,735],{"name":729,"type":723},".kubb",{"name":731,"type":723,"children":732},"clients",[733],{"name":734},"getPetById.ts",{"name":736,"type":723,"children":737},"models",[738,740],{"name":739},"GetPetById.ts",{"name":741},"Pet.ts",[10,743,744,746],{},[36,745,729],{}," holds shared client and serialization helpers.",[24,748,750],{"id":749},"_5-regenerate-after-a-change","Change the spec",[10,752,753,754,757,758,712,760,762,763,765,766,151],{},"Add a ",[36,755,756],{},"tag"," property to ",[36,759,399],{},[36,761,123],{},", next to ",[36,764,426],{}," and ",[36,767,253],{},[29,769,771],{"language":127,"filename":123,"code":770,"class":34},"tag:\n type: string",[36,772,773,52,779],{"class":131},[40,774,775,777],{"class":42,"style":43},[40,776,756],{"style":136},[40,778,151],{"style":77},[40,780,781,783,785,787],{"class":42,"style":43},[40,782,156],{"style":77},[40,784,300],{"style":136},[40,786,140],{"style":77},[40,788,480],{"style":164},[10,790,791,792,794,795,712,797,800,801,803,804,806],{},"Run ",[36,793,696],{}," again. ",[36,796,399],{},[36,798,799],{},"src\u002Fgen\u002Fmodels\u002FPet.ts"," now has an optional ",[36,802,756],{}," field, because ",[36,805,278],{}," does not list it.",[24,808,810],{"id":809},"continue","Continue",[812,813,814,826,831],"card-group",{},[815,816,820,821,825],"card",{"title":817,"icon":818,"to":819},"Call generated operations","i-iconoir-code","\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fcalling-operations","Use the generated Axios client. ",[14,822,824],{"href":823},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests#set-the-base-url","Set the base URL"," for your API.",[815,827,830],{"title":484,"icon":828,"to":829},"i-iconoir-settings","\u002Fdocs\u002F5.x\u002Fhow-to\u002Frecipes","Add React or Vue hooks, validation, and mocks.",[815,832,836],{"title":833,"icon":834,"to":835},"Configuration reference","i-iconoir-bookmark","\u002Fdocs\u002F5.x\u002Freference\u002Fconfiguration","Look up spec versions, options, and config formats.",{"title":681,"searchDepth":838,"depth":838,"links":839},5,[840,842,843,844,845,846],{"id":26,"depth":841,"text":27},2,{"id":116,"depth":841,"text":117},{"id":483,"depth":841,"text":484},{"id":692,"depth":841,"text":693},{"id":749,"depth":841,"text":750},{"id":809,"depth":841,"text":810},"Follow five steps to generate TypeScript types and a typed Axios client from a one-operation Petstore API spec, then inspect the output and regenerate it.","md",{"layout":850,"title":5,"description":847,"outline":851,"order":853,"navigation":854},"doc",[841,852],3,1,{"title":855,"icon":856},"Generate your first client","i-iconoir-rocket","Your first TypeScript client from an API spec",{"layout":850,"outline":859},[841,852],{"title":855,"icon":856},"\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart",{"title":5,"description":847},{"loc":861},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart.md","docs\u002F5.x\u002Ftutorials\u002Fquickstart","IdlRsUAFCOIPB5MJ9FeXgBiccp4y8c2d9zXvKuBU2eo",1795989034765,"2e8b4c62-5b8c-4587-97c0-530d08a9bd53"]