From b52261dd0730c7efeea05044187389c480df9318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pol=20Amor=C3=B3s?= Date: Tue, 21 May 2024 12:46:08 +0200 Subject: [PATCH] fix(console): api gateway ui loose the endpoint while editing body (#6527) Fixes https://github.com/winglang/wing/issues/6525 --- .../console/ui/src/ui/api-interaction.tsx | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/apps/wing-console/console/ui/src/ui/api-interaction.tsx b/apps/wing-console/console/ui/src/ui/api-interaction.tsx index cc3b78d5404..d8fb4f87ba8 100644 --- a/apps/wing-console/console/ui/src/ui/api-interaction.tsx +++ b/apps/wing-console/console/ui/src/ui/api-interaction.tsx @@ -316,28 +316,10 @@ export const ApiInteraction = memo( ], ); - const loadRoutesFromOpenApi = useCallback(() => { - const routes = getRoutesFromOpenApi(openApiSpec); - setRoutes(routes); - const currentRouteExists = routes.some( - (value) => value.route === currentRoute, - ); - setCurrentRoute(currentRouteExists ? currentRoute : ""); - - if (!currentMethod) { - const methods = routes - .filter((item) => { - return item.route === currentRoute; - }) - .map((route) => route.method); - handleMethodChange(currentRoute, methods[0] ?? "GET"); - } - }, [openApiSpec, currentMethod, currentRoute, handleMethodChange]); - // load the routes from the open api spec on mount useEffect(() => { - loadRoutesFromOpenApi(); - }, [openApiSpec, loadRoutesFromOpenApi]); + setRoutes(getRoutesFromOpenApi(openApiSpec)); + }, [openApiSpec]); // Load the possible values for the current header key useEffect(() => {