Skip to content

Commit

Permalink
Refactor how route status is updated into a separate fn
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Sep 17, 2024
1 parent 926ef86 commit 08f08d3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/lib/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,7 @@ const createRoutes = async (
}
}

const routes = Array.from(routeMap.values())

for (const route of routes) {
const isRouteDeprecated = route.endpoints.every(
(endpoint) => endpoint.isDeprecated,
)
const isRouteUndocumented = route.endpoints.every(
(endpoint) => endpoint.isUndocumented,
)

route.isDeprecated = isRouteDeprecated
route.isUndocumented = isRouteUndocumented
}

return routes
return Array.from(routeMap.values()).map(updateRouteStatus)
}

const getNamespace = (path: string, paths: OpenapiPaths): string | null => {
Expand Down Expand Up @@ -391,6 +377,21 @@ const createRoute = async (
}
}

const updateRouteStatus = (route: Route): Route => {
const isRouteDeprecated = route.endpoints.every(
(endpoint) => endpoint.isDeprecated,
)
const isRouteUndocumented = route.endpoints.every(
(endpoint) => endpoint.isUndocumented,
)

return {
...route,
isDeprecated: isRouteDeprecated,
isUndocumented: isRouteUndocumented,
}
}

const createEndpoints = async (
path: string,
pathItem: OpenapiPathItem,
Expand Down

0 comments on commit 08f08d3

Please sign in to comment.