From b7ae8a2efbdcd9887e3a96cc750b308b373c4312 Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Wed, 8 Jun 2022 07:26:07 -0700 Subject: [PATCH] [DOCS] Fix ML sync API example (#133585) --- docs/api/machine-learning/sync.asciidoc | 4 +-- x-pack/plugins/ml/common/openapi/bundled.json | 34 ++++++++++++++++--- x-pack/plugins/ml/common/openapi/bundled.yaml | 25 +++++++++++--- x-pack/plugins/ml/common/openapi/ml_apis.yaml | 27 ++++++++++++--- 4 files changed, 76 insertions(+), 14 deletions(-) diff --git a/docs/api/machine-learning/sync.asciidoc b/docs/api/machine-learning/sync.asciidoc index d210a7826d166..798c04908bdd5 100644 --- a/docs/api/machine-learning/sync.asciidoc +++ b/docs/api/machine-learning/sync.asciidoc @@ -74,7 +74,7 @@ Retrieve the list of {ml} saved objects that require synchronization: [source,sh] -------------------------------------------------- -$ curl -X GET api/ml/saved_objects/sync?simulate=true +GET api/ml/saved_objects/sync?simulate=true -------------------------------------------------- // KIBANA @@ -83,7 +83,7 @@ the following response: [source,sh] -------------------------------------------------- -{{"savedObjectsCreated":{"anomaly_detector":{"myjob1":{"success":true},"myjob2":{"success":true}}},"savedObjectsDeleted":{},"datafeedsAdded":{},"datafeedsRemoved":{}} +{"savedObjectsCreated":{"anomaly_detector":{"myjob1":{"success":true},"myjob2":{"success":true}}},"savedObjectsDeleted":{},"datafeedsAdded":{},"datafeedsRemoved":{}} -------------------------------------------------- To perform the synchronization, re-run the API and omit the `simulate` parameter. \ No newline at end of file diff --git a/x-pack/plugins/ml/common/openapi/bundled.json b/x-pack/plugins/ml/common/openapi/bundled.json index 455bf02bbd232..7814b4c6f5e5e 100644 --- a/x-pack/plugins/ml/common/openapi/bundled.json +++ b/x-pack/plugins/ml/common/openapi/bundled.json @@ -38,8 +38,11 @@ "content": { "application/json": { "schema": { - "items": { - "$ref": "#/components/schemas/syncResponse" + "$ref": "#/components/schemas/syncResponse" + }, + "examples": { + "syncExample": { + "$ref": "#/components/examples/syncExample" } } } @@ -62,8 +65,11 @@ "content": { "application/json": { "schema": { - "items": { - "$ref": "#/components/schemas/syncResponse" + "$ref": "#/components/schemas/syncResponse" + }, + "examples": { + "syncExample": { + "$ref": "#/components/examples/syncExample" } } } @@ -215,6 +221,26 @@ } } } + }, + "examples": { + "syncExample": { + "summary": "Two anomaly detection jobs required synchronization in this example.", + "value": { + "savedObjectsCreated": { + "anomaly_detector": { + "myjob1": { + "success": true + }, + "myjob2": { + "success": true + } + } + }, + "savedObjectsDeleted": {}, + "datafeedsAdded": {}, + "datafeedsRemoved": {} + } + } } }, "security": [ diff --git a/x-pack/plugins/ml/common/openapi/bundled.yaml b/x-pack/plugins/ml/common/openapi/bundled.yaml index 235979ff1651c..0796f0ecf7502 100644 --- a/x-pack/plugins/ml/common/openapi/bundled.yaml +++ b/x-pack/plugins/ml/common/openapi/bundled.yaml @@ -29,8 +29,10 @@ paths: content: application/json: schema: - items: - $ref: '#/components/schemas/syncResponse' + $ref: '#/components/schemas/syncResponse' + examples: + syncExample: + $ref: '#/components/examples/syncExample' /api/ml/saved_objects/sync: get: description: > @@ -47,8 +49,10 @@ paths: content: application/json: schema: - items: - $ref: '#/components/schemas/syncResponse' + $ref: '#/components/schemas/syncResponse' + examples: + syncExample: + $ref: '#/components/examples/syncExample' components: parameters: spaceParam: @@ -163,5 +167,18 @@ components: success: type: boolean example: true + examples: + syncExample: + summary: Two anomaly detection jobs required synchronization in this example. + value: + savedObjectsCreated: + anomaly_detector: + myjob1: + success: true + myjob2: + success: true + savedObjectsDeleted: {} + datafeedsAdded: {} + datafeedsRemoved: {} security: - basicAuth: [] diff --git a/x-pack/plugins/ml/common/openapi/ml_apis.yaml b/x-pack/plugins/ml/common/openapi/ml_apis.yaml index 827aa1075960d..c222d578243d2 100644 --- a/x-pack/plugins/ml/common/openapi/ml_apis.yaml +++ b/x-pack/plugins/ml/common/openapi/ml_apis.yaml @@ -27,8 +27,10 @@ paths: content: application/json: schema: - items: - $ref: '#/components/schemas/syncResponse' + $ref: '#/components/schemas/syncResponse' + examples: + syncExample: + $ref: '#/components/examples/syncExample' /api/ml/saved_objects/sync: get: description: > @@ -43,8 +45,10 @@ paths: content: application/json: schema: - items: - $ref: '#/components/schemas/syncResponse' + $ref: '#/components/schemas/syncResponse' + examples: + syncExample: + $ref: '#/components/examples/syncExample' components: parameters: spaceParam: @@ -142,5 +146,20 @@ components: success: type: boolean example: true + examples: + syncExample: + summary: Two anomaly detection jobs required synchronization in this example. + value: + { + "savedObjectsCreated": { + "anomaly_detector": { + "myjob1": { "success":true }, + "myjob2":{ "success":true } + } + }, + "savedObjectsDeleted": {}, + "datafeedsAdded":{}, + "datafeedsRemoved":{} + } security: - basicAuth: [] \ No newline at end of file