[{"data":1,"prerenderedAt":423},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-faker":3},{"id":4,"title":5,"body":6,"description":404,"extension":412,"frontmatter":413,"heading":5,"meta":414,"navigation":415,"order":416,"path":417,"seo":418,"sitemap":419,"source":4,"stem":420,"__hash__":421,"hasPopups":422},"extensions\u002Fextensions\u002Fkubb-labs\u002Fplugin-faker\u002Findex.md","Faker",{"type":7,"value":8,"toc":403},"minimark",[9,13,21,26,110,131,135,174,178,265,273,277,280],[10,11,12],"p",{},"The Faker plugin generates one factory function per schema. Each factory returns mock data from Faker.js and accepts partial data that overrides the generated values.",[10,14,15,16,20],{},"Use the factories in tests, Storybook, and local development without a running backend. ",[17,18,19],"code",{},"@kubb\u002Fplugin-msw"," can use them to fill mock responses.",[22,23,25],"h2",{"id":24},"installation","Installation",[27,28,30,59,76,94],"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-faker","shiki shiki-themes github-light github-dark dark:github-dark",[17,38,40],{"class":39},"language-shell",[41,42,45,48,52,56],"span",{"class":43,"style":44},"line","display: inline",[41,46,34],{"style":47},"color:#6F42C1;--shiki-dark:#B392F0",[41,49,51],{"style":50},"color:#032F62;--shiki-dark:#9ECBFF"," add",[41,53,55],{"style":54},"color:#005CC5;--shiki-dark:#79B8FF"," -d",[41,57,58],{"style":50}," @kubb\u002Fplugin-faker",[31,60,63],{"language":33,"filename":61,"code":62,"class":36},"pnpm","pnpm add -D @kubb\u002Fplugin-faker",[17,64,65],{"class":39},[41,66,67,69,71,74],{"class":43,"style":44},[41,68,61],{"style":47},[41,70,51],{"style":50},[41,72,73],{"style":54}," -D",[41,75,58],{"style":50},[31,77,80],{"language":33,"filename":78,"code":79,"class":36},"npm","npm install --save-dev @kubb\u002Fplugin-faker",[17,81,82],{"class":39},[41,83,84,86,89,92],{"class":43,"style":44},[41,85,78],{"style":47},[41,87,88],{"style":50}," install",[41,90,91],{"style":54}," --save-dev",[41,93,58],{"style":50},[31,95,98],{"language":33,"filename":96,"code":97,"class":36},"yarn","yarn add -D @kubb\u002Fplugin-faker",[17,99,100],{"class":39},[41,101,102,104,106,108],{"class":43,"style":44},[41,103,96],{"style":47},[41,105,51],{"style":50},[41,107,73],{"style":54},[41,109,58],{"style":50},[10,111,112,113,116,117,122,123,126,127,130],{},"Or run ",[17,114,115],{},"kubb add plugin-faker"," to install the version the ",[118,119,121],"a",{"href":120},"\u002Fregistry","Kubb registry"," pins and add ",[17,124,125],{},"pluginFaker()"," to ",[17,128,129],{},"kubb.config.ts",".",[22,132,134],{"id":133},"setup","Setup",[136,137,138,146,153],"ul",{},[139,140,141,142,145],"li",{},"Add ",[17,143,144],{},"@kubb\u002Fplugin-ts"," for the factory return types. Generation fails without it.",[139,147,148,149,152],{},"Install ",[17,150,151],{},"@faker-js\u002Ffaker"," v10 in the app that uses the generated code.",[139,154,148,155,158,159,162,163,166,167,170,171,130],{},[17,156,157],{},"dayjs",", ",[17,160,161],{},"moment",", or ",[17,164,165],{},"randexp"," when you pick it in ",[17,168,169],{},"dateParser"," or ",[17,172,173],{},"regexGenerator",[22,175,177],{"id":176},"options-worth-knowing","Options worth knowing",[136,179,180,190,199,237,251],{},[139,181,182,185,186,189],{},[17,183,184],{},"seed"," passes a fixed seed to ",[17,187,188],{},"faker.seed(...)",", so every run returns the same data.",[139,191,192,195,196,130],{},[17,193,194],{},"locale"," sets the Faker locale. The default is ",[17,197,198],{},"en",[139,200,201,203,204,207,208,211,212,215,216,162,218,220,221,224,225,207,227,229,230,233,234,130],{},[17,202,169],{}," formats ",[17,205,206],{},"date"," and ",[17,209,210],{},"time"," strings with ",[17,213,214],{},"faker"," (default), ",[17,217,157],{},[17,219,161],{},". ",[17,222,223],{},"date-time"," values always use Faker. ",[17,226,157],{},[17,228,161],{}," do not work when the adapter types a date or time as ",[17,231,232],{},"Date",", for example with ",[17,235,236],{},"dateType: 'date'",[139,238,239,241,242,245,246,248,249,130],{},[17,240,173],{}," turns a ",[17,243,244],{},"pattern"," into a string with ",[17,247,214],{}," (default) or ",[17,250,165],{},[139,252,253,256,257,260,261,264],{},[17,254,255],{},"typeMode"," sets the factory types: ",[17,258,259],{},"inferred"," (default) derives them from the generated values, and ",[17,262,263],{},"schema"," uses the declared model type.",[10,266,267,268,272],{},"See ",[118,269,271],{"href":270},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-faker\u002Foptions","Options"," for every option and its default.",[22,274,276],{"id":275},"example","Example",[10,278,279],{},"The config below generates the factories with a fixed seed.",[31,281,284],{"language":282,"filename":129,"code":283,"class":36},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { pluginFaker } from '@kubb\u002Fplugin-faker'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  plugins: [\n    pluginTs(),\n    pluginFaker({ seed: [100] }),\n  ],\n})",[17,285,287,303,304,303,316,303,328,303,330,303,344,303,355,303,366,303,371,303,379,303,393,303,398],{"class":286},"language-typescript",[41,288,289,293,297,300],{"class":43,"style":44},[41,290,292],{"style":291},"color:#D73A49;--shiki-dark:#F97583","import",[41,294,296],{"style":295},"color:#24292E;--shiki-dark:#E1E4E8"," { defineConfig } ",[41,298,299],{"style":291},"from",[41,301,302],{"style":50}," 'kubb\u002Fconfig'","\n",[41,305,306,308,311,313],{"class":43,"style":44},[41,307,292],{"style":291},[41,309,310],{"style":295}," { pluginTs } ",[41,312,299],{"style":291},[41,314,315],{"style":50}," '@kubb\u002Fplugin-ts'",[41,317,318,320,323,325],{"class":43,"style":44},[41,319,292],{"style":291},[41,321,322],{"style":295}," { pluginFaker } ",[41,324,299],{"style":291},[41,326,327],{"style":50}," '@kubb\u002Fplugin-faker'",[41,329],{"class":43,"style":44},[41,331,332,335,338,341],{"class":43,"style":44},[41,333,334],{"style":291},"export",[41,336,337],{"style":291}," default",[41,339,340],{"style":47}," defineConfig",[41,342,343],{"style":295},"({",[41,345,346,349,352],{"class":43,"style":44},[41,347,348],{"style":295},"  input: ",[41,350,351],{"style":50},"'.\u002FpetStore.yaml'",[41,353,354],{"style":295},",",[41,356,357,360,363],{"class":43,"style":44},[41,358,359],{"style":295},"  output: { path: ",[41,361,362],{"style":50},"'.\u002Fsrc\u002Fgen'",[41,364,365],{"style":295}," },",[41,367,368],{"class":43,"style":44},[41,369,370],{"style":295},"  plugins: [",[41,372,373,376],{"class":43,"style":44},[41,374,375],{"style":47},"    pluginTs",[41,377,378],{"style":295},"(),",[41,380,381,384,387,390],{"class":43,"style":44},[41,382,383],{"style":47},"    pluginFaker",[41,385,386],{"style":295},"({ seed: [",[41,388,389],{"style":54},"100",[41,391,392],{"style":295},"] }),",[41,394,395],{"class":43,"style":44},[41,396,397],{"style":295},"  ],",[41,399,400],{"class":43,"style":44},[41,401,402],{"style":295},"})",{"title":404,"searchDepth":405,"depth":405,"links":406},"",5,[407,409,410,411],{"id":24,"depth":408,"text":25},2,{"id":133,"depth":408,"text":134},{"id":176,"depth":408,"text":177},{"id":275,"depth":408,"text":276},"md",{},{},true,null,"\u002Fextensions\u002Fkubb-labs\u002Fplugin-faker",{"title":5},{"loc":417},"extensions\u002Fkubb-labs\u002Fplugin-faker\u002Findex","4Stla4br3A-KPk2tGBxa1mkfkLzHcDBiA2444rRoU5g",false,1792276911945]