apim-apps icon indicating copy to clipboard operation
apim-apps copied to clipboard

Fix: Default radio button for Mock Implementation endpoints when adding Mock endpoint.

Open iff-sal opened this issue 2 months ago • 4 comments

Resolves wso2/api-manager#3680

What was the problem? When a user added a "Mock Implementation" for an API endpoint, the UI would incorrectly select the "Dynamic Endpoints" radio button by default on the subsequent configuration page. This was due to the createEndpointConfig utility function lacking a specific case to handle the 'INLINE' endpoint type. As a result, it fell through to the default case, generating a configuration that the UI interpreted as a "Dynamic Endpoint".

How was this fixed? This pull request implements a complete fix by addressing the issue at all three relevant points in the code, ensuring 'INLINE' endpoints are handled correctly and consistently. Updated the Reducer (Endpoints.jsx): The reducer's 'endpointImplementationType' case was modified to explicitly handle an endpointType of 'INLINE'. It now correctly sets endpointImplementationType: 'INLINE' in the state and triggers the mock script generation, resolving the primary bug. Added 'INLINE' Case (endpointUtils.js): A new case for 'INLINE' was added to the createEndpointConfig function. This ensures a valid, prototyped configuration is generated, preventing the system from falling back to a 'default' config. Removed Workaround (EndpointOverview.jsx): The inconsistent logic that mapped 'INLINE' to 'prototyped' within the component has been removed. The component now calls createEndpointConfig with the correct 'INLINE' type directly, centralizing the configuration logic.

How to test this: Log in to the Publisher portal and create an API without endpoints. navigate to an API's Endpoints section under API Configurations. Under the Mock Implementation card, click the Add button. On the endpoint configuration page, verify that the "Mock Implementation" radio button is now correctly selected by default (and not "Dynamic Endpoints").

iff-sal avatar Oct 04 '25 21:10 iff-sal

@RusJaI I implemented your suggestion. Instead of changing the low-level logic and creating duplicates, I just fixed it at a higher level by passing the correct endpointImplementationType from the apiReducer. This ensures the correct props are passed down, and the UI defaults to the right radio button. Thanks for the review!

https://github.com/user-attachments/assets/924f94c3-d21a-40a8-a5c0-e5494f999753

iff-sal avatar Oct 24 '25 03:10 iff-sal

@RusJaI @tharikaGitHub please review the latest changes to the pr and give me some feedback. Thanks

iff-sal avatar Oct 28 '25 09:10 iff-sal

Hi @RusJaI, Thanks for the review and patience. I got busy with university exam stuff and the exams are started, so didnt had lot of time to give my full focus to this issue. I implemented your suggestion of implementing the logic in the existing if statement and committed it. Again thanks for the feedback.

iff-sal avatar Oct 30 '25 10:10 iff-sal