21
21
# sh ./getswagger.sh -c <product> -o <version> -B
22
22
#
23
23
# Examples:
24
- # sh ./getswagger.sh cloud-serverless
24
+ # sh ./getswagger.sh cloud-serverless-v2
25
25
# sh ./getswagger.sh clustered -B
26
- # sh ./getswagger.sh cloud
27
- # sh ./getswagger.sh -c v2 -o v2.0 -b file:///Users/johnsmith/github/openapi
26
+ # sh ./getswagger.sh cloud-v2
27
+ # sh ./getswagger.sh -c oss-v2 -b file:///Users/johnsmith/github/openapi
28
+
29
+ DOCS_ROOT=$( git rev-parse --show-toplevel)
30
+ API_DOCS_ROOT=$DOCS_ROOT /api-docs
28
31
29
32
versionDirs=($( ls -d * /) )
30
33
latestOSS=${versionDirs[${#versionDirs[@]} -1]}
@@ -62,7 +65,7 @@ function showHelp {
62
65
subcommand=$1
63
66
64
67
case " $subcommand " in
65
- cloud-dedicated-v2|cloud-dedicated-management|cloud-serverless-v2|clustered-v2|cloud-v2|v2|v1-compat|all)
68
+ cloud-dedicated-v2|cloud-dedicated-management|cloud-serverless-v2|clustered-v2|cloud-v2|oss-v2| v2|v1-compat|all)
66
69
product=$1
67
70
shift
68
71
@@ -117,7 +120,6 @@ function postProcess() {
117
120
api=" $3 "
118
121
119
122
openapiCLI=" @redocly/cli"
120
- currentPath=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
121
123
122
124
# TODO: Move some of this into the plugin:
123
125
@@ -131,101 +133,112 @@ function postProcess() {
131
133
npx --version
132
134
INFLUXDB_PRODUCT=$( dirname " $configPath " ) \
133
135
INFLUXDB_API_NAME=$( echo " $api " | sed ' s/@.*//g;' ) \
134
- API_DOCS_ROOT_PATH=$currentPath \
136
+ API_DOCS_ROOT_PATH=$API_DOCS_ROOT \
135
137
npm_config_yes=true \
136
138
npx $openapiCLI bundle $specPath \
137
139
-o $specPath \
138
140
--config=$configPath
139
141
}
140
142
141
- function updateCloudV2 {
142
- outFile=" cloud/v2/ref.yml"
143
+ function updateOSS {
144
+ outFile=" $API_DOCS_ROOT /v2/ref.yml"
145
+ if [[ -z " $baseUrlOSS " ]];
146
+ then
147
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
148
+ else
149
+ curl $UPDATE_OPTIONS ${baseUrlOSS} /contracts/ref/oss.yml -o $outFile
150
+ fi
151
+ postProcess $outFile " $API_DOCS_ROOT /v2/.config.yml" ' @2'
152
+ }
153
+
154
+ function updateCloudV2 {
155
+ outFile=" $API_DOCS_ROOT /cloud/v2/ref.yml"
143
156
if [[ -z " $baseUrl " ]];
144
157
then
145
- echo " Using existing $outFile "
158
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
146
159
else
147
160
curl $UPDATE_OPTIONS ${baseUrl} /contracts/ref/cloud.yml -o $outFile
148
161
fi
149
- postProcess $outFile ' cloud/.config.yml' v2@2
162
+ postProcess $outFile " $API_DOCS_ROOT / cloud/.config.yml" v2@2
150
163
}
151
164
152
165
function updateCloudDedicatedManagement {
153
- outFile=" cloud-dedicated/management/openapi.yml"
166
+ outFile=" $API_DOCS_ROOT / cloud-dedicated/management/openapi.yml"
154
167
if [[ -z " $baseUrl " ]];
155
168
then
156
- echo " Using existing $outFile "
169
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
157
170
else
158
171
curl $UPDATE_OPTIONS https://raw.githubusercontent.com/influxdata/granite/ab7ee2aceacfae7f415d15ffbcf8c9d0f6f3e015/openapi.yaml -o $outFile
159
172
fi
160
- postProcess $outFile ' cloud-dedicated/.config.yml' management@0
173
+ postProcess $outFile " $API_DOCS_ROOT / cloud-dedicated/.config.yml" management@0
161
174
}
162
175
163
176
function updateCloudDedicatedV2 {
164
- outFile=" cloud-dedicated/v2/ref.yml"
177
+ outFile=" $API_DOCS_ROOT / cloud-dedicated/v2/ref.yml"
165
178
if [[ -z " $baseUrl " ]];
166
179
then
167
- echo " Using existing $outFile "
180
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
168
181
else
169
182
curl $UPDATE_OPTIONS ${baseUrl} /contracts/ref/cloud.yml -o $outFile
170
183
fi
171
- postProcess $outFile ' cloud-dedicated/.config.yml' v2@2
184
+ postProcess $outFile " $API_DOCS_ROOT / cloud-dedicated/.config.yml" v2@2
172
185
}
173
186
174
187
function updateClusteredV2 {
175
- outFile=" clustered/v2/ref.yml"
188
+ outFile=" $API_DOCS_ROOT / clustered/v2/ref.yml"
176
189
if [[ -z " $baseUrl " ]];
177
190
then
178
- echo " Using existing $outFile "
191
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
179
192
else
180
193
curl $UPDATE_OPTIONS ${baseUrl} /contracts/ref/cloud.yml -o $outFile
181
194
fi
182
- postProcess $outFile ' clustered/.config.yml' v2@2
195
+ postProcess $outFile " $API_DOCS_ROOT / clustered/.config.yml" v2@2
183
196
}
184
197
185
198
function updateCloudServerlessV2 {
186
- outFile=" cloud-serverless/v2/ref.yml"
199
+ outFile=" $API_DOCS_ROOT / cloud-serverless/v2/ref.yml"
187
200
if [[ -z " $baseUrl " ]];
188
201
then
189
- echo " Using existing $outFile "
202
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
190
203
else
191
204
curl $UPDATE_OPTIONS ${baseUrl} /contracts/ref/cloud.yml -o $outFile
192
205
fi
193
- postProcess $outFile ' cloud-serverless/.config.yml' v2@2
206
+ postProcess $outFile " $API_DOCS_ROOT / cloud-serverless/.config.yml" v2@2
194
207
}
195
208
196
209
function updateOSSV2 {
197
- outFile=" v2/ref.yml"
210
+ outFile=" $API_DOCS_ROOT / v2/ref.yml"
198
211
if [[ -z " $baseUrlOSS " ]];
199
212
then
200
- echo " Using existing $outFile "
213
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
201
214
else
202
215
curl $UPDATE_OPTIONS ${baseUrlOSS} /contracts/ref/oss.yml -o $outFile
203
216
fi
204
- postProcess $outFile ' v2/.config.yml' ' @2'
217
+ postProcess $outFile " $API_DOCS_ROOT / v2/.config.yml" ' @2'
205
218
}
206
219
207
- function updateV1Compat {
208
- outFile=" cloud/v1-compatibility/swaggerV1Compat.yml"
220
+ function updateV1Compat {
221
+ outFile=" $API_DOCS_ROOT / cloud/v1-compatibility/swaggerV1Compat.yml"
209
222
if [[ -z " $baseUrl " ]];
210
223
then
211
- echo " Using existing $outFile "
224
+ echo " No URL was provided. I'll rebuild from the existing spec $outFile "
212
225
else
213
226
curl $UPDATE_OPTIONS ${baseUrl} /contracts/swaggerV1Compat.yml -o $outFile
214
227
fi
215
- postProcess $outFile ' cloud/.config.yml' ' v1-compatibility'
228
+ postProcess $outFile " $API_DOCS_ROOT / cloud/.config.yml" ' v1-compatibility'
216
229
217
- outFile=" v2/v1-compatibility/swaggerV1Compat.yml"
230
+ outFile=" $API_DOCS_ROOT / v2/v1-compatibility/swaggerV1Compat.yml"
218
231
cp cloud/v1-compatibility/swaggerV1Compat.yml $outFile
219
- postProcess $outFile ' v2/.config.yml' ' v1-compatibility'
232
+ postProcess $outFile " $API_DOCS_ROOT / v2/.config.yml" ' v1-compatibility'
220
233
221
- outFile=" cloud-dedicated/v1-compatibility/swaggerV1Compat.yml"
222
- postProcess $outFile ' cloud-dedicated/.config.yml' ' v1-compatibility'
234
+ outFile=" $API_DOCS_ROOT / cloud-dedicated/v1-compatibility/swaggerV1Compat.yml"
235
+ postProcess $outFile " $API_DOCS_ROOT / cloud-dedicated/.config.yml" ' v1-compatibility'
223
236
224
- outFile=" cloud-serverless/v1-compatibility/swaggerV1Compat.yml"
225
- postProcess $outFile ' cloud-serverless/.config.yml' ' v1-compatibility'
237
+ outFile=" $API_DOCS_ROOT / cloud-serverless/v1-compatibility/swaggerV1Compat.yml"
238
+ postProcess $outFile " $API_DOCS_ROOT / cloud-serverless/.config.yml" ' v1-compatibility'
226
239
227
- outFile=" clustered/v1-compatibility/swaggerV1Compat.yml"
228
- postProcess $outFile ' clustered/.config.yml' ' v1-compatibility'
240
+ outFile=" $API_DOCS_ROOT / clustered/v1-compatibility/swaggerV1Compat.yml"
241
+ postProcess $outFile " $API_DOCS_ROOT / clustered/.config.yml" ' v1-compatibility'
229
242
}
230
243
231
244
UPDATE_OPTIONS=" --fail"
252
265
elif [ " $product " = " clustered-v2" ];
253
266
then
254
267
updateClusteredV2
268
+ elif [ " $product " = " oss-v2" ];
269
+ then
270
+ updateOSSV2
255
271
elif [ " $product " = " v2" ];
256
272
then
257
273
updateOSSV2
0 commit comments