openhab-core
openhab-core copied to clipboard
[REST API] metadata value is not optional
Posting metadata config without a value entry always results in a 404 response.
The data model however defines value as optional.

Example Body:
{
"config": {
"test": 1
}
}
You are talking about this API ?

Where do you see the value as optional ?
I see that 400 should be returned if no valuye is provided:

Is it what's not working ?
And it looks this is correctly checked:
https://github.com/openhab/openhab-core/blob/master/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java#L521
In the screenshot I posted it shows value and config as optional
Where did you get that screenshot from? If value is reported as optional, that is the bug. What is the use-case of metadata without value?
I think it was from OH2.X. Currently it looks like that

Isn't the config part optional?
Currently the Schema does not show optional/required values. The problem is (similar to other DTOs) that the MetadataDTO is part of the org.openhab.core bundle which is agnostic of the REST API.
Even if we added annotations, the code currently is not able to process these annotations, we would need to find a way to identify packages that contain DTOs (which are currently spread over a lot of bundles) and feed those to the Swagger Model.