diff --git a/packages/openapi-generator/src/codec.ts b/packages/openapi-generator/src/codec.ts index e3eb58a4..e909c8f6 100644 --- a/packages/openapi-generator/src/codec.ts +++ b/packages/openapi-generator/src/codec.ts @@ -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}'`); diff --git a/packages/openapi-generator/test/apiSpec.test.ts b/packages/openapi-generator/test/apiSpec.test.ts index 52a7030b..4c4bb424 100644 --- a/packages/openapi-generator/test/apiSpec.test.ts +++ b/packages/openapi-generator/test/apiSpec.test.ts @@ -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", ]);