Skip to content

Commit db5c053

Browse files
committed
Refactor, split into separate guides, add tabs, address review feedback
1 parent 4559483 commit db5c053

File tree

4 files changed

+439
-360
lines changed

4 files changed

+439
-360
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
navigation_title: Elasticsearch API docs
3+
---
4+
5+
# Contribute to Elasticsearch API docs locally
6+
7+
## Overview
8+
9+
The Elasticsearch APIs are the foundation of the Elastic Stack and the largest API set we maintain. Because the workflow is quite complex, we created this quickstart guide to help you get started.
10+
11+
This is a step-by-step local development workflow. While CI runs these steps automatically on PR branches in the `elasticsearch-specification` repo (see [Makefile](https://github.com/elastic/elasticsearch-specification/blob/main/Makefile)), working locally enables you to validate, preview and debug before submitting your changes. For a complete list of available make targets, run `make help`.
12+
13+
For the official Elasticsearch specification contribution guidance, see [`CONTRIBUTING.md`](https://github.com/elastic/elasticsearch-specification/blob/main/CONTRIBUTING.md#contributing-to-the-elasticsearch-specification).
14+
15+
## Quickstart
16+
17+
Follow these steps to contribute to Elasticsearch API docs locally:
18+
19+
:::::{stepper}
20+
21+
::::{step} Prepare your environment
22+
23+
Run this command to set up your Node.js environment:
24+
25+
```shell
26+
nvm use
27+
```
28+
If you don't have Node.js installed, refer to the [setup guide](https://github.com/elastic/elasticsearch-specification/tree/main?tab=readme-ov-file#prepare-the-environment).
29+
::::
30+
31+
::::{step} Clone the specification repo
32+
```shell
33+
git clone https://github.com/elastic/elasticsearch-specification.git
34+
cd elasticsearch-specification
35+
```
36+
:::{warning}
37+
You must [create PRs from a branch](https://github.com/elastic/elasticsearch-specification/blob/main/CONTRIBUTING.md#send-your-pull-request-from-a-branch) in the `elasticsearch-specification` repo, not a fork.
38+
:::
39+
::::
40+
41+
::::{step} Install dependencies
42+
```shell
43+
make setup
44+
```
45+
46+
:::{important}
47+
You should run `make setup` every time you begin work on a contribution, because the `elasticsearch-specification` repository is under active development. This ensures you have the latest dependencies and tools.
48+
:::
49+
50+
::::
51+
52+
::::{step} Make your docs changes
53+
Edit the relevant TypeScript files in the `specification` directory. Use JSDoc comments to describe your API interfaces, following the [guidelines](./guidelines.md). Add or update summaries, descriptions, tags, metadata, links, and examples as needed.
54+
55+
:::{important}
56+
If you're adding a new API, you must first create a REST API specification file in the [`specification/_json_spec`](https://github.com/elastic/elasticsearch-specification/tree/main/specification/_json_spec) directory.
57+
:::
58+
59+
::::{step} Format, generate and validate your changes
60+
```shell
61+
make contrib
62+
```
63+
This command runs multiple steps in sequence:
64+
65+
1. Formats your code (`spec-format-fix`)
66+
2. Generates the schema JSON (`generate`)
67+
3. Transforms to OpenAPI format for language clients (`transform-to-openapi`)
68+
4. Filters for serverless (`filter-for-serverless`)
69+
5. Lints the language clients OpenAPIdocs (`lint-docs`)
70+
71+
:::{note}
72+
Some of the linter errors at this stage may be false alarms, and are fixed by path consolidation and overlays. You'll need to run `make lint` later against the docs-specific OpenAPI files.
73+
:::
74+
::::
75+
76+
::::{step} Generate docs-specific OpenAPI files
77+
```shell
78+
make transform-to-openapi-for-docs
79+
```
80+
Generates the OpenAPI files specifically for docs purposes. This step also runs `generate-language-examples` to autogenerate examples for the various language clients and `curl`.
81+
82+
:::{note}
83+
The `transform-to-openapi` command (run by `make contrib`) is used for client libraries and does not generate the JSON schema files needed for docs purposes.
84+
:::
85+
::::
86+
87+
::::{step} Apply overlays
88+
89+
[OpenAPI overlays](https://github.com/OAI/Overlay-Specification?tab=readme-ov-file#overlay-specification) are used to handle publisher-specific requirements or work around rendering limitations. For example, they sort the list of tags alphabetically and apply `x-model` extensions to abbreviate deeply nested/recursive schema objects.
90+
91+
```shell
92+
make overlay-docs
93+
```
94+
::::
95+
96+
::::{step} Lint your docs
97+
98+
Run this command to lint your docs-specific OpenAPI files:
99+
```shell
100+
make lint-docs
101+
```
102+
:::{tip}
103+
You should try to fix all linter warnings and not just errors. Fixing errors alone will not ensure your docs are complete, i.e. helpful for users.
104+
:::
105+
::::
106+
107+
::::{step} Preview your changes
108+
Generate a preview of how your docs will appear:
109+
```shell
110+
npm install -g bump-cli
111+
bump preview output/openapi/elasticsearch-openapi-docs-final.json # Preview Elasticsearch API docs
112+
bump preview output/openapi/elasticsearch-serverless-openapi-docs-final.json # Preview Elasticsearch serverless API docs
113+
```
114+
This creates a temporary URL to preview your changes and share with others.
115+
::::
116+
117+
::::{step} Open a pull request
118+
119+
Once you're satisfied with your docs changes:
120+
1. Create a pull request from a branch on your local clone
121+
2. The CI will validate your OpenAPI specs
122+
3. Once approved, merge your changes and ensure they are backported to the appropriate branches
123+
::::
124+
125+
:::::

0 commit comments

Comments
 (0)