Build: Support `console-result` language (#45937) (#45976)

This adds support for verifying that snippets with the `console-result`
language are valid json. It also switches the response snippets on the
`docs/get` page from `js` to `console-result` which will allow clients
to provide "alternatives" for them like they can now do with
`// CONSOLE` snippets.
This commit is contained in:
Nik Everett 2019-08-26 16:38:02 -04:00 committed by GitHub
parent 3d64605075
commit b3f76d6f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -123,7 +123,7 @@ public class SnippetsTask extends DefaultTask {
} }
} }
if (snippet.testResponse if (snippet.testResponse
&& 'js' == snippet.language && ('js' == snippet.language || 'console-result' == snippet.language)
&& null == snippet.skip) { && null == snippet.skip) {
String quoted = snippet.contents String quoted = snippet.contents
// quote values starting with $ // quote values starting with $
@ -162,7 +162,7 @@ public class SnippetsTask extends DefaultTask {
} }
return return
} }
matcher = line =~ /\["?source"?,\s*"?(\w+)"?(,.*)?].*/ matcher = line =~ /\["?source"?,\s*"?([-\w]+)"?(,.*)?].*/
if (matcher.matches()) { if (matcher.matches()) {
lastLanguage = matcher.group(1) lastLanguage = matcher.group(1)
lastLanguageLine = lineNumber lastLanguageLine = lineNumber

View File

@ -240,7 +240,7 @@ GET twitter/_doc/0
The API returns the following result: The API returns the following result:
[source,js] [source,console-result]
-------------------------------------------------- --------------------------------------------------
{ {
"_index" : "twitter", "_index" : "twitter",
@ -359,7 +359,7 @@ GET twitter/_doc/1?stored_fields=tags,counter
The API returns the following result: The API returns the following result:
[source,js] [source,console-result]
-------------------------------------------------- --------------------------------------------------
{ {
"_index": "twitter", "_index": "twitter",
@ -403,7 +403,7 @@ GET twitter/_doc/2?routing=user1&stored_fields=tags,counter
The API returns the following result: The API returns the following result:
[source,js] [source,console-result]
-------------------------------------------------- --------------------------------------------------
{ {
"_index": "twitter", "_index": "twitter",