[rest] Improve metadata query parameter description (#2790)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp
2022-02-20 17:48:01 +01:00
committed by GitHub
parent 79ec0396b3
commit 355c1345ea
2 changed files with 6 additions and 7 deletions
@@ -203,7 +203,7 @@ public class ItemResource implements RESTResource {
@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language,
@QueryParam("type") @Parameter(description = "item type filter") @Nullable String type,
@QueryParam("tags") @Parameter(description = "item tag filter") @Nullable String tags,
@QueryParam("metadata") @Parameter(description = "metadata selector") @Nullable String namespaceSelector,
@QueryParam("metadata") @Parameter(description = "metadata selector - a comma separated list or a regular expression (suppressed if no value given)") @Nullable String namespaceSelector,
@DefaultValue("false") @QueryParam("recursive") @Parameter(description = "get member items recursively") boolean recursive,
@QueryParam("fields") @Parameter(description = "limit output to the given fields (comma separated)") @Nullable String fields) {
final Locale locale = localeService.getLocale(language);
@@ -228,7 +228,7 @@ public class ItemResource implements RESTResource {
@ApiResponse(responseCode = "404", description = "Item not found") })
public Response getItemData(final @Context UriInfo uriInfo, final @Context HttpHeaders httpHeaders,
@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language,
@QueryParam("metadata") @Parameter(description = "metadata selector") @Nullable String namespaceSelector,
@QueryParam("metadata") @Parameter(description = "metadata selector - a comma separated list or a regular expression (suppressed if no value given)") @Nullable String namespaceSelector,
@DefaultValue("true") @QueryParam("recursive") @Parameter(description = "get member items if the item is a group item") boolean recursive,
@PathParam("itemname") @Parameter(description = "item name") String itemname) {
final Locale locale = localeService.getLocale(language);
@@ -13,7 +13,6 @@
package org.openhab.core.io.rest.core.internal.item;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
@@ -45,16 +44,16 @@ public class MetadataSelectorMatcher {
}
/**
* Filter existing metadata namespaces against the given namespaeSelector. The given String might consist of a comma
* separated list of namespaces as well as a regular expression.
* Filter existing metadata namespaces against the given namespaceSelector. The given String might consist of a
* comma separated list of namespaces as well as a regular expression.
*
* @param namespaceSelector a comma separated list of namespaces or regular expression.
* @param namespaceSelector a comma separated list of namespaces or a regular expression.
* @param locale the locale for config descriptions with the scheme "metadata".
* @return a {@link Set} of matching namespaces.
*/
public Set<String> filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale) {
if (namespaceSelector == null || namespaceSelector.isEmpty()) {
return Collections.emptySet();
return Set.of();
} else {
Set<String> originalNamespaces = Arrays.stream(namespaceSelector.split(",")) //
.filter(n -> !metadataRegistry.isInternalNamespace(n)) //