OpenSearch/docs/reference
Nik Everett 6d2c40e546 Enforce that responses in docs are valid json (#26249)
All of the snippets in our docs marked with `// TESTRESPONSE` are
checked against the response from Elasticsearch but, due to the
way they are implemented they are actually parsed as YAML instead
of JSON. Luckilly, all valid JSON is valid YAML! Unfurtunately
that means that invalid JSON has snuck into the exmples!

This adds a step during the build to parse them as JSON and fail
the build if they don't parse.

But no! It isn't quite that simple. The displayed text of some of
these responses looks like:
```
{
    ...
    "aggregations": {
        "range": {
            "buckets": [
                {
                    "to": 1.4436576E12,
                    "to_as_string": "10-2015",
                    "doc_count": 7,
                    "key": "*-10-2015"
                },
                {
                    "from": 1.4436576E12,
                    "from_as_string": "10-2015",
                    "doc_count": 0,
                    "key": "10-2015-*"
                }
            ]
        }
    }
}
```

Note the `...` which isn't valid json but we like it anyway and want
it in the output. We use substitution rules to convert the `...`
into the response we expect. That yields a response that looks like:
```
{
    "took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,
    "aggregations": {
        "range": {
            "buckets": [
                {
                    "to": 1.4436576E12,
                    "to_as_string": "10-2015",
                    "doc_count": 7,
                    "key": "*-10-2015"
                },
                {
                    "from": 1.4436576E12,
                    "from_as_string": "10-2015",
                    "doc_count": 0,
                    "key": "10-2015-*"
                }
            ]
        }
    }
}
```

That is what the tests consume but it isn't valid JSON! Oh no! We don't
want to go update all the substitution rules because that'd be huge and,
ultimately, wouldn't buy much. So we quote the `$body.took` bits before
parsing the JSON.

Note the responses that we use for the `_cat` APIs are all converted into
regexes and there is no expectation that they are valid JSON.

Closes #26233
2017-08-17 09:02:10 -04:00
..
aggregations Enforce that responses in docs are valid json (#26249) 2017-08-17 09:02:10 -04:00
analysis Update experimental labels in the docs (#25727) 2017-07-18 14:06:22 +02:00
cat Enforce that responses in docs are valid json (#26249) 2017-08-17 09:02:10 -04:00
cluster Remove mention of http_address in nodes info docs 2017-07-31 22:04:16 +09:00
docs Enforce that responses in docs are valid json (#26249) 2017-08-17 09:02:10 -04:00
how-to Broke recipes into separate pages 2017-07-17 18:21:39 +02:00
images Update MSI installer images (#25414) 2017-06-28 09:04:23 +10:00
index-modules Add a scripted similarity. (#25831) 2017-08-08 08:55:12 +02:00
indices Update templates.asciidoc (#26036) 2017-08-08 11:29:11 +02:00
ingest add URL-Decode Processor to Ingest (#26045) 2017-08-07 10:26:11 -07:00
mapping percolator: Hint what clauses are important in a conjunction query based on fields 2017-08-11 15:32:01 +02:00
migration Migrate migration docs from 6.0 to 7.0 (#26227) 2017-08-16 13:12:44 -06:00
modules Fix script setting names in script security docs 2017-08-16 09:07:46 -04:00
query-dsl Add support for auto_generate_synonyms_phrase_query in match_query, multi_match_query, query_string and simple_query_string (#26097) 2017-08-09 12:15:09 +02:00
release-notes Migrate migration docs from 6.0 to 7.0 (#26227) 2017-08-16 13:12:44 -06:00
search Docs: Add search response took time explanation (#26202) 2017-08-15 08:43:26 +02:00
setup Rename CONF_DIR to ES_PATH_CONF 2017-08-15 06:19:06 +09:00
testing Docs: Replace deprecated pluginList with Arrays.asList (#24270) 2017-04-24 13:30:37 +02:00
aggregations.asciidoc Update aggregation.asciidoc (#24042) 2017-04-11 09:02:38 -04:00
analysis.asciidoc Add the ability to set an analyzer on keyword fields. (#21919) 2016-12-30 09:36:10 +01:00
api-conventions.asciidoc [Docs] Fix typo in api-conventions.asciidoc (#26171) 2017-08-15 14:09:10 +02:00
cat.asciidoc Enforce that responses in docs are valid json (#26249) 2017-08-17 09:02:10 -04:00
cluster.asciidoc [docs] include two cluster doc pages missing from index (#25180) 2017-06-12 12:33:56 -07:00
docs.asciidoc Inclusion of link to Multi Delete (#22619) 2017-01-16 12:58:59 +01:00
getting-started.asciidoc Enforce that responses in docs are valid json (#26249) 2017-08-17 09:02:10 -04:00
glossary.asciidoc Remove usage of multi-types from the docs and added a page explaining type removal (#25543) 2017-07-05 12:30:19 +02:00
gs-index.asciidoc [DOCS] Adding index file for GS "mini book". 2017-07-18 13:44:08 -07:00
how-to.asciidoc Correct grammar in list in how-to docs 2017-01-17 20:57:22 -05:00
index-modules.asciidoc describe how to apply best_compression (#25706) 2017-08-15 16:44:38 +02:00
index-shared1.asciidoc [DOCS] Split index-shared.asciidoc into multiple smaller files (#25302) 2017-06-19 15:14:53 -07:00
index-shared2.asciidoc [DOCS] Split index-shared.asciidoc into multiple smaller files (#25302) 2017-06-19 15:14:53 -07:00
index-shared3.asciidoc [DOCS] Split index-shared.asciidoc into multiple smaller files (#25302) 2017-06-19 15:14:53 -07:00
index.asciidoc Include shared/attributes.asciidoc from docs master 2017-07-03 18:17:34 +02:00
indices.asciidoc Remove shadow replicas 2017-04-11 11:26:26 -06:00
ingest.asciidoc Renamed all AUTOSENSE snippets to CONSOLE (#18210) 2016-05-09 15:42:23 +02:00
mapping.asciidoc [DOCS] Explain mapping explosion (#25654) 2017-07-14 09:47:41 +02:00
modules.asciidoc Docs: Cross-cluster search doc wasn't being included 2017-01-18 10:02:51 +01:00
query-dsl.asciidoc Fixed broken xrefs to query-dsl-not-query, which has been removed. 2015-10-20 13:01:37 -07:00
redirects.asciidoc Mark filtered query example as not to be used (#25661) 2017-07-14 11:45:21 +02:00
release-notes.asciidoc Migrate migration docs from 6.0 to 7.0 (#26227) 2017-08-16 13:12:44 -06:00
search.asciidoc Removed field-stats docs 2017-07-11 15:15:25 +02:00
setup.asciidoc Reorganised setup docs into better order 2017-07-21 11:24:46 +02:00
testing.asciidoc [DOCS] Test framework documentation 2013-12-02 18:01:45 +01:00