@kubb/plugin-faker 5.0.0-beta.86 → 5.0.0-beta.87
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/dist/index.cjs +21 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -277,7 +277,7 @@ declare const pluginFakerName = "plugin-faker";
|
|
|
277
277
|
* import { pluginFaker } from '@kubb/plugin-faker'
|
|
278
278
|
*
|
|
279
279
|
* export default defineConfig({
|
|
280
|
-
* input:
|
|
280
|
+
* input: './petStore.yaml',
|
|
281
281
|
* output: { path: './src/gen' },
|
|
282
282
|
* plugins: [
|
|
283
283
|
* pluginTs(),
|
package/dist/index.js
CHANGED
|
@@ -724,6 +724,24 @@ function getOperationParameters(node, options = {}) {
|
|
|
724
724
|
};
|
|
725
725
|
}
|
|
726
726
|
//#endregion
|
|
727
|
+
//#region ../../internals/shared/src/adapter.ts
|
|
728
|
+
/**
|
|
729
|
+
* Narrows the generic `Adapter` from a generator context to the OpenAPI adapter,
|
|
730
|
+
* so OAS-only options (`dateType`, `nameMapping`) and the parsed `document` are typed.
|
|
731
|
+
*
|
|
732
|
+
* Throws when a non-OAS adapter is configured, turning a silently wrong cast into a
|
|
733
|
+
* clear, actionable error at the point of use.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```ts
|
|
737
|
+
* const { dateType } = getOasAdapter(ctx.adapter).options
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
function getOasAdapter(adapter) {
|
|
741
|
+
if (adapter.name !== "oas") throw new Error(`Expected the OpenAPI adapter (adapterOas), but received "${adapter.name}". Configure \`adapter: adapterOas()\` in your Kubb config.`);
|
|
742
|
+
return adapter;
|
|
743
|
+
}
|
|
744
|
+
//#endregion
|
|
727
745
|
//#region ../../internals/shared/src/group.ts
|
|
728
746
|
/**
|
|
729
747
|
* Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
|
|
@@ -1009,7 +1027,7 @@ const fakerGenerator = defineGenerator({
|
|
|
1009
1027
|
regexGenerator,
|
|
1010
1028
|
nodes: printer?.nodes,
|
|
1011
1029
|
cyclicSchemas,
|
|
1012
|
-
nameMapping: adapter.options.nameMapping
|
|
1030
|
+
nameMapping: getOasAdapter(adapter).options.nameMapping
|
|
1013
1031
|
});
|
|
1014
1032
|
const fakerText = printerInstance.print(node) ?? "undefined";
|
|
1015
1033
|
const typeReference = resolveTypeReference({
|
|
@@ -1216,7 +1234,7 @@ const fakerGenerator = defineGenerator({
|
|
|
1216
1234
|
regexGenerator,
|
|
1217
1235
|
nodes: printer?.nodes,
|
|
1218
1236
|
cyclicSchemas,
|
|
1219
|
-
nameMapping: adapter.options.nameMapping
|
|
1237
|
+
nameMapping: getOasAdapter(adapter).options.nameMapping
|
|
1220
1238
|
});
|
|
1221
1239
|
const fakerText = printerInstance.print(schema) ?? "undefined";
|
|
1222
1240
|
const { imports, aliases } = aliasConflictingImports(filterUsedImports(resolveMockImports(schema), fakerText, skipImportNames), localHelperNames);
|
|
@@ -1390,7 +1408,7 @@ const pluginFakerName = "plugin-faker";
|
|
|
1390
1408
|
* import { pluginFaker } from '@kubb/plugin-faker'
|
|
1391
1409
|
*
|
|
1392
1410
|
* export default defineConfig({
|
|
1393
|
-
* input:
|
|
1411
|
+
* input: './petStore.yaml',
|
|
1394
1412
|
* output: { path: './src/gen' },
|
|
1395
1413
|
* plugins: [
|
|
1396
1414
|
* pluginTs(),
|