|
8 | 8 | - [Query parameters](#query-parameters) |
9 | 9 | - [Path parameters](#path-parameters) |
10 | 10 | - [Endpoints](#endpoints) |
11 | | - |
| 11 | + - [Example_Code](#example_code) |
| 12 | + |
12 | 13 | ## Introduction |
13 | 14 |
|
14 | 15 | The `.md` documents in this repository are rendered into HTML pages using [Jekyll](https://jekyllrb.com/). These HTML pages are hosted on [opensearch.org](https://docs.opensearch.org/latest/). |
@@ -88,6 +89,65 @@ All spec insert components accept the following arguments: |
88 | 89 | - `component` (String; required): The name of the component to render, such as `query_parameters`, `path_parameters`, or `endpoints`. |
89 | 90 | - `omit_header` (Boolean; Default is `false`): If set to `true`, the markdown header of the component will not be rendered. |
90 | 91 |
|
| 92 | +### Example_Code |
| 93 | + |
| 94 | +- `api` should not be placed for the `component: example_code` tag. `rest` is mapped to the correct API by regex mapping. |
| 95 | +- `rest` (String; required): The HTTP request line (`HTTP method` + `endpoint path`) that is regex mapped to the `opensearch-openapi.yaml`. |
| 96 | + |
| 97 | +The following tags are included to help with additional needs: |
| 98 | + |
| 99 | +- `body` (String; optional): The request body for the API call, using YAML `|` to preserve newlines and indentation. |
| 100 | +- `include_client_setup:` (Boolean; Default is `false`): If set to `true`, the client setup for the language will be rendered. |
| 101 | +- `skip` (Boolean; Default is `false`): If set to `true`, the language conversions will not render/re-render. Use for manual conversions. |
| 102 | + |
| 103 | +To insert multi-language support for the `cat.allocation` API, use the following snippet: |
| 104 | + |
| 105 | +```markdown |
| 106 | +<!-- spec_insert_start |
| 107 | +component: example_code |
| 108 | +rest: GET /_cat/allocation?v |
| 109 | +--> |
| 110 | +<!-- spec_insert_end --> |
| 111 | +``` |
| 112 | + |
| 113 | +To insert multi-language support for the `index` API with a request body, use the following snippet. The `|` is needed for multiline support for the body: |
| 114 | + |
| 115 | +```markdown |
| 116 | +<!-- spec_insert_start |
| 117 | +component: example_code |
| 118 | +rest: PUT /_settings?expand_wildcards=all&analyze_wildcard |
| 119 | +body: | |
| 120 | + { |
| 121 | + "index": { |
| 122 | + "number_of_replicas": 2 |
| 123 | + } |
| 124 | + } |
| 125 | +--> |
| 126 | +<!-- spec_insert_end --> |
| 127 | +``` |
| 128 | + |
| 129 | +To insert multi-language support for the `index` API and include the client setup for each language, use the following snippet: |
| 130 | + |
| 131 | +```markdown |
| 132 | +<!-- spec_insert_start |
| 133 | +component: example_code |
| 134 | +rest: PUT /_settings?expand_wildcards=all&analyze_wildcard |
| 135 | +include_client_setup: true |
| 136 | +--> |
| 137 | +<!-- spec_insert_end --> |
| 138 | +``` |
| 139 | + |
| 140 | +To insert multi-language support for the `index` API but need to manually set the multi-language example for the `index` API, use the following snippet: |
| 141 | + |
| 142 | +```markdown |
| 143 | +<!-- spec_insert_start |
| 144 | +component: example_code |
| 145 | +rest: PUT /_settings?expand_wildcards=all&analyze_wildcard |
| 146 | +skip: true |
| 147 | +--> |
| 148 | +<!-- spec_insert_end --> |
| 149 | +``` |
| 150 | + |
91 | 151 | ### Endpoints |
92 | 152 | To insert endpoints for the `search` API, use the following snippet: |
93 | 153 |
|
|
0 commit comments