Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor: improve the error message for missing external codecs in op…
…enapi-generator

following principles of 1. What went wrong and 2. how to solve it
  • Loading branch information
yanxue-22 committed Oct 23, 2025
commit 96b5e1a6d41fd57584ccc80650df5ca6cdb00c36
6 changes: 5 additions & 1 deletion packages/openapi-generator/src/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,11 @@ export function parseCodecInitializer(
// schema.location might be a package name -> need to resolve the path from the project types
const path = project.getTypes()[schema.name];
if (path === undefined)
return errorLeft(`Cannot find module '${schema.location}' in the project`);
return errorLeft(
`Cannot find external codec '${schema.name}' from module '${schema.location}'. ` +
`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`,
);
refSource = project.get(path);
if (refSource === undefined) {
return errorLeft(`Cannot find '${schema.name}' from '${schema.location}'`);
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-generator/test/apiSpec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,5 @@ const MISSING_REFERENCE = {
};

testCase('missing reference', MISSING_REFERENCE, '/index.ts', {}, [
"Cannot find module 'foo' in the project",
"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",
]);
Loading