trace-server-protocol icon indicating copy to clipboard operation
trace-server-protocol copied to clipboard

OutputElementStyle.values contains values other than "object"

Open awendelin-work opened this issue 1 year ago • 2 comments

The trace-server (built from incubator 4b14d71637df2cedecd48d4287851315418a2d31) is inconsistent with the openapi specification with regards to the format of OutputElementStyle.

OutputElementStyle is defined in the openapi specification as follows:

OutputElementStyle:
  type: object
  properties:
    parentKey:
      type: string
    values:
      type: object
      additionalProperties:
        type: object

This matches an example JSON like:

"style": {
  "parentKey": "mykey",
  "values": {
    "value0": {"type": 12},
    "value1": {"color": "blue"}
  }
}

What the server actually responds with (xy model for HistogramDataProvider) is JSON like:

"style": {
  "parentKey": null,
  "values": {
    "series-type": "line"
  }
}

or (from latency analysis I believe):

"style": {
  "parentKey": null,
  "values": {
    "series-type": "scatter"
  }
}

Notice how the keys of "values" point to strings and not to objects.

I think the underlying issue is because the openapi specification (and implementation of OutputElementStyle) is defined in Java as:

public interface OutputElementStyle {
    ...
    Map<String, Object> getValues();
    ...

The Java notion of an Object can mean a lot of things, but a JSON notion of an Object is more specific and does not include strings.

It appears the values of an OutputElementStyle should rather be defined as any type. See free-form objects in: https://swagger.io/docs/specification/data-models/dictionaries/

diff --git a/API.yaml b/API.yaml
index af1ee4c..1060590 100644
--- a/API.yaml
+++ b/API.yaml
@@ -1605,7 +1605,6 @@ components:
         values:
           type: object
           additionalProperties:
-            type: object
             description: Style values or empty map if there are no values. Keys and
               values are defined in https://git.eclipse.org/r/plugins/gitiles/tracecompass/org.eclipse.tracecompass/+/refs/heads/master/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/model/StyleProperties.java
           description: Style values or empty map if there are no values. Keys and

awendelin-work avatar Jul 19 '24 16:07 awendelin-work