[{"data":1,"prerenderedAt":433},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts":3},{"id":4,"title":5,"body":6,"description":415,"extension":423,"frontmatter":424,"heading":5,"meta":425,"navigation":426,"order":427,"path":428,"seo":429,"sitemap":430,"source":4,"stem":431,"__hash__":432},"extensions\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Findex.md","TypeScript",{"type":7,"value":8,"toc":414},"minimark",[9,13,21,26,112,133,137,140,144,235,254,262,266,272],[10,11,12],"p",{},"The TypeScript plugin generates a type or interface for every schema in your OpenAPI spec, plus the request, response, and parameter types of each operation.",[10,14,15,16,20],{},"Kubb runs this plugin before the plugins that import its types, whatever the order of the ",[17,18,19],"code",{},"plugins"," array.",[22,23,25],"h2",{"id":24},"installation","Installation",[27,28,30,59,77,95],"code-group",{"sync":29},"package-manager",[31,32,37],"pre",{"language":33,"filename":34,"code":35,"class":36},"shell","bun","bun add -d @kubb\u002Fplugin-ts","highlights",[17,38,40],{"class":39},"language-shell",[41,42,45,49,53,56],"span",{"class":43,"style":44},"line","display: inline",[41,46,48],{"style":47},"color:#6f42c1;--hls-dark:#b392f0","bun ",[41,50,52],{"style":51},"color:#24292e;--hls-dark:#e1e4e8","add -d ",[41,54,55],{"style":51},"@",[41,57,58],{"style":51},"kubb\u002Fplugin-ts",[31,60,63],{"language":33,"filename":61,"code":62,"class":36},"pnpm","pnpm add -D @kubb\u002Fplugin-ts",[17,64,65],{"class":39},[41,66,67,70,73,75],{"class":43,"style":44},[41,68,69],{"style":47},"pnpm ",[41,71,72],{"style":51},"add -D ",[41,74,55],{"style":51},[41,76,58],{"style":51},[31,78,81],{"language":33,"filename":79,"code":80,"class":36},"npm","npm install --save-dev @kubb\u002Fplugin-ts",[17,82,83],{"class":39},[41,84,85,88,91,93],{"class":43,"style":44},[41,86,87],{"style":47},"npm ",[41,89,90],{"style":51},"install --save-dev ",[41,92,55],{"style":51},[41,94,58],{"style":51},[31,96,99],{"language":33,"filename":97,"code":98,"class":36},"yarn","yarn add -D @kubb\u002Fplugin-ts",[17,100,101],{"class":39},[41,102,103,106,108,110],{"class":43,"style":44},[41,104,105],{"style":47},"yarn ",[41,107,72],{"style":51},[41,109,55],{"style":51},[41,111,58],{"style":51},[10,113,114,115,118,119,124,125,128,129,132],{},"Or run ",[17,116,117],{},"kubb add plugin-ts"," to install the version the ",[120,121,123],"a",{"href":122},"\u002Fregistry","Kubb registry"," pins and add ",[17,126,127],{},"pluginTs()"," to ",[17,130,131],{},"kubb.config.ts",".",[22,134,136],{"id":135},"setup","Setup",[10,138,139],{},"No other plugins or packages are needed.",[22,141,143],{"id":142},"options-worth-knowing","Options worth knowing",[145,146,147,184,198,213,226],"ul",{},[148,149,150,153,154,157,158,161,162,161,165,168,169,172,173,161,176,179,180,183],"li",{},[17,151,152],{},"enum.type"," sets how enums are written: ",[17,155,156],{},"asConst"," (default), ",[17,159,160],{},"enum",", ",[17,163,164],{},"constEnum",[17,166,167],{},"literal",", or ",[17,170,171],{},"inlineLiteral",". ",[17,174,175],{},"enum.constCasing",[17,177,178],{},"enum.typeSuffix",", and ",[17,181,182],{},"enum.keyCasing"," tune the names.",[148,185,186,189,190,193,194,197],{},[17,187,188],{},"syntaxType"," writes object schemas as ",[17,191,192],{},"type"," aliases (default) or ",[17,195,196],{},"interface"," declarations.",[148,199,200,203,204,157,207,168,210,132],{},[17,201,202],{},"optionalType"," sets how optional properties are written: ",[17,205,206],{},"questionToken",[17,208,209],{},"undefined",[17,211,212],{},"questionTokenAndUndefined",[148,214,215,218,219,222,223,132],{},[17,216,217],{},"arrayType"," writes arrays as ",[17,220,221],{},"T[]"," (default) or ",[17,224,225],{},"Array\u003CT>",[148,227,228,231,232,132],{},[17,229,230],{},"group"," splits the output into folders by tag or path. It does not work with ",[17,233,234],{},"output.mode: 'file'",[10,236,237,238,241,242,245,246,249,250,253],{},"With the default OpenAPI adapter, ",[17,239,240],{},"int64"," fields are typed as ",[17,243,244],{},"bigint",", while JSON responses hold numbers. Set ",[17,247,248],{},"integerType: 'number'"," on ",[17,251,252],{},"adapterOas"," for most JSON APIs.",[10,255,256,257,261],{},"See ",[120,258,260],{"href":259},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Foptions","Options"," for every option and its default.",[22,263,265],{"id":264},"example","Example",[10,267,268,269,132],{},"The config below generates the types into ",[17,270,271],{},"src\u002Fgen\u002Ftypes",[31,273,276],{"language":274,"filename":131,"code":275,"class":36},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  plugins: [\n    pluginTs(),\n  ],\n})",[17,277,279,302,303,302,319,302,321,302,335,302,352,302,376,302,387,302,400,302,409],{"class":278},"language-typescript",[41,280,281,285,289,292,295,298],{"class":43,"style":44},[41,282,284],{"style":283},"color:#d73a49;--hls-dark:#f97583","import ",[41,286,288],{"style":287},"color:#005cc5;--hls-dark:#79b8ff","{ ",[41,290,291],{"style":51},"defineConfig ",[41,293,294],{"style":287},"} ",[41,296,297],{"style":283},"from ",[41,299,301],{"style":300},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[41,304,305,307,309,312,314,316],{"class":43,"style":44},[41,306,284],{"style":283},[41,308,288],{"style":287},[41,310,311],{"style":51},"pluginTs ",[41,313,294],{"style":287},[41,315,297],{"style":283},[41,317,318],{"style":300},"'@kubb\u002Fplugin-ts'",[41,320],{"class":43,"style":44},[41,322,323,326,329,332],{"class":43,"style":44},[41,324,325],{"style":283},"export ",[41,327,328],{"style":283},"default ",[41,330,331],{"style":47},"defineConfig",[41,333,334],{"style":287},"({",[41,336,337,340,343,346,349],{"class":43,"style":44},[41,338,339],{"style":287},"  ",[41,341,342],{"style":287},"input",[41,344,345],{"style":283},": ",[41,347,348],{"style":300},"'.\u002FpetStore.yaml'",[41,350,351],{"style":283},",",[41,353,354,356,359,361,363,366,368,371,374],{"class":43,"style":44},[41,355,339],{"style":283},[41,357,358],{"style":287},"output",[41,360,345],{"style":283},[41,362,288],{"style":287},[41,364,365],{"style":287},"path",[41,367,345],{"style":283},[41,369,370],{"style":300},"'.\u002Fsrc\u002Fgen' ",[41,372,373],{"style":287},"}",[41,375,351],{"style":283},[41,377,378,380,382,384],{"class":43,"style":44},[41,379,339],{"style":283},[41,381,19],{"style":287},[41,383,345],{"style":283},[41,385,386],{"style":287},"[",[41,388,389,392,395,398],{"class":43,"style":44},[41,390,391],{"style":287},"    ",[41,393,394],{"style":47},"pluginTs",[41,396,397],{"style":287},"()",[41,399,351],{"style":283},[41,401,402,404,407],{"class":43,"style":44},[41,403,339],{"style":283},[41,405,406],{"style":287},"]",[41,408,351],{"style":283},[41,410,411],{"class":43,"style":44},[41,412,413],{"style":287},"})",{"title":415,"searchDepth":416,"depth":416,"links":417},"",5,[418,420,421,422],{"id":24,"depth":419,"text":25},2,{"id":135,"depth":419,"text":136},{"id":142,"depth":419,"text":143},{"id":264,"depth":419,"text":265},"md",{},{},true,null,"\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts",{"title":5},{"loc":428},"extensions\u002Fkubb-labs\u002Fplugin-ts\u002Findex","A_epJ9ZF8KLDGPwyh5vcDeXbyPn48-O6H9FCxzYyO_g",1792850983652]