Skip to content

Commit 4eb9f69

Browse files
committed
add warning
1 parent ec4265e commit 4eb9f69

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

packages/openapi-ts/src/plugins/@faker-js/faker/shared/export.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { log } from '@hey-api/codegen-core';
12
import { buildSymbolIn, pathToName } from '@hey-api/shared';
23

34
import { $ } from '../../../../ts-dsl';
@@ -20,22 +21,28 @@ export function exportAst({
2021
isCircularSchema?: boolean;
2122
}): void {
2223
const name = pathToName(path, { anchor: namingAnchor });
24+
const symbolIn = buildSymbolIn({
25+
meta: {
26+
category: 'schema',
27+
path,
28+
tags,
29+
tool: 'faker',
30+
...meta,
31+
},
32+
name,
33+
naming,
34+
plugin,
35+
schema,
36+
});
2337

24-
const symbol = plugin.registerSymbol(
25-
buildSymbolIn({
26-
meta: {
27-
category: 'schema',
28-
path,
29-
tags,
30-
tool: 'faker',
31-
...meta,
32-
},
33-
name,
34-
naming,
35-
plugin,
36-
schema,
37-
}),
38-
);
38+
if (final.resultType === 'never') {
39+
log.warn(
40+
`[${plugin.name}] ${symbolIn.name} not generated because we can't produce data that fits its schema.`,
41+
);
42+
return;
43+
}
44+
45+
const symbol = plugin.registerSymbol(symbolIn);
3946

4047
// Look up the TypeScript type for this schema (e.g. Foo, Bar, or PostFooResponse)
4148
const typeSymbol = plugin.querySymbol({

packages/openapi-ts/src/plugins/@faker-js/faker/v10/processor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ export function createProcessor(
7474
tracking.isObjectByRef.set(ctx.meta.resourceId, !!final.isObjectLike);
7575

7676
if (shouldExport) {
77-
// Skip exporting impossible schemas (e.g. allOf: [number, string])
78-
if (final.resultType === 'never') {
79-
return;
80-
}
8177
exportAst({ ...ctx, final, isCircularSchema, plugin });
8278
return;
8379
}

0 commit comments

Comments
 (0)