Skip to content

Commit 84d57a4

Browse files
authored
Add more example subfolders (#3505)
1 parent 4e4b5bf commit 84d57a4

File tree

133 files changed

+81
-49
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+81
-49
lines changed

docs/add-new-api.md

+32
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,35 @@ class Response {
166166
]
167167
}
168168
```
169+
170+
### Add endpoint request and response examples
171+
172+
Add an `examples` folder and `request` and `xxx_response` subfolders (where `xxx` is the relevant response code).
173+
174+
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.
175+
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.
176+
177+
For example:
178+
179+
```yaml
180+
summary: Sequence query
181+
# method_request: GET /my-data-stream/_eql/search
182+
# type: request
183+
description: >
184+
Run `GET /my-data-stream/_eql/search` to search for a sequence of events.
185+
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`.
186+
It is followed by an event with an `event.category` of `process` and a `process.executable` that contains the substring `regsvr32`.
187+
These events must also share the same `process.pid` value.
188+
value: |-
189+
{
190+
"query": """
191+
sequence by process.pid
192+
[ file where file.name == "cmd.exe" and process.pid != 2013 ]
193+
[ process where stringContains(process.executable, "regsvr32") ]
194+
"""
195+
}
196+
```
197+
198+
NOTE: A good example covers a very common use case or demonstrates a more complex but critical use case.
199+
It involves realistic data sets ( rather than generic "hello world" values).
200+
If it requires detailed setup or explanations, however, it is more appropriate for coverage in longer-form narrative documentation.

docs/overlays/elasticsearch-openapi-overlays.yaml

+24-24
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ actions:
149149
application/json:
150150
examples:
151151
nodesInfoResponseExample1:
152-
$ref: "../../specification/nodes/info/nodesInfoResponseExample1.yaml"
152+
$ref: "../../specification/nodes/info/examples/200_response/nodesInfoResponseExample1.yaml"
153153
- target: "$.paths['/_ilm/policy/{policy}']['delete']"
154154
description: "Add examples for delete lifecycle policy operation"
155155
update:
@@ -275,7 +275,7 @@ actions:
275275
application/json:
276276
examples:
277277
indicesCloneRequestExample1:
278-
$ref: "../../specification/indices/clone/indicesCloneRequestExample1.yaml"
278+
$ref: "../../specification/indices/clone/examples/request/indicesCloneRequestExample1.yaml"
279279
- target: "$.paths['/{index}/_close']['post']"
280280
description: "Add examples for close index response"
281281
update:
@@ -293,7 +293,7 @@ actions:
293293
application/json:
294294
examples:
295295
indicesDataStreamStatsResponseExample1:
296-
$ref: "../../specification/indices/data_streams_stats/indicesDataStreamStatsResponseExample1.yaml"
296+
$ref: "../../specification/indices/data_streams_stats/examples/200_response/indicesDataStreamStatsResponseExample1.yaml"
297297
- target: "$.paths['/{index}/_open']['post']"
298298
description: "Add examples for open index response"
299299
update:
@@ -303,7 +303,7 @@ actions:
303303
application/json:
304304
examples:
305305
indicesOpenResponseExample1:
306-
$ref: "../../specification/indices/open/indicesOpenResponseExample1.yaml"
306+
$ref: "../../specification/indices/open/examples/200_response/indicesOpenResponseExample1.yaml"
307307
- target: "$.paths['/_autoscaling/policy/{name}']['delete']"
308308
description: "Add examples for delete autoscaling policy response"
309309
update:
@@ -313,7 +313,7 @@ actions:
313313
application/json:
314314
examples:
315315
deleteAutoscalingPolicyResponseExample1:
316-
$ref: "../../specification/autoscaling/delete_autoscaling_policy/autoscalingApisDeleteAutoscalingPolicyResponseExample1.yaml"
316+
$ref: "../../specification/autoscaling/delete_autoscaling_policy/examples/response/DeleteAutoscalingPolicyResponseExample1.yaml"
317317
- target: "$.paths['/_autoscaling/capacity']['get']"
318318
description: "Add examples for get autoscaling capacity response"
319319
update:
@@ -323,7 +323,7 @@ actions:
323323
application/json:
324324
examples:
325325
getAutoscalingCapacityResponseExample1:
326-
$ref: "../../specification/autoscaling/get_autoscaling_capacity/autoscalingApisGetAutoscalingCapacityResponseExample1.yaml"
326+
$ref: "../../specification/autoscaling/get_autoscaling_capacity/examples/200_response/GetAutoscalingCapacityResponseExample1.yaml"
327327
- target: "$.paths['/_autoscaling/policy/{name}']['get']"
328328
description: "Add examples for get autoscaling policy response"
329329
update:
@@ -333,7 +333,7 @@ actions:
333333
application/json:
334334
examples:
335335
getAutoscalingPolicyResponseExample1:
336-
$ref: "../../specification/autoscaling/get_autoscaling_policy/autoscalingApisGetAutoscalingPolicyResponseExample1.yaml"
336+
$ref: "../../specification/autoscaling/get_autoscaling_policy/examples/200_response/GetAutoscalingPolicyResponseExample1.yaml"
337337
- target: "$.paths['/_autoscaling/policy/{name}']['put']"
338338
description: "Add examples for create autoscaling policy operation"
339339
update:
@@ -342,24 +342,24 @@ actions:
342342
application/json:
343343
examples:
344344
createAutoscalingPolicyRequestExample1:
345-
$ref: "../../specification/autoscaling/put_autoscaling_policy/autoscalingApisPutAutoscalingPolicyRequestExample1.yaml"
345+
$ref: "../../specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample1.yaml"
346346
createAutoscalingPolicyRequestExample2:
347-
$ref: "../../specification/autoscaling/put_autoscaling_policy/autoscalingApisPutAutoscalingPolicyRequestExample2.yaml"
347+
$ref: "../../specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample2.yaml"
348348
responses:
349349
200:
350350
content:
351351
application/json:
352352
examples:
353353
createAutoscalingPolicyResponseExample1:
354-
$ref: "../../specification/autoscaling/put_autoscaling_policy/autoscalingApisPutAutoscalingPolicyResponseExample1.yaml"
354+
$ref: "../../specification/autoscaling/put_autoscaling_policy/examples/200_response/PutAutoscalingPolicyResponseExample1.yaml"
355355
- target: "$.components['responses']['indices.recovery#200']"
356356
description: "Add example for get index recovery response"
357357
update:
358358
content:
359359
application/json:
360360
examples:
361361
getIndicesRecoveryResponseExample1:
362-
$ref: "../../specification/indices/recovery/indicesRecoveryResponseExample1.yaml"
362+
$ref: "../../specification/indices/recovery/examples/200_response/indicesRecoveryResponseExample1.yaml"
363363
- target: "$.paths['/_resolve/cluster/{name}']['get']"
364364
description: "Add examples for resolve cluster operation"
365365
update:
@@ -369,31 +369,31 @@ actions:
369369
application/json:
370370
examples:
371371
resolveClusterResponseExample1:
372-
$ref: "../../specification/indices/resolve_cluster/ResolveClusterResponseExample1.yaml"
372+
$ref: "../../specification/indices/resolve_cluster/examples/200_response/ResolveClusterResponseExample1.yaml"
373373
- target: "$.components['requestBodies']['indices.shrink']"
374374
description: "Add example for shrink index request"
375375
update:
376376
content:
377377
application/json:
378378
examples:
379379
indicesShrinkRequestExample1:
380-
$ref: "../../specification/indices/shrink/indicesShrinkRequestExample1.yaml"
380+
$ref: "../../specification/indices/shrink/examples/request/indicesShrinkRequestExample1.yaml"
381381
- target: "$.components['requestBodies']['indices.split']"
382382
description: "Add example for split index request"
383383
update:
384384
content:
385385
application/json:
386386
examples:
387387
indicesSplitRequestExample1:
388-
$ref: "../../specification/indices/split/indicesSplitRequestExample1.yaml"
388+
$ref: "../../specification/indices/split/examples/request/indicesSplitRequestExample1.yaml"
389389
- target: "$.components['requestBodies']['indices.put_template']"
390390
description: "Add example for legacy create template request"
391391
update:
392392
content:
393393
application/json:
394394
examples:
395395
indicesLegacyPutTemplateRequestExample1:
396-
$ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml"
396+
$ref: "../../specification/indices/put_template/examples/request/indicesPutTemplateRequestExample1.yaml"
397397
## Examples for behavioral analytics
398398
- target: "$.paths['/_application/analytics/{collection_name}/event/{event_type}']['post']"
399399
description: "Add examples for post analytics collection event operation"
@@ -403,7 +403,7 @@ actions:
403403
application/json:
404404
examples:
405405
postBehavioralAnalyticsEventRequestExample1:
406-
$ref: "../../specification/search_application/post_behavioral_analytics_event/BehavioralAnalyticsEventPostRequestExample1.yaml"
406+
$ref: "../../specification/search_application/post_behavioral_analytics_event/examples/request/BehavioralAnalyticsEventPostRequestExample1.yaml"
407407
## Examples for indices
408408
- target: "$.paths['/_lifecycle/stats']['get']"
409409
description: "Add examples for get lifecycle stats operation"
@@ -452,7 +452,7 @@ actions:
452452
application/json:
453453
examples:
454454
getBasicStatusResponseExample1:
455-
$ref: "../../specification/license/get_basic_status/GetBasicLicenseStatusResponseExample1.yaml"
455+
$ref: "../../specification/license/get_basic_status/examples/200_response/GetBasicLicenseStatusResponseExample1.yaml"
456456
- target: "$.paths['/_license/trial_status']['get']"
457457
description: "Add example for get trial status response"
458458
update:
@@ -462,7 +462,7 @@ actions:
462462
application/json:
463463
examples:
464464
getLicenseResponseExample1:
465-
$ref: "../../specification/license/get_trial_status/GetTrialLicenseStatusResponseExample1.yaml"
465+
$ref: "../../specification/license/get_trial_status/examples/200_response/GetTrialLicenseStatusResponseExample1.yaml"
466466
- target: "$.paths['/_license/start_basic']['post']"
467467
description: "Add example for start basic response"
468468
update:
@@ -472,7 +472,7 @@ actions:
472472
application/json:
473473
examples:
474474
startBasicLicenseResponseExample1:
475-
$ref: "../../specification/license/post_start_basic/StartBasicLicenseResponseExample1.yaml"
475+
$ref: "../../specification/license/post_start_basic/examples/200_response/StartBasicLicenseResponseExample1.yaml"
476476
- target: "$.paths['/_license/start_trial']['post']"
477477
description: "Add example for start trial response"
478478
update:
@@ -482,23 +482,23 @@ actions:
482482
application/json:
483483
examples:
484484
startTrialLicenseResponseExample1:
485-
$ref: "../../specification/license/post_start_trial/StartTrialLicenseResponseExample1.yaml"
485+
$ref: "../../specification/license/post_start_trial/examples/200_response/StartTrialLicenseResponseExample1.yaml"
486486
- target: "$.components['requestBodies']['license.post']"
487487
description: "Add examples for update license request"
488488
update:
489489
content:
490490
application/json:
491491
examples:
492492
updateLicenseRequestExample1:
493-
$ref: "../../specification/license/post/PostLicenseRequestExample1.yaml"
493+
$ref: "../../specification/license/post/examples/request/PostLicenseRequestExample1.yaml"
494494
- target: "$.components['responses']['license.post#200']"
495495
description: "Add examples for update license response"
496496
update:
497497
content:
498498
application/json:
499499
examples:
500500
clusterHealthResponseExample1:
501-
$ref: "../../specification/license/post/PostLicenseResponseExample1.yaml"
501+
$ref: "../../specification/license/post/examples/200_response/PostLicenseResponseExample1.yaml"
502502
## Examples for search applications
503503
- target: "$.paths['/_application/search_application/{name}/_render_query']['post']"
504504
description: "Add examples for render search application query operation"
@@ -508,9 +508,9 @@ actions:
508508
application/json:
509509
examples:
510510
renderSearchApplicationQueryRequestExample1:
511-
$ref: "../../specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml"
511+
$ref: "../../specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryRequestExample1.yaml"
512512
renderSearchApplicationQueryResponseExample1:
513-
$ref: "../../specification/search_application/render_query/SearchApplicationsRenderQueryResponseExample1.yaml"
513+
$ref: "../../specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryResponseExample1.yaml"
514514
# Examples for security
515515
- target: "$.paths['/_security/api_key/_bulk_update']['post']"
516516
description: "Add examples for bulk update API keys operation"

0 commit comments

Comments
 (0)