-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommitFlowController.java
More file actions
53 lines (48 loc) · 2.49 KB
/
CommitFlowController.java
File metadata and controls
53 lines (48 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package pl.commit.craft.flow;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pl.commit.craft.service.CommitTranslateService;
@RestController
@RequestMapping("/api/v1/commit-flow")
@Tag(name = "Commit Flow Controller", description = "Flow commit")
public class CommitFlowController {
private final CommitTranslateService commitTranslateService;
public CommitFlowController(CommitTranslateService commitTranslateService) {
this.commitTranslateService = commitTranslateService;
}
@Operation(
summary = "Generate a commit message based on the provided commit flow data",
description = "This endpoint receives commit flow details and generates the corresponding commit message."
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Successfully generated commit message",
content = @Content(mediaType = "text/plain", schema = @Schema(type = "string"))),
@ApiResponse(responseCode = "400", description = "Bad request, invalid input data",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "500", description = "Internal server error",
content = @Content(mediaType = "application/json"))
})
@PostMapping("/craft")
public String generateCommit(
@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Commit flow request data",
required = true,
content = @Content(schema = @Schema(implementation = CommitFlowRequest.class)))
@RequestBody CommitFlowRequest commitFlowRequest) {
return commitTranslateService.generateFlowCommit(
commitFlowRequest.major(),
commitFlowRequest.type(),
commitFlowRequest.component(),
commitFlowRequest.changeDescription(),
commitFlowRequest.details(),
commitFlowRequest.wholeGitCommand()
);
}
}