Skip to content

Commit 40a13d2

Browse files
committed
Add tips to the readme
1 parent c9d7136 commit 40a13d2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/add-new-api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,35 @@ class Response {
153153
]
154154
}
155155
```
156+
157+
### Add endpoint request and response examples
158+
159+
Add an `examples` folder and `request` and `xxx_response` subfolders (where `xxx` is the relevant response code).
160+
161+
These examples are for use in the API documentation and must adhere to the [OpenAPI 3.0 Example object specification](https://spec.openapis.org/oas/v3.0.3#example-object). They must have a `value` field that contains the request or response body.
162+
If there are multiple examples for the endpoint, they must each have a brief `summary` field, which is used as the label for the example. You can also optionaly provide an explanation in a `description` field.
163+
164+
For example:
165+
166+
```yaml
167+
summary: Sequence query
168+
# method_request: GET /my-data-stream/_eql/search
169+
# type: request
170+
description: >
171+
Run `GET /my-data-stream/_eql/search` to search for a sequence of events.
172+
The sequence starts with an event with an `event.category` of `file`, a `file.name` of `cmd.exe`, and a `process.pid` other than `2013`.
173+
It is followed by an event with an `event.category` of `process` and a `process.executable` that contains the substring `regsvr32`.
174+
These events must also share the same `process.pid` value.
175+
value: |-
176+
{
177+
"query": """
178+
sequence by process.pid
179+
[ file where file.name == "cmd.exe" and process.pid != 2013 ]
180+
[ process where stringContains(process.executable, "regsvr32") ]
181+
"""
182+
}
183+
```
184+
185+
NOTE: A good example covers a very common use case or demonstrates a more complex but critical use case.
186+
It involves realistic data sets ( rather than generic "hello world" values).
187+
If it requires detailed setup or explanations, however, it is more appropriate for coverage in longer-form narrative documentation.

0 commit comments

Comments
 (0)