|
36 | 36 | import org.apache.flink.runtime.rest.messages.MessageQueryParameter; |
37 | 37 | import org.apache.flink.runtime.rest.messages.TriggerId; |
38 | 38 | import org.apache.flink.runtime.rest.messages.job.JobSubmitHeaders; |
| 39 | +import org.apache.flink.runtime.rest.messages.job.metrics.MetricCollectionResponseBody; |
39 | 40 | import org.apache.flink.runtime.rest.messages.json.SerializedThrowableSerializer; |
40 | 41 | import org.apache.flink.runtime.rest.util.DocumentingRestEndpoint; |
41 | 42 | import org.apache.flink.runtime.rest.versioning.RestAPIVersion; |
@@ -152,6 +153,7 @@ static OpenAPI createDocumentation( |
152 | 153 |
|
153 | 154 | overrideIdSchemas(openApi); |
154 | 155 | overrideSerializeThrowableSchema(openApi); |
| 156 | + overrideMetricCollectionSchema(openApi); |
155 | 157 |
|
156 | 158 | sortProperties(openApi); |
157 | 159 | sortSchemas(openApi); |
@@ -284,6 +286,19 @@ private static void overrideIdSchemas(final OpenAPI openApi) { |
284 | 286 | .addSchemas(SlotSharingGroupId.class.getSimpleName(), idSchema); |
285 | 287 | } |
286 | 288 |
|
| 289 | + /** |
| 290 | + * Overrides the schema for {@link MetricCollectionResponseBody} which uses a custom Jackson |
| 291 | + * serializer that writes the metrics collection as a raw JSON array, not as an object with a |
| 292 | + * "metrics" field. |
| 293 | + */ |
| 294 | + private static void overrideMetricCollectionSchema(final OpenAPI openApi) { |
| 295 | + final ArraySchema metricArraySchema = |
| 296 | + new ArraySchema().items(new Schema().$ref("#/components/schemas/Metric")); |
| 297 | + |
| 298 | + openApi.getComponents() |
| 299 | + .addSchemas(MetricCollectionResponseBody.class.getSimpleName(), metricArraySchema); |
| 300 | + } |
| 301 | + |
287 | 302 | private static void overrideSerializeThrowableSchema(final OpenAPI openAPI) { |
288 | 303 | final Schema serializedThrowableSchema = |
289 | 304 | new Schema<>() |
|
0 commit comments