From 5f8658d0aeaa2ff68379245294a4fa40d3141198 Mon Sep 17 00:00:00 2001 From: lolodomo Date: Wed, 16 Aug 2023 17:48:09 +0200 Subject: [PATCH] [REST] Check a label is provided when creating a new semantic tag (#3734) Signed-off-by: Laurent Garnier --- .../core/io/rest/core/internal/tag/TagResource.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java index cc4d558b4..4e97419e0 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java @@ -189,16 +189,19 @@ public class TagResource implements RESTResource { @Operation(operationId = "createSemanticTag", summary = "Creates a new semantic tag and adds it to the registry.", security = { @SecurityRequirement(name = "oauth2", scopes = { "admin" }) }, responses = { @ApiResponse(responseCode = "201", description = "Created", content = @Content(schema = @Schema(implementation = EnrichedSemanticTagDTO.class))), - @ApiResponse(responseCode = "400", description = "The tag identifier is invalid."), + @ApiResponse(responseCode = "400", description = "The tag identifier is invalid or the tag label is missing."), @ApiResponse(responseCode = "409", description = "A tag with the same identifier already exists.") }) public Response create( @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language, @Parameter(description = "tag data", required = true) EnrichedSemanticTagDTO data) { final Locale locale = localeService.getLocale(language); - if (data.uid == null) { + if (data.uid == null || data.uid.isBlank()) { return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Tag identifier is required!"); } + if (data.label == null || data.label.isBlank()) { + return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Tag label is required!"); + } String uid = data.uid.trim();