11package pl .commit .craft .template ;
22
33import io .swagger .v3 .oas .annotations .Operation ;
4+ import io .swagger .v3 .oas .annotations .media .Content ;
5+ import io .swagger .v3 .oas .annotations .media .Schema ;
6+ import io .swagger .v3 .oas .annotations .parameters .RequestBody ;
47import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
8+ import io .swagger .v3 .oas .annotations .responses .ApiResponses ;
9+ import io .swagger .v3 .oas .annotations .tags .Tag ;
510import lombok .RequiredArgsConstructor ;
611import org .springframework .http .HttpStatus ;
712import org .springframework .http .ResponseEntity ;
1419@ RestController
1520@ RequestMapping ("/api/v1/craft-template" )
1621@ RequiredArgsConstructor
22+ @ Tag (name = "Commit Template Controller" , description = "Management template commit model" )
1723public class CommitCraftTemplateController {
1824
1925 private final CommitTemplateService commitTemplateService ;
@@ -22,6 +28,11 @@ public class CommitCraftTemplateController {
2228 summary = "Get all commit templates" ,
2329 description = "Fetches a list of all available commit craft templates."
2430 )
31+ @ ApiResponses ({
32+ @ ApiResponse (responseCode = "200" , description = "Successfully fetched templates" ,
33+ content = @ Content (mediaType = "application/json" ,
34+ schema = @ Schema (implementation = CommitCraftTemplate .class )))
35+ })
2536 @ GetMapping ("/all" )
2637 public ResponseEntity <List <CommitCraftTemplate >> getAllTemplates () throws IOException {
2738 List <CommitCraftTemplate > templates = commitTemplateService .getAllTemplates ();
@@ -30,14 +41,19 @@ public ResponseEntity<List<CommitCraftTemplate>> getAllTemplates() throws IOExce
3041
3142 @ Operation (
3243 summary = "Create a dedicated commit template" ,
33- description = "Creates a new dedicated commit template if the pattern and model scope are valid." ,
34- responses = {
35- @ ApiResponse (responseCode = "201" , description = "Template created successfully" ),
36- @ ApiResponse (responseCode = "400" , description = "Invalid template format or template already exists" )
37- }
44+ description = "Creates a new dedicated commit template if the pattern and model scope are valid."
3845 )
46+ @ ApiResponses ({
47+ @ ApiResponse (responseCode = "201" , description = "Template created successfully" ,
48+ content = @ Content (mediaType = "application/json" )),
49+ @ ApiResponse (responseCode = "400" , description = "Invalid template format or template already exists" ,
50+ content = @ Content (mediaType = "application/json" ))
51+ })
3952 @ PostMapping ("/dedicated" )
40- public ResponseEntity <Map <String , String >> createDedicatedTemplate (@ RequestBody CommitCraftTemplate template ) throws IOException {
53+ public ResponseEntity <Map <String , String >> createDedicatedTemplate (
54+ @ RequestBody (description = "Commit template data" , required = true ,
55+ content = @ Content (schema = @ Schema (implementation = CommitCraftTemplate .class )))
56+ @ org .springframework .web .bind .annotation .RequestBody CommitCraftTemplate template ) throws IOException {
4157 TemplateOperationResult result = commitTemplateService .createDedicatedTemplate (template );
4258
4359 if (result .success ()) {
@@ -53,11 +69,12 @@ public ResponseEntity<Map<String, String>> createDedicatedTemplate(@RequestBody
5369
5470 @ Operation (
5571 summary = "Remove a commit template" ,
56- description = "Removes a dedicated commit template by name." ,
57- responses = {
58- @ ApiResponse (responseCode = "200" , description = "Template removed successfully" )
59- }
72+ description = "Removes a dedicated commit template by name."
6073 )
74+ @ ApiResponses ({
75+ @ ApiResponse (responseCode = "200" , description = "Template removed successfully" ,
76+ content = @ Content (mediaType = "text/plain" ))
77+ })
6178 @ DeleteMapping ("/removed/{name}" )
6279 public ResponseEntity <String > addTemplate (@ PathVariable ("name" ) String name ) throws IOException {
6380 commitTemplateService .removeDedicatedTemplate (name );
@@ -66,11 +83,12 @@ public ResponseEntity<String> addTemplate(@PathVariable("name") String name) thr
6683
6784 @ Operation (
6885 summary = "Generate commit template JSON" ,
69- description = "Generates a JSON representation of the commit template based on its name." ,
70- responses = {
71- @ ApiResponse (responseCode = "200" , description = "JSON generated successfully" )
72- }
86+ description = "Generates a JSON representation of the commit template based on its name."
7387 )
88+ @ ApiResponses ({
89+ @ ApiResponse (responseCode = "200" , description = "JSON generated successfully" ,
90+ content = @ Content (mediaType = "application/json" ))
91+ })
7492 @ PostMapping ("/generate-json/{name}" )
7593 public Map <String , Object > generateJson (@ PathVariable String name ) throws IOException {
7694 CommitCraftJson commitCraftJson = commitTemplateService .prepareJsonByModel (name );
0 commit comments