mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
[rest] VoiceResource: Return answer from /interpreters endpoint & Add annotations for answer
Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
parent
728c7376b6
commit
9646607e47
@ -139,8 +139,9 @@ public class VoiceResource implements RESTResource {
|
||||
@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(
|
||||
@ -175,8 +176,9 @@ public class VoiceResource implements RESTResource {
|
||||
@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(
|
||||
@ -189,8 +191,8 @@ public class VoiceResource implements RESTResource {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user