Skip to content

Commit

Permalink
Fix/add /_render/template.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Dec 10, 2024
1 parent 7a8d7df commit 64c488a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
7 changes: 3 additions & 4 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
64 changes: 64 additions & 0 deletions tests/default/_core/render/template.yaml
Original file line number Diff line number Diff line change
@@ -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


3 changes: 3 additions & 0 deletions tests/default/search/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ epilogues:
- path: /movies
method: DELETE
status: [200, 404]
- path: /movies
method: DELETE
status: [200, 404]
prologues:
- path: /_bulk
method: POST
Expand Down

0 comments on commit 64c488a

Please sign in to comment.