Skip to content

Commit 4314589

Browse files
committed
feat(v3): WIP: Revise API specs for Core and Enterprise
- Adds basic support for core and enterprise in getswagger.sh - Adds custom OpenAPI info for Core and Enterprise - Validates as OpenAPI 3.0 (using Spectral) - operationId - tags - Revises use of Legacy, v2 - TODO: need to check and validate in UI, adjust tags if nec. - Add and remove components - Update parameters - Add examples - Add tests for Core
1 parent f11461a commit 4314589

File tree

26 files changed

+3150
-179
lines changed

26 files changed

+3150
-179
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extends: substitution
2+
message: Did you mean '%s' instead of '%s'
3+
level: warning
4+
ignorecase: false
5+
# swap maps tokens in form of bad: good
6+
# NOTE: The left-hand (bad) side can match the right-hand (good) side;
7+
# Vale ignores alerts that match the intended form.
8+
swap:
9+
'cloud-serverless|cloud-dedicated|clustered': core
10+
'Cloud Serverless|Cloud Dedicated|Clustered': Core
11+
'API token': database token
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extends: substitution
2+
message: Did you mean '%s' instead of '%s'
3+
level: warning
4+
ignorecase: false
5+
# swap maps tokens in form of bad: good
6+
# NOTE: The left-hand (bad) side can match the right-hand (good) side;
7+
# Vale ignores alerts that match the intended form.
8+
swap:
9+
'(?i)bucket': database
10+
'(?i)measurement': table

.frontmatter-schema.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"title": {
6+
"type": "string",
7+
"description": "Title of the page"
8+
},
9+
"description": {
10+
"type": "string",
11+
"description": "Page description that supports multi-line text"
12+
},
13+
"menu": {
14+
"type": "object",
15+
"properties": {
16+
"influxdb3_core": {
17+
"type": "object",
18+
"properties": {
19+
"name": {
20+
"type": "string",
21+
"description": "Menu item name"
22+
}
23+
},
24+
"required": ["name"]
25+
}
26+
}
27+
},
28+
"weight": {
29+
"type": "integer",
30+
"description": "Order weight for menu items",
31+
"minimum": 0
32+
},
33+
"source": {
34+
"type": "string",
35+
"description": "Path to source content file",
36+
"pattern": "^/shared/.+\\.md$"
37+
}
38+
},
39+
"required": ["title", "description", "menu", "weight"]
40+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node_modules
88
*.log
99
/resources
1010
.hugo_build.lock
11-
/content/influxdb/*/api/**/*.html
11+
/content/influxdb*/*/api/**/*.html
1212
/api-docs/redoc-static.html*
1313
.vscode/*
1414
.idea

.vscode/settings.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
{
2-
"vale.valeCLI.config": " \"${workspaceFolder}/.vale.ini\"",
2+
"commentAnchors.tags.anchors":
3+
{ "SOURCE": {
4+
"scope": "file",
5+
"behavior": "link",
6+
"iconColor": "#FF0000",
7+
"highlightColor": "#FF0000",
8+
"style": "bold"
9+
}},
10+
"commentAnchors.workspace.matchFiles": "**/*.{md,ini,json,yaml,yml}",
11+
"commentAnchors.workspace.enabled": true,
12+
"yaml.schemas": {
13+
"./.frontmatter-schema.json": "${workspaceFolder}/content/**/*.md"
14+
},
15+
"vale.valeCLI.config": "${workspaceFolder}/.vale.ini",
316
"vale.valeCLI.minAlertLevel": "warning",
417
}

CONTRIBUTING.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ To install dependencies listed in package.json:
4646
4. Install the Yarn package manager and run `yarn` to install project dependencies.
4747

4848
`package.json` contains dependencies for linting and running Git hooks.
49+
docs-v2 uses [Lefthook](https://github.com/evilmartians/lefthook) to configure and manage pre-commit hooks for linting and testing Markdown content.
50+
51+
Other dependencies used in the project:
4952

50-
- **[husky](https://github.com/typicode/husky)**: manages Git hooks, including the pre-commit hook for linting and testing
51-
- **[lint-staged](https://github.com/lint-staged/lint-staged)**: passes staged files to commands
5253
- **[prettier](https://prettier.io/docs/en/)**: formats code, including Markdown, according to style rules for consistency
5354

5455
### Install Docker
@@ -72,6 +73,17 @@ docker build -t influxdata:docs-pytest -f Dockerfile.pytest .
7273

7374
To run the documentation locally, follow the instructions provided in the README.
7475

76+
### Install Visual Studio Code extensions
77+
78+
If you use Microsoft Visual Studio (VS) Code, you can install extensions
79+
to help you navigate, check, and edit files.
80+
81+
docs-v2 contains a `./.vscode/settings.json` that configures the following extensions:
82+
83+
- Comment Anchors: recognizes tags (for example, `//SOURCE`) and makes links and filepaths clickable in comments.
84+
- Vale: shows linter errors and suggestions in the editor.
85+
- YAML Schemas: validates frontmatter attributes.
86+
7587
### Make your changes
7688

7789
Make your suggested changes being sure to follow the [style and formatting guidelines](#style--formatting) outline below.
@@ -80,27 +92,25 @@ Make your suggested changes being sure to follow the [style and formatting guide
8092

8193
### Automatic pre-commit checks
8294

83-
docs-v2 uses Husky to manage Git hook scripts.
84-
When you try to commit your changes (for example, `git commit`), Git runs
85-
scripts configured in `.husky/pre-commit`, including linting and tests for your **staged** files.
95+
docs-v2 uses Lefthook to manage Git hooks, such as pre-commit hooks that lint Markdown and test code blocks.
96+
When you try to commit changes (`git commit`), Git runs
97+
the commands configured in `lefthook.yml` which pass your **staged** files to Vale, Prettier, and Pytest (in a Docker container).
8698

8799
### Skip pre-commit hooks
88100

89101
**We strongly recommend running linting and tests**, but you can skip them
90102
(and avoid installing dependencies)
91-
by including the `HUSKY=0` environment variable or the `--no-verify` flag with
103+
by including the `LEFTHOOK=0` environment variable or the `--no-verify` flag with
92104
your commit--for example:
93105

94106
```sh
95107
git commit -m "<COMMIT_MESSAGE>" --no-verify
96108
```
97109

98110
```sh
99-
HUSKY=0 git commit
111+
LEFTHOOK=0 git commit
100112
```
101113

102-
For more options, see the [Husky documentation](https://typicode.github.io/husky/how-to.html#skipping-git-hooks).
103-
104114
### Set up test scripts and credentials
105115

106116
To set up your docs-v2 instance to run tests locally, do the following:

Dockerfile.pytest

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
3434
telegraf \
3535
wget
3636

37+
# Install InfluxDB 3 Core
38+
RUN curl -O https://www.influxdata.com/d/install_influxdb3.sh \
39+
&& chmod +x install_influxdb3.sh \
40+
&& bash -c yes | ./install_influxdb3.sh
41+
3742
RUN ln -s /usr/bin/python3 /usr/bin/python
3843

3944
# Create a virtual environment for Python to avoid conflicts with the system Python and having to use the --break-system-packages flag when installing packages with pip.

api-docs/getswagger.sh

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function showHelp {
6262
subcommand=$1
6363

6464
case "$subcommand" in
65-
cloud-dedicated-v2|cloud-dedicated-management|cloud-serverless-v2|clustered-v2|cloud-v2|v2|v1-compat|all)
65+
cloud-dedicated-v2|cloud-dedicated-management|cloud-serverless-v2|clustered-v2|cloud-v2|v2|v1-compat|core-v3|enterprise-v3|all)
6666
product=$1
6767
shift
6868

@@ -176,6 +176,17 @@ function updateCloudDedicatedV2 {
176176
postProcess $outFile 'influxdb3/cloud-dedicated/.config.yml' v2@2
177177
}
178178

179+
function updateCloudServerlessV2 {
180+
outFile="influxdb3/cloud-serverless/v2/ref.yml"
181+
if [[ -z "$baseUrl" ]];
182+
then
183+
echo "Using existing $outFile"
184+
else
185+
curl $UPDATE_OPTIONS ${baseUrl}/contracts/ref/cloud.yml -o $outFile
186+
fi
187+
postProcess $outFile 'influxdb3/cloud-serverless/.config.yml' v2@2
188+
}
189+
179190
function updateClusteredV2 {
180191
outFile="influxdb3/clustered/v2/ref.yml"
181192
if [[ -z "$baseUrl" ]];
@@ -187,15 +198,28 @@ function updateClusteredV2 {
187198
postProcess $outFile 'influxdb3/clustered/.config.yml' v2@2
188199
}
189200

190-
function updateCloudServerlessV2 {
191-
outFile="influxdb3/cloud-serverless/v2/ref.yml"
201+
function updateCoreV3 {
202+
outFile="influxdb3/core/v3/ref.yml"
192203
if [[ -z "$baseUrl" ]];
193204
then
194205
echo "Using existing $outFile"
195206
else
196-
curl $UPDATE_OPTIONS ${baseUrl}/contracts/ref/cloud.yml -o $outFile
207+
local url="${baseUrl}/TO_BE_DECIDED"
208+
curl $UPDATE_OPTIONS $url -o $outFile
197209
fi
198-
postProcess $outFile 'influxdb3/cloud-serverless/.config.yml' v2@2
210+
postProcess $outFile 'influxdb3/core/.config.yml' v3@3
211+
}
212+
213+
function updateEnterpriseV3 {
214+
outFile="influxdb3/enterprise/v3/ref.yml"
215+
if [[ -z "$baseUrl" ]];
216+
then
217+
echo "Using existing $outFile"
218+
else
219+
local url="${baseUrl}/TO_BE_DECIDED"
220+
curl $UPDATE_OPTIONS $url -o $outFile
221+
fi
222+
postProcess $outFile 'influxdb3/enterprise/.config.yml' v3@3
199223
}
200224

201225
function updateOSSV2 {
@@ -220,7 +244,7 @@ function updateV1Compat {
220244
postProcess $outFile 'influxdb/cloud/.config.yml' 'v1-compatibility'
221245

222246
outFile="influxdb/v2/v1-compatibility/swaggerV1Compat.yml"
223-
cp cloud/v1-compatibility/swaggerV1Compat.yml $outFile
247+
cp influxdb/cloud/v1-compatibility/swaggerV1Compat.yml $outFile
224248
postProcess $outFile 'influxdb/v2/.config.yml' 'v1-compatibility'
225249

226250
outFile="influxdb3/cloud-dedicated/v1-compatibility/swaggerV1Compat.yml"
@@ -257,6 +281,12 @@ then
257281
elif [ "$product" = "clustered-v2" ];
258282
then
259283
updateClusteredV2
284+
elif [ "$product" = "core-v3" ];
285+
then
286+
updateCoreV3
287+
elif [ "$product" = "enterprise-v3" ];
288+
then
289+
updateEnterpriseV3
260290
elif [ "$product" = "v2" ];
261291
then
262292
updateOSSV2
@@ -270,9 +300,11 @@ then
270300
updateCloudDedicatedManagement
271301
updateCloudServerlessV2
272302
updateClusteredV2
303+
updateCoreV3
304+
updateEnterpriseV3
273305
updateOSSV2
274306
updateV1Compat
275307
else
276-
echo "Provide a product argument: cloud-v2, cloud-serverless-v2, cloud-dedicated-v2, clustered-v2, v2, v1-compat, or all."
308+
echo "Provide a product argument: cloud-v2, cloud-serverless-v2, cloud-dedicated-v2, cloud-dedicated-management, clustered-v2, core-v3, enterprise-v3, v2, v1-compat, or all."
277309
showHelp
278310
fi
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
title: InfluxDB 3 Core API Service
2+
x-influxdata-short-title: InfluxDB 3 API
3+
x-influxdata-version-matrix:
4+
v1: Legacy compatibility layer
5+
v2: Backward compatibility with InfluxDB 2.x
6+
v3: Current native API
7+
summary: The InfluxDB HTTP API for InfluxDB 3 Core provides a programmatic interface for writing data stored in an InfluxDB 3 Core database.
8+
description: |
9+
Write and query data, and perform administrative tasks, such as managing databases and processing engine plugins.
10+
11+
The InfluxDB HTTP API for InfluxDB 3 Core includes endpoints for compatibility with InfluxDB 2.x and InfluxDB 1.x APIs.
12+
13+
<!-- TODO: verify where to host the spec that users can download.
14+
This documentation is generated from the
15+
[InfluxDB OpenAPI specification](https://raw.githubusercontent.com/influxdata/openapi/master/contracts/ref/cloud.yml).
16+
-->
17+
license:
18+
name: MIT
19+
url: 'https://opensource.org/licenses/MIT'
20+
contact:
21+
name: InfluxData
22+
url: https://www.influxdata.com
23+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- url: https://{baseurl}
2+
description: InfluxDB 3 Core API URL
3+
variables:
4+
baseurl:
5+
enum:
6+
- 'localhost:8181'
7+
default: 'localhost:8181'
8+
description: InfluxDB 3 Core URL

0 commit comments

Comments
 (0)