Refactor Get Endpoints to use ExecuteAsync to explicitly show return …#6746
Open
notfahmed wants to merge 1 commit intoelsa-workflows:mainfrom
Open
Refactor Get Endpoints to use ExecuteAsync to explicitly show return …#6746notfahmed wants to merge 1 commit intoelsa-workflows:mainfrom
notfahmed wants to merge 1 commit intoelsa-workflows:mainfrom
Conversation
Author
|
@dotnet-policy-service agree |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors several GET endpoints to explicitly specify their return types by switching from HandleAsync to ExecuteAsync and updating ElsaEndpoint<TRequest> to ElsaEndpoint<TRequest, TResponse>.
- Endpoints now return strongly typed response objects via
ExecuteAsyncinstead of manually callingSendOkAsync/SendCreatedAtAsync. - Signature changes across workflow‐definition and graph endpoints align with new method patterns.
- A couple of model classes were added or moved to support the new response/request types.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Refresh/Endpoint.cs | Changed to ElsaEndpoint<Request, Response> and ExecuteAsync |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/IsNameUnique/Endpoint.cs | Changed to ElsaEndpoint<Request, Response> and ExecuteAsync |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/ImportFiles/Models.cs | Added Response model for imported file count |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/ImportFiles/Endpoint.cs | Switched to ExecuteAsync and return Response |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Import/Endpoint.cs | Changed to ElsaEndpoint<WorkflowDefinitionModel, LinkedWorkflowDefinitionModel> and ExecuteAsync |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Graph/Segments/Endpoint.cs | Updated signature to ElsaEndpoint<Request, Response> |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Graph/Endpoint.cs | Updated signature to ElsaEndpoint<Request, ActivityNode> |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/GetManyById/Endpoint.cs | Changed to ExecuteAsync returning ListResponse<...> |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/GetById/Endpoint.cs | Changed to ExecuteAsync returning LinkedWorkflowDefinitionModel |
| src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/GetByDefinitionId/Endpoint.cs | Changed to ExecuteAsync returning LinkedWorkflowDefinitionModel |
| src/modules/Elsa.Expressions.JavaScript/Endpoints/TypeDefinitions/Models.cs | Extracted Request record into its own file |
| src/modules/Elsa.Expressions.JavaScript/Endpoints/TypeDefinitions/Endpoint.cs | Removed duplicate Request record from endpoint file |
Comments suppressed due to low confidence (3)
src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Graph/Segments/Endpoint.cs:15
- You updated the endpoint signature to use
ElsaEndpoint<Request, Response>but didn't rename the override fromHandleAsynctoExecuteAsync. Update the method signature and return type accordingly.
internal class Nodes(IWorkflowDefinitionService workflowDefinitionService, IApiSerializer apiSerializer, ActivityWriter activityWriter) : ElsaEndpoint<Request, Response>
src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Graph/Endpoint.cs:13
- The class signature was updated for a generic response type but the handler method still overrides
HandleAsync. It should be renamed toExecuteAsync(Request, CancellationToken)returningActivityNode.
internal class Graph(IWorkflowDefinitionService workflowDefinitionService, IApiSerializer apiSerializer, ActivityWriter activityWriter) : ElsaEndpoint<Request, ActivityNode>
src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Import/Endpoint.cs:63
- The
return updatedModel;is inside theif (isNew)block, making theValidationFailedbranch unreachable and omitting a return path for non-new, non-validation cases. Refactor so that validation is handled first andupdatedModelis returned on all successful paths.
return updatedModel;
4e58970 to
ae1bb77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several get endpoints didn't explicitly set their return type on the method and ElsaEndpoint<TReq,TResp>. Changes were made to use the ExecuteAsync rather than the HandleAsync method, explicitly setting the return type on the method, to use ElsaEndpoint<TRequest, TResponse>, and a couple smaller refactors to align with the coding standards.
This change is