docs-v2/api-docs/README.md

61 lines
2.4 KiB
Markdown
Raw Normal View History

2019-09-27 20:42:01 +00:00
## Generate InfluxDB API docs
InfluxDB uses [Redoc](https://github.com/Redocly/redoc/),
[redoc-cli](https://github.com/Redocly/redoc/blob/master/cli/README.md),
and Redocly's [OpenApi CLI](https://redoc.ly/docs/cli/) to generate
API documentation from the InfluxDB openapi contracts.
2019-09-27 20:42:01 +00:00
2019-09-30 16:16:09 +00:00
To minimize repo size, the generated API documentation HTML is gitignored, therefore
not committed directly to the docs repo.
The InfluxDB docs deployment process uses swagger files in the `api-docs` directory
to generate version-specific API documentation.
2019-09-27 20:42:01 +00:00
2019-09-30 16:16:09 +00:00
### Versioned swagger files
Install dependencies as project dependencies from NPM repo (#2476) * Added hugo-extended, postcss, postcss-cli, and autoprefixer as devDependencies. Run npm install or yarn install. (#2474) * Replaced global hugo and yarn installs with project-level yarn install. * Replaced npm package.lock with yarn.lock (#2474). * enhancement: update README with instructions for installing NODE.JS dependencies. (#2474) * updated api doc generator script to use npx * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update package.json Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * fix: indentation. (#2476) * update: Added separate dependencies list for api-docs. - Moved redoc-cli to a separate package.json in api-docs. Excluded api-docs/node_modules from generate-api-docs.sh. - Updated redoc-cli argument sequence to agree with their docs. - Updated READMEs. - Fixed typos. * update: add api-docs > yarn install to .circleci * Added language and consistency to code block. Specify where to run the command. Co-authored-by: Scott Anderson <scott@influxdata.com> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-05-24 17:11:01 +00:00
The structure versions swagger files using the following pattern:
2019-09-30 16:59:25 +00:00
2019-09-27 20:42:01 +00:00
```
2019-09-30 16:16:09 +00:00
api-docs/
├── v2.0/
│ └── ref.yml
2019-09-30 16:16:09 +00:00
├── v2.1/
│ └── ref.yml
2019-09-30 16:16:09 +00:00
├── v2.2/
│ └── ref.yml
└── etc...
```
### Configure OpenAPI CLI linting and bundling
`.redoc.yaml` sets linting and bundling options for `openapi` CLI.
`./openapi/plugins` contains custom OpenAPI CLI plugins composed of *rules* (for linting) and *decorators* (for bundle customization).
### Custom content
`./openapi/content` contains custom OAS (OpenAPI Spec) content in YAML files. The content structure and Markdown must be valid OAS.
`./openapi/plugins` use `./openapi/plugins/decorators` to apply the content to the contracts.
`.yml` files in `./openapi/content/` set content for sections (nodes) in the contract. To update the content for those nodes, you only need to update the YAML files.
To add new YAML files for other nodes in the openapi contracts, configure the new content YAML file in `./openapi/content/content.js`. Then, write a decorator module for the node and configure the decorator in the plugin, e.g. `./openapi/plugins/docs-plugin.js`. See the [complete list of OAS v3.0 nodes](https://github.com/Redocly/openapi-cli/blob/master/packages/core/src/types/oas3.ts#L529).
`openapi` CLI requires that modules use CommonJS `require` syntax for imports.
2019-09-30 16:16:09 +00:00
### Generate API docs locally
Because the API documentation HTML is gitignored, you must manually generate it
to view the API docs locally.
Verify that you have a working `npx` (it's included with Node.js).
In your terminal, run:
2019-09-30 16:16:09 +00:00
```sh
npx --version
```
Install dependencies as project dependencies from NPM repo (#2476) * Added hugo-extended, postcss, postcss-cli, and autoprefixer as devDependencies. Run npm install or yarn install. (#2474) * Replaced global hugo and yarn installs with project-level yarn install. * Replaced npm package.lock with yarn.lock (#2474). * enhancement: update README with instructions for installing NODE.JS dependencies. (#2474) * updated api doc generator script to use npx * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update package.json Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * fix: indentation. (#2476) * update: Added separate dependencies list for api-docs. - Moved redoc-cli to a separate package.json in api-docs. Excluded api-docs/node_modules from generate-api-docs.sh. - Updated redoc-cli argument sequence to agree with their docs. - Updated READMEs. - Fixed typos. * update: add api-docs > yarn install to .circleci * Added language and consistency to code block. Specify where to run the command. Co-authored-by: Scott Anderson <scott@influxdata.com> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-05-24 17:11:01 +00:00
If `npx` returns errors, [download](https://nodejs.org/en/) and run a recent version of the Node.js installer for your OS.
Install dependencies as project dependencies from NPM repo (#2476) * Added hugo-extended, postcss, postcss-cli, and autoprefixer as devDependencies. Run npm install or yarn install. (#2474) * Replaced global hugo and yarn installs with project-level yarn install. * Replaced npm package.lock with yarn.lock (#2474). * enhancement: update README with instructions for installing NODE.JS dependencies. (#2474) * updated api doc generator script to use npx * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update package.json Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * fix: indentation. (#2476) * update: Added separate dependencies list for api-docs. - Moved redoc-cli to a separate package.json in api-docs. Excluded api-docs/node_modules from generate-api-docs.sh. - Updated redoc-cli argument sequence to agree with their docs. - Updated READMEs. - Fixed typos. * update: add api-docs > yarn install to .circleci * Added language and consistency to code block. Specify where to run the command. Co-authored-by: Scott Anderson <scott@influxdata.com> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-05-24 17:11:01 +00:00
In your terminal, from the root of the docs repo, run:
Install dependencies as project dependencies from NPM repo (#2476) * Added hugo-extended, postcss, postcss-cli, and autoprefixer as devDependencies. Run npm install or yarn install. (#2474) * Replaced global hugo and yarn installs with project-level yarn install. * Replaced npm package.lock with yarn.lock (#2474). * enhancement: update README with instructions for installing NODE.JS dependencies. (#2474) * updated api doc generator script to use npx * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update package.json Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * fix: indentation. (#2476) * update: Added separate dependencies list for api-docs. - Moved redoc-cli to a separate package.json in api-docs. Excluded api-docs/node_modules from generate-api-docs.sh. - Updated redoc-cli argument sequence to agree with their docs. - Updated READMEs. - Fixed typos. * update: add api-docs > yarn install to .circleci * Added language and consistency to code block. Specify where to run the command. Co-authored-by: Scott Anderson <scott@influxdata.com> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-05-24 17:11:01 +00:00
```sh
Install dependencies as project dependencies from NPM repo (#2476) * Added hugo-extended, postcss, postcss-cli, and autoprefixer as devDependencies. Run npm install or yarn install. (#2474) * Replaced global hugo and yarn installs with project-level yarn install. * Replaced npm package.lock with yarn.lock (#2474). * enhancement: update README with instructions for installing NODE.JS dependencies. (#2474) * updated api doc generator script to use npx * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * Update README.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update package.json Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * fix: indentation. (#2476) * update: Added separate dependencies list for api-docs. - Moved redoc-cli to a separate package.json in api-docs. Excluded api-docs/node_modules from generate-api-docs.sh. - Updated redoc-cli argument sequence to agree with their docs. - Updated READMEs. - Fixed typos. * update: add api-docs > yarn install to .circleci * Added language and consistency to code block. Specify where to run the command. Co-authored-by: Scott Anderson <scott@influxdata.com> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-05-24 17:11:01 +00:00
cd api-docs
2019-09-30 16:16:09 +00:00
# Generate the API docs
sh generate-api-docs.sh
2019-09-27 20:42:01 +00:00
```