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