Skip to content

Commit

Permalink
[rest] VoiceResource: Return answer from /interpreters endpoint & Add…
Browse files Browse the repository at this point in the history
… annotations for answer

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored and wborn committed Nov 2, 2024
1 parent 728c737 commit 9646607
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ public Response getInterpreter(
@POST
@Path("/interpreters/{ids: [a-zA-Z_0-9,]+}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
@Operation(operationId = "interpretText", summary = "Sends a text to a given human language interpreter(s).", responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "404", description = "No human language interpreter was found."),
@ApiResponse(responseCode = "400", description = "interpretation exception occurs") })
public Response interpret(
Expand Down Expand Up @@ -175,8 +176,9 @@ public Response interpret(
@POST
@Path("/interpreters")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
@Operation(operationId = "interpretTextByDefaultInterpreter", summary = "Sends a text to the default human language interpreter.", responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "404", description = "No human language interpreter was found."),
@ApiResponse(responseCode = "400", description = "interpretation exception occurs") })
public Response interpret(
Expand All @@ -189,8 +191,8 @@ public Response interpret(
}

try {
hli.interpret(locale, text);
return Response.ok(null, MediaType.TEXT_PLAIN).build();
String answer = hli.interpret(locale, text);
return Response.ok(answer, MediaType.TEXT_PLAIN).build();
} catch (InterpretationException e) {
return JSONResponse.createErrorResponse(Status.BAD_REQUEST, e.getMessage());
}
Expand Down

0 comments on commit 9646607

Please sign in to comment.