You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: API_STYLE_GUIDE.md
+12-9
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,14 @@
1
-
# API reference page template
1
+
# API Style Guide
2
2
3
-
This template provides the basic structure for creating OpenSearch API documentation. It includes the most important elements that should appear in the documentation and helpful suggestions to help support them.
3
+
This guide provides the basic structure for creating OpenSearch API documentation. It includes the various elements that we feel are most important to creating complete and useful API documentation, as well as description and examples where appropriate.
4
4
5
5
Depending on the intended purpose of the API, *some sections will be required while others may not be applicable*.
6
6
7
+
Use the [API_TEMPLATE](templates/API_TEMPLATE.md) to create an API documentation page.
8
+
7
9
### A note on terminology ###
8
10
9
-
Terminology for API parameters varies in the software industry, where two or even three names may be used to label the same type of parameter. For the sake of consistency, we use the following nomenclature for parameters in our API documentation:
11
+
Terminology for API parameters varies in the software industry, where two or even three names may be used to label the same type of parameter. For consistency, we use the following nomenclature for parameters in our API documentation:
10
12
**Path parameter* – "path parameter" and "URL parameter" are sometimes used synonymously. To avoid confusion, we use "path parameter" in this documentation.
11
13
**Query parameter* – This parameter name is often used synonymously with "request parameter." We use "query parameter" to be consistent.
12
14
@@ -24,7 +26,7 @@ Provide a REST API call example in `json` format. Optionally, also include the `
24
26
25
27
## Basic elements for documentation
26
28
27
-
The following sections describe the basic API documentation structure. Each section is discussed under its respective heading below. You can include only those elements appropriate to the API.
29
+
The following sections describe the basic API documentation structure. Each section is discussed under its respective heading. Include only those elements appropriate to the API.
28
30
29
31
Depending on where the documentation appears within a section or subsection, heading levels may be adjusted to fit with other content.
30
32
@@ -70,10 +72,11 @@ GET /_nodes/<node_id>/stats/<metric>/<index_metric>
70
72
71
73
While the API endpoint states a point of entry to a resource, the path parameter acts on the resource that precedes it. Path parameters come after the resource name in the URL.
72
74
75
+
In the following example, the resource is `scroll` and its path parameter is `<scroll_id>`:
76
+
73
77
```json
74
78
GET _search/scroll/<scroll_id>
75
79
```
76
-
In the example above, the resource is `scroll` and its path parameter is `<scroll_id>`.
77
80
78
81
Introduce what the path parameters can do at a high level. Provide a table with parameter names and descriptions. Include a table with the following columns:
79
82
*Parameter* – Parameter name in plain font.
@@ -87,12 +90,12 @@ Parameter | Data type | Description
87
90
88
91
In terms of placement, query parameters are always appended to the end of the URL and located to the right of the operator "?". Query parameters serve the purpose of modifying information to be retrieved from the resource.
89
92
93
+
In the following example, the endpoint is `aliases` and its query parameter is `v` (provides verbose output):
94
+
90
95
```json
91
96
GET _cat/aliases?v
92
97
```
93
98
94
-
In the example above, the endpoint is `aliases` and its query parameter is `v` (provides verbose output).
95
-
96
99
Include a paragraph that describes how to use the query parameters with an example in code font. Include the query parameter operator "?" to delineate query parameters from path parameters.
97
100
98
101
For GET and DELETE APIs: Introduce what you can do with the optional parameters. Include a table with the same columns as the path parameter table.
@@ -114,7 +117,7 @@ Field | Data type | Description
114
117
115
118
#### Example request
116
119
117
-
Provide a sentence that describes what is shown in the example, followed by a cut-and-paste-ready API request in JSON format. Make sure that you test the request yourself in the Dashboards Dev Tools console to make sure it works. See the examples below.
120
+
Provide a sentence that describes what is shown in the example, followed by a cut-and-paste-ready API request in JSON format. Make sure that you test the request yourself in the Dashboards Dev Tools console to make sure it works. See the following examples.
118
121
119
122
The following request gets all the settings in your index:
120
123
@@ -138,7 +141,7 @@ POST _reindex
138
141
139
142
#### Example response
140
143
141
-
Include a JSON example response to show what the API returns. See the examples below.
144
+
Include a JSON example response to show what the API returns. See the following examples.
142
145
143
146
The `GET /sample-index1/_settings` request returns the following response fields:
This is an experimental feature and is not recommended for use in a production environment. For updates on the progress of the feature or if you want to leave feedback, see the associated [GitHub issue](https://example.issue.link).
11
+
{: .warning}
12
+
13
+
This is an experimental feature and is not recommended for use in a production environment. For updates on the progress the feature or if you want to leave feedback, join the discussion in the [OpenSearch forum](https://forum.opensearch.org/).
0 commit comments