@kubb/plugin-faker 5.1.4 → 5.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/options.md CHANGED
@@ -117,7 +117,7 @@ Library used to generate strings that satisfy a regex `pattern` in the spec.
117
117
  ::field-group
118
118
 
119
119
  :::field{name="'faker'"}
120
- Default value. Generates `faker.helpers.fromRegExp(pattern)` without an extra dependency.
120
+ Default value. Generates `faker.helpers.fromRegExp(/pattern/)` without an extra dependency. Faker does not support shorthand classes such as `\d`, `\w`, or `\s`, so use `'randexp'` for patterns that contain them.
121
121
  :::
122
122
 
123
123
  :::field{name="'randexp'"}
package/docs/overview.md CHANGED
@@ -1,24 +1,29 @@
1
1
  # Faker
2
2
 
3
- Generates a Faker.js mock-data factory for every schema in your OpenAPI spec. Use the factories in tests, Storybook, and local development without a running backend. Each factory accepts partial data that overrides the generated values.
3
+ 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.
4
4
 
5
- `@kubb/plugin-msw` can use these factories to fill mock responses.
5
+ Use the factories in tests, Storybook, and local development without a running backend. `@kubb/plugin-msw` can use them to fill mock responses.
6
6
 
7
7
  ## Setup
8
8
 
9
- - Add `@kubb/plugin-ts` for the factory return types.
10
- - Install `@faker-js/faker` v9 or higher in the app that uses the generated code.
9
+ - Add `@kubb/plugin-ts` for the factory return types. Generation fails without it.
10
+ - Install `@faker-js/faker` v10 in the app that uses the generated code.
11
+ - Install `dayjs`, `moment`, or `randexp` when you pick it in `dateParser` or `regexGenerator`.
11
12
 
12
13
  ## Options worth knowing
13
14
 
14
15
  - `seed` passes a fixed seed to `faker.seed(...)`, so every run returns the same data.
15
16
  - `locale` sets the Faker locale. The default is `en`.
16
- - `dateParser` formats date and time strings with `faker` (default), `dayjs`, or `moment`. Install the library you pick.
17
+ - `dateParser` formats `date` and `time` strings with `faker` (default), `dayjs`, or `moment`. `date-time` values always use Faker. `dayjs` and `moment` do not work when the adapter types a date or time as `Date`, for example with `dateType: 'date'`.
17
18
  - `regexGenerator` turns a `pattern` into a string with `faker` (default) or `randexp`.
18
- - `typeMode` sets the factory types: `inferred` (default) derives them from the generated values. `schema` uses the declared model type.
19
+ - `typeMode` sets the factory types: `inferred` (default) derives them from the generated values, and `schema` uses the declared model type.
20
+
21
+ See [Options](https://kubb.dev/extensions/kubb-labs/plugin-faker/options) for every option and its default.
19
22
 
20
23
  ## Example
21
24
 
25
+ The config below generates the factories with a fixed seed.
26
+
22
27
  ```typescript [kubb.config.ts]
23
28
  import { defineConfig } from 'kubb/config'
24
29
  import { pluginTs } from '@kubb/plugin-ts'
@@ -33,9 +38,3 @@ export default defineConfig({
33
38
  ],
34
39
  })
35
40
  ```
36
-
37
- ## See also
38
-
39
- - [Faker.js](https://fakerjs.dev/)
40
- - [@kubb/plugin-ts](https://kubb.dev/extensions/kubb-labs/plugin-ts)
41
- - [@kubb/plugin-msw](https://kubb.dev/extensions/kubb-labs/plugin-msw)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-faker",
3
- "version": "5.1.4",
3
+ "version": "5.1.6",
4
4
  "description": "Generate Faker.js mock data factories with Kubb. Produces realistic seed data and fixtures for development and testing.",
5
5
  "keywords": [
6
6
  "code-generation",
@@ -74,17 +74,17 @@
74
74
  "registry": "https://registry.npmjs.org/"
75
75
  },
76
76
  "dependencies": {
77
- "@kubb/plugin-ts": "^5.0.9"
77
+ "@kubb/plugin-ts": "^5.0.11"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@faker-js/faker": "^10.6.0",
81
81
  "@internals/shared": "0.0.0",
82
82
  "@internals/utils": "0.0.0",
83
- "kubb": "^5.8.3"
83
+ "kubb": "^5.9.2"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@faker-js/faker": "^10.0.0",
87
- "kubb": "^5.8.3"
87
+ "kubb": "^5.9.2"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
90
  "@faker-js/faker": {