Skip to content

Commit

Permalink
Include resource name in missing route path error
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Jan 30, 2025
1 parent 2e82db5 commit 5519611
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,11 @@ const createResource = (
schema: OpenapiSchema,
routes: Route[],
): Resource => {
const routePath = validateRoutePath(schema['x-route-path'], routes)
const routePath = validateRoutePath(
schemaName,
schema['x-route-path'],
routes,
)

return {
resourceType: schemaName,
Expand All @@ -847,11 +851,12 @@ const createResource = (
}

const validateRoutePath = (
resourceName: string,
routePath: string | undefined,
routes: Route[],
): string => {
if (routePath == null || routePath.length === 0) {
throw new Error('Missing route path')
throw new Error(`Resource ${resourceName} is missing a route path`)
}
if (!routes.some((r) => r.path === routePath)) {
throw new Error(`Route path ${routePath} not found in routes`)
Expand Down

0 comments on commit 5519611

Please sign in to comment.