[{"data":1,"prerenderedAt":882,"buildId":883},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart":3},{"id":4,"title":5,"body":6,"description":862,"extension":863,"frontmatter":864,"heading":872,"meta":873,"navigation":875,"order":868,"path":876,"seo":877,"sitemap":878,"source":879,"stem":880,"__hash__":881},"docs\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart.md","Generate TypeScript from OpenAPI in five steps",{"type":7,"value":8,"toc":852},"minimark",[9,19,822,826],[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,692,705,709,722,732,757,762,766,783,804],"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: [\n pluginTs({ output: { path: 'models' } }),\n pluginAxios({ output: { path: 'clients' } }),\n ],\n})",[36,496,498,52,518,52,534,52,550,52,552,52,566,52,581,52,614,52,625,52,653,52,679,52,687],{"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],{"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,629,632,635,637,639,641,643,645,648,651],{"class":42,"style":43},[40,628,218],{"style":136},[40,630,631],{"style":46},"pluginTs",[40,633,634],{"style":136},"({ ",[40,636,587],{"style":136},[40,638,140],{"style":77},[40,640,505],{"style":136},[40,642,271],{"style":136},[40,644,140],{"style":77},[40,646,647],{"style":164},"'models' ",[40,649,650],{"style":136},"} })",[40,652,580],{"style":77},[40,654,655,657,660,662,664,666,668,670,672,675,677],{"class":42,"style":43},[40,656,218],{"style":77},[40,658,659],{"style":46},"pluginAxios",[40,661,634],{"style":136},[40,663,587],{"style":136},[40,665,140],{"style":77},[40,667,505],{"style":136},[40,669,271],{"style":136},[40,671,140],{"style":77},[40,673,674],{"style":164},"'clients' ",[40,676,650],{"style":136},[40,678,580],{"style":77},[40,680,681,683,685],{"class":42,"style":43},[40,682,156],{"style":77},[40,684,434],{"style":136},[40,686,580],{"style":77},[40,688,689],{"class":42,"style":43},[40,690,691],{"style":136},"})",[693,694,696,697,700,701,704],"blockquote",{"as":695},"warning","",[36,698,699],{},"clean: true"," empties ",[36,702,703],{},"src\u002Fgen"," before each run. Keep your own files elsewhere.",[24,706,708],{"id":707},"_4-generate-the-client","Generate the client",[29,710,712],{"language":31,"filename":32,"code":711,"class":34},"npx kubb generate",[36,713,714],{"class":38},[40,715,716,719],{"class":42,"style":43},[40,717,718],{"style":46},"npx ",[40,720,721],{"style":50},"kubb generate",[10,723,724,725,727,728,731],{},"Kubb writes this tree. ",[36,726,236],{}," in ",[36,729,730],{},"src\u002Fgen\u002Fclients\u002FgetPetById.ts"," takes a typed path parameter and returns a typed result.",[733,734],"file-tree",{":tree":735},[736],{"name":737,"type":738,"children":739},"src","dir",[740],{"name":741,"type":738,"children":742},"gen",[743,745,750],{"name":744,"type":738},".kubb",{"name":746,"type":738,"children":747},"clients",[748],{"name":749},"getPetById.ts",{"name":751,"type":738,"children":752},"models",[753,755],{"name":754},"GetPetById.ts",{"name":756},"Pet.ts",[10,758,759,761],{},[36,760,744],{}," holds shared client and serialization helpers.",[24,763,765],{"id":764},"_5-regenerate-after-a-change","Change the spec",[10,767,768,769,772,773,727,775,777,778,780,781,151],{},"Add a ",[36,770,771],{},"tag"," property to ",[36,774,399],{},[36,776,123],{},", next to ",[36,779,426],{}," and ",[36,782,253],{},[29,784,786],{"language":127,"filename":123,"code":785,"class":34},"tag:\n type: string",[36,787,788,52,794],{"class":131},[40,789,790,792],{"class":42,"style":43},[40,791,771],{"style":136},[40,793,151],{"style":77},[40,795,796,798,800,802],{"class":42,"style":43},[40,797,156],{"style":77},[40,799,300],{"style":136},[40,801,140],{"style":77},[40,803,480],{"style":164},[10,805,806,807,809,810,727,812,815,816,818,819,821],{},"Run ",[36,808,711],{}," again. ",[36,811,399],{},[36,813,814],{},"src\u002Fgen\u002Fmodels\u002FPet.ts"," now has an optional ",[36,817,771],{}," field, because ",[36,820,278],{}," does not list it.",[24,823,825],{"id":824},"continue","Continue",[827,828,829,841,846],"card-group",{},[830,831,835,836,840],"card",{"title":832,"icon":833,"to":834},"Call generated operations","i-iconoir-code","\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fcalling-operations","Use the generated Axios client. ",[14,837,839],{"href":838},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests#set-the-base-url","Set the base URL"," for your API.",[830,842,845],{"title":484,"icon":843,"to":844},"i-iconoir-settings","\u002Fdocs\u002F5.x\u002Fhow-to\u002Frecipes","Add React or Vue hooks, validation, and mocks.",[830,847,851],{"title":848,"icon":849,"to":850},"Configuration reference","i-iconoir-bookmark","\u002Fdocs\u002F5.x\u002Freference\u002Fconfiguration","Look up spec versions, options, and config formats.",{"title":696,"searchDepth":853,"depth":853,"links":854},5,[855,857,858,859,860,861],{"id":26,"depth":856,"text":27},2,{"id":116,"depth":856,"text":117},{"id":483,"depth":856,"text":484},{"id":707,"depth":856,"text":708},{"id":764,"depth":856,"text":765},{"id":824,"depth":856,"text":825},"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":865,"title":5,"description":862,"outline":866,"order":868,"navigation":869},"doc",[856,867],3,1,{"title":870,"icon":871},"Generate your first client","i-iconoir-rocket","Your first TypeScript client from an API spec",{"layout":865,"outline":874},[856,867],{"title":870,"icon":871},"\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart",{"title":5,"description":862},{"loc":876},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Ftutorials\u002Fquickstart.md","docs\u002F5.x\u002Ftutorials\u002Fquickstart","GWx6NYvXRcXWoekBVsoqNOutn4T5ZLMNHNEjiPosBAk",1795727674422,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]