diff --git a/STYLE_API_TEMPLATE.md b/API_STYLE_GUIDE.md similarity index 88% rename from STYLE_API_TEMPLATE.md rename to API_STYLE_GUIDE.md index 0002e908..6dc40df0 100644 --- a/STYLE_API_TEMPLATE.md +++ b/API_STYLE_GUIDE.md @@ -1,12 +1,14 @@ -# API reference page template +# API Style Guide -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. +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. Depending on the intended purpose of the API, *some sections will be required while others may not be applicable*. +Use the [API_TEMPLATE](templates/API_TEMPLATE.md) to create an API documentation page. + ### A note on terminology ### -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: +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: * *Path parameter* – "path parameter" and "URL parameter" are sometimes used synonymously. To avoid confusion, we use "path parameter" in this documentation. * *Query parameter* – This parameter name is often used synonymously with "request parameter." We use "query parameter" to be consistent. @@ -24,7 +26,7 @@ Provide a REST API call example in `json` format. Optionally, also include the ` ## Basic elements for documentation -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. +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. Depending on where the documentation appears within a section or subsection, heading levels may be adjusted to fit with other content. @@ -70,10 +72,11 @@ GET /_nodes//stats// 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. +In the following example, the resource is `scroll` and its path parameter is ``: + ```json GET _search/scroll/ ``` -In the example above, the resource is `scroll` and its path parameter is ``. 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: *Parameter* – Parameter name in plain font. @@ -87,12 +90,12 @@ Parameter | Data type | Description 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. +In the following example, the endpoint is `aliases` and its query parameter is `v` (provides verbose output): + ```json GET _cat/aliases?v ``` -In the example above, the endpoint is `aliases` and its query parameter is `v` (provides verbose output). - 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. 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 #### Example request -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. +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. The following request gets all the settings in your index: @@ -138,7 +141,7 @@ POST _reindex #### Example response -Include a JSON example response to show what the API returns. See the examples below. +Include a JSON example response to show what the API returns. See the following examples. The `GET /sample-index1/_settings` request returns the following response fields: diff --git a/FORMATTING_GUIDE.md b/FORMATTING_GUIDE.md index fc18d2fa..d5a4d222 100644 --- a/FORMATTING_GUIDE.md +++ b/FORMATTING_GUIDE.md @@ -9,6 +9,7 @@ This guide provides an overview of the formatted elements commonly used in the O * [Adding pages or sections](#adding-pages-or-sections) * [Buttons](#buttons) * [Callouts](#callouts) +* [Collapsible blocks](#collapsible-blocks) * [Dashes](#dashes) * [Horizontal rule](#horizontal-rule) * [Images](#images) @@ -91,6 +92,31 @@ For a callout with multiple paragraphs or lists, use `>`: ``` +## Collapsible blocks + +To insert a collapsible block, use the `
` element as follows: + +````html +
+ + Response + + {: .text-delta} + +```json +{ + "_nodes" : { + "total" : 1, + "successful" : 1, + "failed" : 0 + } +} +``` +
+```` + +Collapsible blocks are useful for long responses and for the Table of Contents at the beginning of a page. + ## Dashes Use one dash for hyphens, two for en dashes, and three for em dashes: diff --git a/templates/API_TEMPLATE.md b/templates/API_TEMPLATE.md new file mode 100644 index 00000000..669dcb80 --- /dev/null +++ b/templates/API_TEMPLATE.md @@ -0,0 +1,89 @@ +--- +layout: default +title: Example API +parent: +nav_order: +--- + +# Example API +Introduced 1.0 +{: .label .label-purple } + +The Example API ... (descriptive sentence about what this API does). + +## Path and HTTP methods + +```json +POST /_example/endpoint/ +POST /_example/endpoint/ +``` + +## Path parameters + +The following table lists the available path parameters. All path parameters are optional. + +| Parameter | Data type | Description | +| :--- | :--- | :--- | +| `path_parameter` | Type | Example path parameter description. Default is ... | + +## Query parameters + +The following table lists the available query parameters. All query parameters are optional. + +| Parameter | Data type | Description | +| :--- | :--- | :--- | +| `query_parameter` | String | Example query parameter description. Default is ... | + +## Request fields + +The following table lists the available request fields. + +| Field | Data type | Description | +| :--- | :--- | :--- | +| `example_object` | Object | Example object description. | +| `example_object.required_request_field` | Type | Required request field description. Required. | +| `example_object.optional_request_field` | Type | Optional request field description. Optional. Default is ... | + +#### Example request + +```json +POST /_example/endpoint/ +{ + "example_object": { + "required_request_field": "example value", + "optional_request_field": "example value" + } +} +``` +{% include copy-curl.html %} + +#### Example response + +
+ + Response + + {: .text-delta} + +```json +{ + "_nodes" : { + "total" : 1, + "successful" : 1, + "failed" : 0 + } +} +``` +
+ +## Response fields + +The following table lists all response fields. + +| Field | Data type | Description | +| :--- | :--- | :--- | +| `response_field` | Type | Required field description. | + +## Required permissions + +If you use the Security plugin, make sure you have the appropriate permissions: `cluster:example/permission/name`. diff --git a/templates/EXPERIMENTAL_TEMPLATE.md b/templates/EXPERIMENTAL_TEMPLATE.md new file mode 100644 index 00000000..6aa06c58 --- /dev/null +++ b/templates/EXPERIMENTAL_TEMPLATE.md @@ -0,0 +1,14 @@ +--- +layout: default +title: Experimental feature name +nav_order: +parent: +--- + +# Experimental feature name + +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). +{: .warning} + +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/). +{: .warning} \ No newline at end of file