From 9c76ee47c4b4d61765474155609fe290063c044d Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 12 May 2020 14:49:02 -0500 Subject: [PATCH] [7.x] json spec: allow null for documentation url (#55749) (#56625) This commit allows the JSON schema's documentation.url property to have a null value. This can useful for cases where a feature is under development, and does not have documentation published yet. This commit also adds a documentation.url for two ml resources. --- rest-api-spec/src/main/resources/schema.json | 32 ++++++++++++++++++- x-pack/plugin/build.gradle | 5 +-- .../rest-api-spec/api/ml.validate.json | 2 +- .../api/ml.validate_detector.json | 2 +- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/rest-api-spec/src/main/resources/schema.json b/rest-api-spec/src/main/resources/schema.json index 16418116b51..6ae10164ee7 100644 --- a/rest-api-spec/src/main/resources/schema.json +++ b/rest-api-spec/src/main/resources/schema.json @@ -43,6 +43,37 @@ "$ref": "#/definitions/Body" } }, + "if": { + "properties": { + "stability": { + "const": "stable" + } + } + }, + "then": { + "properties": { + "documentation": { + "$ref": "#/definitions/Documentation", + "properties": { + "url" : { + "type": ["string"] + } + } + } + } + }, + "else": { + "properties": { + "documentation": { + "$ref": "#/definitions/Documentation", + "properties": { + "url" : { + "type": ["string", "null"] + } + } + } + } + }, "required": [ "documentation", "stability", @@ -130,7 +161,6 @@ "additionalProperties": false, "properties": { "url": { - "type": "string", "format": "uri" }, "description": { diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index a5a5bf73c59..d9938d485ed 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -159,7 +159,4 @@ testClusters.integTest { } } -validateRestSpec { - ignore 'ml.validate.json' - ignore 'ml.validate_detector.json' -} + diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate.json index ffbede6b1e3..46f6e8337ef 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate.json @@ -1,7 +1,7 @@ { "ml.validate":{ "documentation":{ - "url":null, + "url":"https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html", "description":"Validates an anomaly detection job." }, "stability":"stable", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate_detector.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate_detector.json index f4cee6d5c27..336b81aaaaf 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate_detector.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.validate_detector.json @@ -1,7 +1,7 @@ { "ml.validate_detector":{ "documentation":{ - "url":null, + "url":"https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html", "description":"Validates an anomaly detection detector." }, "stability":"stable",