[{"data":1,"prerenderedAt":476},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-faker":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":475,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-faker\u002Findex.md",{},"Faker",{"type":8,"value":9,"toc":466},"minimark",[10,14,22,27,113,134,138,177,181,268,276,280,283],[11,12,13],"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.",[11,15,16,17,21],{},"Use the factories in tests, Storybook, and local development without a running backend. ",[18,19,20],"code",{},"@kubb\u002Fplugin-msw"," can use them to fill mock responses.",[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-faker","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-faker",[32,61,64],{"language":34,"filename":62,"code":63,"class":37},"pnpm","pnpm add -D @kubb\u002Fplugin-faker",[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-faker",[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-faker",[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-faker"," to install the version the ",[121,122,124],"a",{"href":123},"\u002Fregistry","Kubb registry"," pins and add ",[18,127,128],{},"pluginFaker()"," to ",[18,131,132],{},"kubb.config.ts",".",[23,135,137],{"id":136},"setup","Setup",[139,140,141,149,156],"ul",{},[142,143,144,145,148],"li",{},"Add ",[18,146,147],{},"@kubb\u002Fplugin-ts"," for the factory return types. Generation fails without it.",[142,150,151,152,155],{},"Install ",[18,153,154],{},"@faker-js\u002Ffaker"," v10 in the app that uses the generated code.",[142,157,151,158,161,162,165,166,169,170,173,174,133],{},[18,159,160],{},"dayjs",", ",[18,163,164],{},"moment",", or ",[18,167,168],{},"randexp"," when you pick it in ",[18,171,172],{},"dateParser"," or ",[18,175,176],{},"regexGenerator",[23,178,180],{"id":179},"options-worth-knowing","Options worth knowing",[139,182,183,193,202,240,254],{},[142,184,185,188,189,192],{},[18,186,187],{},"seed"," passes a fixed seed to ",[18,190,191],{},"faker.seed(...)",", so every run returns the same data.",[142,194,195,198,199,133],{},[18,196,197],{},"locale"," sets the Faker locale. The default is ",[18,200,201],{},"en",[142,203,204,206,207,210,211,214,215,218,219,165,221,223,224,227,228,210,230,232,233,236,237,133],{},[18,205,172],{}," formats ",[18,208,209],{},"date"," and ",[18,212,213],{},"time"," strings with ",[18,216,217],{},"faker"," (default), ",[18,220,160],{},[18,222,164],{},". ",[18,225,226],{},"date-time"," values always use Faker. ",[18,229,160],{},[18,231,164],{}," do not work when the adapter types a date or time as ",[18,234,235],{},"Date",", for example with ",[18,238,239],{},"dateType: 'date'",[142,241,242,244,245,248,249,251,252,133],{},[18,243,176],{}," turns a ",[18,246,247],{},"pattern"," into a string with ",[18,250,217],{}," (default) or ",[18,253,168],{},[142,255,256,259,260,263,264,267],{},[18,257,258],{},"typeMode"," sets the factory types: ",[18,261,262],{},"inferred"," (default) derives them from the generated values, and ",[18,265,266],{},"schema"," uses the declared model type.",[11,269,270,271,275],{},"See ",[121,272,274],{"href":273},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-faker\u002Foptions","Options"," for every option and its default.",[23,277,279],{"id":278},"example","Example",[11,281,282],{},"The config below generates the factories with a fixed seed.",[32,284,287],{"language":285,"filename":132,"code":286,"class":37},"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})",[18,288,290,313,314,313,330,313,346,313,348,313,362,313,379,313,403,313,415,313,428,313,452,313,461],{"class":289},"language-typescript",[42,291,292,296,300,303,306,309],{"class":44,"style":45},[42,293,295],{"style":294},"color:#d73a49;--hls-dark:#f97583","import ",[42,297,299],{"style":298},"color:#005cc5;--hls-dark:#79b8ff","{ ",[42,301,302],{"style":52},"defineConfig ",[42,304,305],{"style":298},"} ",[42,307,308],{"style":294},"from ",[42,310,312],{"style":311},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[42,315,316,318,320,323,325,327],{"class":44,"style":45},[42,317,295],{"style":294},[42,319,299],{"style":298},[42,321,322],{"style":52},"pluginTs ",[42,324,305],{"style":298},[42,326,308],{"style":294},[42,328,329],{"style":311},"'@kubb\u002Fplugin-ts'",[42,331,332,334,336,339,341,343],{"class":44,"style":45},[42,333,295],{"style":294},[42,335,299],{"style":298},[42,337,338],{"style":52},"pluginFaker ",[42,340,305],{"style":298},[42,342,308],{"style":294},[42,344,345],{"style":311},"'@kubb\u002Fplugin-faker'",[42,347],{"class":44,"style":45},[42,349,350,353,356,359],{"class":44,"style":45},[42,351,352],{"style":294},"export ",[42,354,355],{"style":294},"default ",[42,357,358],{"style":48},"defineConfig",[42,360,361],{"style":298},"({",[42,363,364,367,370,373,376],{"class":44,"style":45},[42,365,366],{"style":298},"  ",[42,368,369],{"style":298},"input",[42,371,372],{"style":294},": ",[42,374,375],{"style":311},"'.\u002FpetStore.yaml'",[42,377,378],{"style":294},",",[42,380,381,383,386,388,390,393,395,398,401],{"class":44,"style":45},[42,382,366],{"style":294},[42,384,385],{"style":298},"output",[42,387,372],{"style":294},[42,389,299],{"style":298},[42,391,392],{"style":298},"path",[42,394,372],{"style":294},[42,396,397],{"style":311},"'.\u002Fsrc\u002Fgen' ",[42,399,400],{"style":298},"}",[42,402,378],{"style":294},[42,404,405,407,410,412],{"class":44,"style":45},[42,406,366],{"style":294},[42,408,409],{"style":298},"plugins",[42,411,372],{"style":294},[42,413,414],{"style":298},"[",[42,416,417,420,423,426],{"class":44,"style":45},[42,418,419],{"style":298},"    ",[42,421,422],{"style":48},"pluginTs",[42,424,425],{"style":298},"()",[42,427,378],{"style":294},[42,429,430,432,435,438,440,442,444,447,450],{"class":44,"style":45},[42,431,419],{"style":294},[42,433,434],{"style":48},"pluginFaker",[42,436,437],{"style":298},"({ ",[42,439,187],{"style":298},[42,441,372],{"style":294},[42,443,414],{"style":298},[42,445,446],{"style":298},"100",[42,448,449],{"style":298},"] })",[42,451,378],{"style":294},[42,453,454,456,459],{"class":44,"style":45},[42,455,366],{"style":294},[42,457,458],{"style":298},"]",[42,460,378],{"style":294},[42,462,463],{"class":44,"style":45},[42,464,465],{"style":298},"})",{"title":467,"searchDepth":468,"depth":468,"links":469},"",5,[470,472,473,474],{"id":25,"depth":471,"text":26},2,{"id":136,"depth":471,"text":137},{"id":179,"depth":471,"text":180},{"id":278,"depth":471,"text":279},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-faker",1793647022283]