forked from neurodock/NeuroDock
refactor: me.zacharias.chat → me.neurodock, org rename cleanup
- Renamed package from me.zacharias.chat to me.neurodock across all 8 modules - Updated Gradle group from me.zacharias.neurodock to me.neurodock - Updated README and other files to reflect new Gitea org URL (Chat_things → neurodock) Dev note: 95 files touched. The Great Refactor is complete, long may it rest.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package me.neurodock.api.controllers;
|
||||
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import me.neurodock.api.APIApplication;
|
||||
import me.neurodock.api.payload.request.NewToolRequest;
|
||||
import me.neurodock.api.payload.response.NewToolResponse;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/tool")
|
||||
public class Tool {
|
||||
APIApplication application;
|
||||
|
||||
public Tool(APIApplication application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new tool to the application.
|
||||
*
|
||||
* @param request The request containing the tool details.
|
||||
* @return A response entity containing the tool details or an error message.
|
||||
*/
|
||||
@PostMapping("addTool")
|
||||
@ApiResponse(responseCode = "200", description = "Tool added successfully", content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = NewToolResponse.class)))
|
||||
@ApiResponse(responseCode = "400", description = "Tool already exists", content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = String.class)))
|
||||
public ResponseEntity<?> addTool(@RequestBody NewToolRequest request) {
|
||||
if(application.addTool(request.getName(), request)) {
|
||||
String[] arguments = new String[request.getArguments().length];
|
||||
for(int i = 0; i < arguments.length; i++) {
|
||||
arguments[i] = request.getArguments()[i].getName()+":("+request.getArguments()[i].getType()+")";
|
||||
}
|
||||
return ResponseEntity.ok(new NewToolResponse(request.getName(), request.getDescription(), arguments));
|
||||
} else {
|
||||
return ResponseEntity.badRequest().body("Tool already exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user