Skip to content

Commit

Permalink
fix(plugin): throw an explicit error message if service id is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
glc-omid committed Sep 27, 2024
1 parent 2fb077c commit af1df73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default async (_: any, options: Props) => {

const services = options.services ?? [];
for (const serviceSpec of services) {
if (!serviceSpec.id) throw new Error('The service id is required. please provide a service id');

console.log(chalk.green(`Processing ${serviceSpec.path}`));

try {
Expand Down
12 changes: 12 additions & 0 deletions src/test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,18 @@ describe('OpenAPI EventCatalog Plugin', () => {

expect(service).toBeDefined();
});

it('[id] if the `id` not provided in the service config options, The generator throw an explicit error', async () => {
await expect(
plugin(config, {
services: [
{
path: join(openAPIExamples, 'petstore.yml'),
} as any,
],
})
).rejects.toThrow('The service id is required');
});
});
});
});
Expand Down

0 comments on commit af1df73

Please sign in to comment.