The openapi-extractor
extracts the OpenAPI v2 and v3 specifications of a given Kubernetes API server.
To install the openapi-extractor
binary into your Go bin path run
go install github.com/ironcore-dev/openapi-extractor/cmd/openapi-extractor@main
In case you have the api server binary present, you can extract the OpenAPI specifications by running
openapi-extractor --apiserver-command=<PATH-TO-APISERVER-BIN> \
--apiservices=<PATH-TO-APISERVICES-DIR>
The sample
folder contains an example on how to extract the Open API spec from an api server package. In
our example we are using the ironcore
aggregated api server.
openapi-extractor --apiserver-package=github.com/ironcore-dev/ironcore/cmd/ironcore-apiserver \
--apiserver-build-opts=mod \
--apiservices=<PATH-TO-APISERVICES-DIR>
In case you want to use your own package, first go get
it so you have to correct dependencies in your go.mod
file and
adjust the --apiserver-package
flag accordingly.
The extracted OpenAPI v2 and v3 files can be found in current folder where the v2 version will be stored in the swagger.json
file and the v3 versions will be stored in individual files per group in the ./v3
folder.
To override the location of the output pass on the --output
flag e.g. via --output=dev
store extract the files into
the ./dev
folder.
We'd love to get feedback from you. Please report bugs, suggestions or post questions by opening a GitHub issue.
Copyright 2022.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.