Closed Catherine-monk closed 1 month ago
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by:
To complete the pull request process, please assign fisherxu after the PR has been reviewed.
You can assign the PR to them by writing /assign @fisherxu
in a comment when ready.
The full list of commands accepted by this bot can be found here.
Introduction
Tool that supports automatically generating API documentation
Implementation Method
Generate OpenAPI definitions by using openapi-gen: The
openapi-gen
tool generates Go template code containing OpenAPI definitions from comment information. By adding a specific annotation+k8s:openapigen=true
in thedoc.go
file,openapi-gen
will scan all types in the package to generate OpenAPI definitions, which are stored in thezz_generated.openapi.go
file.Generate OpenAPI Specification: Write
generate-swagger.go
referencing the generated OpenAPI definitions (zz_generated.openapi.go
) to create the OpenAPI specification (swagger.json
). Theswagger.json
file contains all the OpenAPI definition information of the apiserver.Contents of
generateswagger.go
include:Usage
First, run
./apidoc/tools/generate-openapi.sh
to generate the OpenAPI definitions, then execute./apidoc/tools/update-swagger-docs.sh
to generate the OpenAPI specification.