diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index d48733fd5..a1c0e68b0 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -2482,16 +2482,15 @@ components: schema: type: object properties: - file: - type: string + id: + $ref: '../schemas/_common.yaml#/components/schemas/Id' params: description: |- Key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value. type: object - additionalProperties: - type: object + additionalProperties: true source: description: |- An inline search template. diff --git a/tests/default/_core/render/template.yaml b/tests/default/_core/render/template.yaml new file mode 100644 index 000000000..839d10dc0 --- /dev/null +++ b/tests/default/_core/render/template.yaml @@ -0,0 +1,64 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test rendering a search template as a search query. + +prologues: + - path: /_scripts/movie_template + method: POST + request: + content_type: application/json + payload: + script: + lang: mustache + source: > + { + "query": { + "match": { + "{{field}}": "{{value}}" + } + } + } +epilogues: + - path: /_scripts/movie_template + method: DELETE + status: [200, 404] +chapters: + - synopsis: Render the movie template (request payload). + path: /_render/template + method: + - GET + - POST + request: + payload: + id: movie_template + params: + field: director + value: Quentin Tarantino + response: + status: 200 + payload: + template_output: + query: + match: + director: Quentin Tarantino + - synopsis: Render the movie template (path). + path: /_render/template/{id} + method: + - GET + - POST + parameters: + id: movie_template + request: + payload: + params: + field: director + value: Christopher Nolan + response: + status: 200 + payload: + template_output: + query: + match: + director: Christopher Nolan + + diff --git a/tests/default/search/template.yaml b/tests/default/search/template.yaml index 956f6fbd9..a0aeff1a1 100644 --- a/tests/default/search/template.yaml +++ b/tests/default/search/template.yaml @@ -5,6 +5,9 @@ epilogues: - path: /movies method: DELETE status: [200, 404] + - path: /movies + method: DELETE + status: [200, 404] prologues: - path: /_bulk method: POST