Skip to content

Commit b3bb9c4

Browse files
committed
feat(api): InfluxDB3 Core API reference, API fixes, and e2e tests
- Adds InfluxDB 3 Core API reference - Updates scripts - Removes non-valid info.summary field from specs, replaces with description in metadata - Simplifies frontmatter generation for HTML template - Reorg of file structure to mirror the content structure. - Moves OSS v2 into v2/v2/ref.yml to follow the same pattern as others - Replaces isDefault API config field with specific aliases. - Misc. fixes. - Remove generated HTML files.
1 parent 846d3a9 commit b3bb9c4

File tree

39 files changed

+424
-11351
lines changed

39 files changed

+424
-11351
lines changed

.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

api-docs/generate-api-docs.sh

Lines changed: 31 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function generateHtml {
4141
local productName="$3"
4242
local api="$4"
4343
local configPath="$5"
44-
local isDefault=$6
4544

4645
# Use the product name to define the menu for the Hugo template
4746
local menu="$(echo $productVersion | sed 's/\./_/g;s/-/_/g;s/\//_/g;')"
@@ -55,12 +54,25 @@ function generateHtml {
5554
# Use the title and summary defined in the product API's info.yml file.
5655
local title=$(yq '.title' $productVersion/$apiName/content/info.yml)
5756
local menuTitle=$(yq '.x-influxdata-short-title' $productVersion/$apiName/content/info.yml)
58-
local description=$(yq '.summary' $productVersion/$apiName/content/info.yml)
57+
# Get the first paragraph of the description for the meta description.
58+
59+
# Get the description with whitespace and newlines preserved.
60+
local description=$(yq e -r '.description // ""' $productVersion/$apiName/content/info.yml | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g')
61+
# Get the aliases array from the configuration file.
62+
local aliases=$(yq e ".apis | .$api | .x-influxdata-docs-aliases" "$configPath")
63+
# If aliases is null, set it to an empty YAML array.
64+
if [[ "$aliases" == "null" ]]; then
65+
aliases='[]'
66+
fi
67+
local weight=102
68+
if [[ $apiName == "v1-compatibility" ]]; then
69+
weight=304
70+
fi
5971
# Define the file name for the Redoc HTML output.
6072
local specbundle=redoc-static_index.html
6173
# Define the temporary file for the Hugo template and Redoc HTML.
6274
local tmpfile="${productVersion}-${api}_index.tmp"
63-
75+
6476
echo "Bundling $specPath"
6577

6678
# Use npx to install and run the specified version of redoc-cli.
@@ -77,68 +89,24 @@ function generateHtml {
7789
--options.hideHostname \
7890
--options.noAutoAuth \
7991
--output=$specbundle \
80-
--templateOptions.description=$description \
92+
--templateOptions.description= $(echo "$description" | sed 's/\n//g') \
8193
--templateOptions.product="$productVersion" \
8294
--templateOptions.productName="$productName"
8395

84-
if [[ $apiName == "v1-compatibility" ]]; then
85-
frontmatter="---
86-
title: $title
87-
description: $description
88-
layout: api
89-
menu:
90-
$menu:
91-
parent: InfluxDB HTTP API
92-
name: $menuTitle
93-
identifier: api-reference-$apiName
94-
weight: 304
95-
aliases:
96-
- /influxdb/$versionDir/api/v1/
97-
---
98-
"
99-
elif [[ $apiVersion == "0" ]]; then
100-
echo $productName $apiName
101-
frontmatter="---
102-
title: $title
103-
description: $description
104-
layout: api
105-
weight: 102
106-
menu:
107-
$menu:
108-
parent: InfluxDB HTTP API
109-
name: $menuTitle
110-
identifier: api-reference-$apiName
96+
local frontmatter=$(yq eval -n \
97+
".title = \"$title\" |
98+
.description = \"$description\" |
99+
.layout = \"api\" |
100+
.weight = $weight |
101+
.menu.[\"$menu\"].parent = \"InfluxDB HTTP API\" |
102+
.menu.[\"$menu\"].name = \"$menuTitle\" |
103+
.menu.[\"$menu\"].identifier = \"api-reference-$apiName\" |
104+
.aliases = \"$aliases\"")
105+
106+
frontmatter="---
107+
$frontmatter
111108
---
112109
"
113-
elif [[ $isDefault == true ]]; then
114-
frontmatter="---
115-
title: $title
116-
description: $description
117-
layout: api
118-
menu:
119-
$menu:
120-
parent: InfluxDB HTTP API
121-
name: $menuTitle
122-
identifier: api-reference-$apiName
123-
weight: 102
124-
aliases:
125-
- /influxdb/$versionDir/api/
126-
---
127-
"
128-
else
129-
frontmatter="---
130-
title: $title
131-
description: $description
132-
layout: api
133-
menu:
134-
$menu:
135-
parent: InfluxDB HTTP API
136-
name: $menuTitle
137-
identifier: api-reference-$apiName
138-
weight: 102
139-
---
140-
"
141-
fi
142110

143111
# Create the Hugo template file with the frontmatter and Redoc HTML
144112
echo "$frontmatter" >> $tmpfile
@@ -199,13 +167,7 @@ function build {
199167
if [ -d "$specPath" ] || [ ! -f "$specPath" ]; then
200168
echo "OpenAPI spec $specPath doesn't exist."
201169
fi
202-
# Get default status from the configuration.
203-
local isDefault=false
204-
local defaultStatus
205-
defaultStatus=$(yq e ".apis | .$api | .x-influxdata-default" "$configPath")
206-
if [[ $defaultStatus == "true" ]]; then
207-
isDefault=true
208-
fi
170+
209171

210172
# If the spec file differs from master, regenerate the HTML.
211173
local update=0
@@ -219,9 +181,9 @@ function build {
219181

220182
if [[ $update -eq 0 ]]; then
221183
echo "Regenerating $version $api"
222-
generateHtml "$specPath" "$version" "$versionName" "$api" "$configPath" "$isDefault"
184+
generateHtml "$specPath" "$version" "$versionName" "$api" "$configPath"
223185
fi
224-
echo "========Done with $version $api========"
186+
echo -e "========Finished $version $api========\n\n"
225187
done <<< "$apis"
226188
done
227189
}

api-docs/getswagger.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ function updateEnterpriseV3 {
223223
}
224224

225225
function updateOSSV2 {
226-
outFile="influxdb/v2/ref.yml"
226+
outFile="influxdb/v2/v2/ref.yml"
227227
if [[ -z "$baseUrlOSS" ]];
228228
then
229229
echo "Using existing $outFile"
230230
else
231231
curl $UPDATE_OPTIONS ${baseUrlOSS}/contracts/ref/oss.yml -o $outFile
232232
fi
233-
postProcess $outFile 'influxdb/v2/.config.yml' '@2'
233+
postProcess $outFile 'influxdb/v2/.config.yml' 'v2@2'
234234
}
235235

236236
function updateV1Compat {

api-docs/influxdb/cloud/.config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ x-influxdata-product-name: InfluxDB v2 Cloud
88
apis:
99
v2@2:
1010
root: v2/ref.yml
11-
x-influxdata-default: true
11+
x-influxdata-docs-aliases:
12+
- /influxdb/cloud/api/
1213
v1-compatibility@2:
1314
root: v1-compatibility/swaggerV1Compat.yml
15+
x-influxdata-docs-aliases:
16+
- /influxdb/cloud/api/v1/

api-docs/influxdb/cloud/v2/ref.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12212,7 +12212,7 @@ paths:
1221212212
type: string
1221312213
- description: |
1221412214
A unix timestamp precision.
12215-
Formats timestamps as [unix (epoch) timestamps](/influxdb/cloud/reference/glossary/#unix-timestamp) the specified precision
12215+
Formats timestamps as [unix (epoch) timestamps](/influxdb/cloud/reference/glossary/#unix-timestamp) with the specified precision
1221612216
instead of [RFC3339 timestamps](/influxdb/cloud/reference/glossary/#rfc3339-timestamp) with nanosecond precision.
1221712217
in: query
1221812218
name: epoch

api-docs/influxdb/v2/.config.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ extends:
66
x-influxdata-product-name: InfluxDB v2 OSS
77

88
apis:
9-
'@2':
10-
root: ref.yml
11-
x-influxdata-default: true
9+
v2@2:
10+
root: v2/ref.yml
11+
x-influxdata-docs-aliases:
12+
- /influxdb/v2/api/
1213
v1-compatibility@2:
1314
root: v1-compatibility/swaggerV1Compat.yml
15+
x-influxdata-docs-aliases:
16+
- /influxdb/v2/api/v1/

api-docs/influxdb/v2/content/info.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

api-docs/influxdb/v2/v1-compatibility/swaggerV1Compat.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -467,19 +467,3 @@ components:
467467
468468
469469
For examples and more information, see how to [authenticate with a username and password](/influxdb/cloud/reference/api/influxdb-1x/).
470-
x-tagGroups:
471-
- name: Using the InfluxDB HTTP API
472-
tags:
473-
- Quick start
474-
- Authentication
475-
- Supported operations
476-
- Headers
477-
- Pagination
478-
- Response codes
479-
- Data I/O endpoints
480-
- Security and access endpoints
481-
- System information endpoints
482-
- name: All endpoints
483-
tags:
484-
- Query
485-
- Write
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
title: InfluxDB OSS API Service
2+
x-influxdata-short-title: v2 API
3+
description: |
4+
The InfluxDB v2 HTTP API provides a programmatic interface for all interactions with an InfluxDB v2 instance.
5+
6+
The InfluxDB v2 HTTP API provides a programmatic interface for all interactions with an InfluxDB v2 instance. Access the InfluxDB API using `/api/v2/` and InfluxDB v1-compatible endpoints.
7+
8+
This documentation is generated from the
9+
[InfluxDB OpenAPI specification](https://github.com/influxdata/openapi/blob/influxdb-oss-v2.7.0/contracts/ref/oss.yml).
10+
version: 2.x
11+
license:
12+
name: MIT
13+
url: 'https://opensource.org/licenses/MIT'
14+
contact:
15+
name: InfluxData
16+
url: https://www.influxdata.com
17+

0 commit comments

Comments
 (0)