Skip to content
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 for KubeEdge #5582

Closed
wants to merge 5 commits into from

Conversation

greensong
Copy link

1. Generate OpenAPI Definitions with openapi-gen:
Use the openapi-gen tool to generate Go template code containing OpenAPI definitions based on annotation information. By adding a specific annotation +k8s:openapigen=true in the doc.go file, openapi-gen scans all types under that package and generates OpenAPI definitions for them, stored in the zz_generated.openapi.go file.

2. Generate OpenAPI Specification:
Write generateswagger.go to reference the generated OpenAPI definitions (zz_generated.openapi.go) and generate the OpenAPI specification (swagger.json). The swagger.json file contains all the OpenAPI definition information for the API server.

The contents of generateswagger.go are as follows:

  • Create Schema objects for type registration and object instantiation.
  • Create a REST Mapper Mapper for conversion between GVR (GroupVersionResource) and GVK (GroupVersionKind).
  • Add specific mappings for various KubeEdge resources.
  • Set information for the OpenAPI specification.

The specific process is as follows:

  • Run “go run auto_generate_openapi.go” to call the openapi-gen tool and generate OpenAPI definitions.
  • After generating the OpenAPI definitions, run “go run generateswagger.go” to create the OpenAPI specification.

‘greensong’ added 5 commits April 29, 2024 01:27
Signed-off-by: ‘greensong’ <‘15079795005@163.com’>
Signed-off-by: ‘greensong’ <‘15079795005@163.com’>
Signed-off-by: ‘greensong’ <‘15079795005@163.com’>
Signed-off-by: ‘greensong’ <‘15079795005@163.com’>
Signed-off-by: ‘greensong’ <‘15079795005@163.com’>
@kubeedge-bot
Copy link
Collaborator

[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.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 28, 2024
@WillardHu
Copy link
Collaborator

WillardHu commented Apr 29, 2024

Thank you for your contribution, you need to pass the DCO check first.
Refer https://github.com/kubeedge/kubeedge/pull/5582/checks?check_run_id=24349847302

"k8s.io/kube-openapi/pkg/validation/spec"
)

func main() {
Copy link
Collaborator

@WillardHu WillardHu Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These source codes of a openapi generation tool that does not fit in the hack/ directory, is there a better choice?

"strings"
)

func main() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a shell script would be more appropriate then the gofile for execute openapi-gen command. BTW, we can use the compiled binary openapi-gen.

@greensong greensong closed this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants