Skip to content

Commit 97d7cee

Browse files
authored
refactor: improve the error message for missing external codecs in openapi-generator
2 parents 8b539fe + 96b5e1a commit 97d7cee

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/openapi-generator/src/codec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,11 @@ export function parseCodecInitializer(
528528
// schema.location might be a package name -> need to resolve the path from the project types
529529
const path = project.getTypes()[schema.name];
530530
if (path === undefined)
531-
return errorLeft(`Cannot find module '${schema.location}' in the project`);
531+
return errorLeft(
532+
`Cannot find external codec '${schema.name}' from module '${schema.location}'. ` +
533+
`To fix this, add the codec definition to your codec config file. ` +
534+
`See: https://github.com/BitGo/api-ts/tree/master/packages/openapi-generator#4-defining-custom-codecs`,
535+
);
532536
refSource = project.get(path);
533537
if (refSource === undefined) {
534538
return errorLeft(`Cannot find '${schema.name}' from '${schema.location}'`);

packages/openapi-generator/test/apiSpec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,5 @@ const MISSING_REFERENCE = {
290290
};
291291

292292
testCase('missing reference', MISSING_REFERENCE, '/index.ts', {}, [
293-
"Cannot find module 'foo' in the project",
293+
"Cannot find external codec 'Foo' from module 'foo'. To fix this, add the codec definition to your codec config file. See: https://github.com/BitGo/api-ts/tree/master/packages/openapi-generator#4-defining-custom-codecs",
294294
]);

0 commit comments

Comments
 (0)