-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool that supports automatically generating API documentation #5615
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please using make verify
to update the vendor/LICENSES/crds...
1 execute make verify
2 push the modified file
friendly remind : ) |
--input-dirs "k8s.io/apiextensions-apiserver/pkg/apis" \ | ||
--input-dirs "k8s.io/kubernetes/pkg/apis" \ | ||
--input-dirs "k8s.io/apimachinery/pkg/version" \ | ||
--input-dirs "k8s.io/apimachinery/pkg/api/resource" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to generate k8s API
"k8s.io/client-go/kubernetes/scheme" | ||
"k8s.io/klog/v2" | ||
"k8s.io/kube-openapi/pkg/common" | ||
"k8s.io/kube-openapi/pkg/validation/spec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort the import
apidoc/tools/generate-swagger.go
Outdated
}, | ||
Resources: []lib.ResourceWithNamespaceScoped{ | ||
// Define resources and their namespace scoped and resource mapping correspondingly | ||
{GVR: appsv1alpha1.SchemeGroupVersion.WithResource("edgeapplications"), NamespaceScoped: false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edgeapplications namespaceScope should not be false. And other apis should also be checked.
mkdir "$folder_name" | ||
fi | ||
|
||
go run ${KUBEEDGE_ROOT}/apidoc/tools/generate-swagger.go > ${KUBEEDGE_ROOT}/apidoc/generated/swagger/swagger.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why swagger.json in this PR is empty?
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.6.2 | ||
creationTimestamp: null | ||
controller-gen.kubebuilder.io/version: v0.14.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we must upgrade controller-gen tool in this PR? If not, remove it, If so, we need another separate PR to upgrade controller-gen.
hack/generate-crds.sh
Outdated
@@ -136,4 +136,4 @@ function cleanup { | |||
|
|||
:copy:to:destination | |||
|
|||
cleanup | |||
#cleanup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this #
@@ -28,7 +28,6 @@ import ( | |||
|
|||
type DevicesV1beta1Interface interface { | |||
RESTClient() rest.Interface | |||
DevicesGetter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove DeviceGetter?
@@ -24,8 +24,6 @@ import ( | |||
|
|||
// Interface provides access to all the informers in this group version. | |||
type Interface interface { | |||
// Devices returns a DeviceInformer. | |||
Devices() DeviceInformer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove Device Interface?
if ! test -f "${GOFILE}" ; then | ||
echo "Error: Go file not found." && exit 1 | ||
fi | ||
OUTPUT_FILE="${KUBEEDGE_ROOT}/vendor/k8s.io/kube-openapi/cmd/openapi-gen" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using go install k8s.io/kube-openapi/cmd/openapi-gen
Signed-off-by: guolinsheng <15079795005@163.com>
Signed-off-by: guolinsheng <15079795005@163.com>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: guolinsheng <15079795005@163.com>
Signed-off-by: guolinsheng <15079795005@163.com>
Introduction
Tool that supports automatically generating API documentation.
Implementation Method
Generate OpenAPI definitions 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.