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

feat: update API requests with OpenAPI generated client #2926

Merged
merged 56 commits into from Jul 8, 2022

Conversation

g1eny0ung
Copy link
Member

@g1eny0ung g1eny0ung commented Feb 22, 2022

What problem does this PR solve?

Close #3386

What's changed and how it works?

Proposal: rfc: OpenAPI to TypeScript API Client and Forms

This PR updates nearly all API requests (Some with strong dependency bindings are ignored and will solve next time) with the OpenAPI generated client. Note that this PR must be merged after #2770 because it's based on it.

The overall update process is as follows:

  1. Upgrade swag to the latest version to meet some needs (fast generation).
  2. Run ./hack/generate_swagger_spec.sh in your local to generate swagger files.
  3. Then run yarn workspace @ui/openapi codegen client to update the client.
  4. Finally, the API requests are updated one by one according to the type inference of TypeScript.

Related changes

  • Need to update chaos-mesh/website
  • Need to update Dashboard UI
  • Need to cheery-pick to release branches
    • release-2.1
    • release-2.0

Checklist

Tests

  • Unit test
  • E2E test
  • No code
  • Manual test (add steps below)

Side effects

  • Breaking backward compatibility

DCO

If you find the DCO check fails, please run commands like below (Depends on the actual situations. For example, if the failed commit isn't the most recent) to fix it:

git commit --amend --signoff
git push --force

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@STRRL
Copy link
Member

STRRL commented Apr 25, 2022

Hi @g1eny0ung , I tried to resolve the conflict by regenerating the swagger.yaml.

But it seems swag failed to parse import alias with u "github.com/chaos-mesh/chaos-mesh/pkg/dashboard/apiserver/utils":

2022/04/25 07:09:07 ParseComment error in file pkg/dashboard/apiserver/template/template.go :can not find schema type: "u.APIError"

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@codecov
Copy link

codecov bot commented Jun 17, 2022

Codecov Report

Merging #2926 (53677ca) into master (9522623) will decrease coverage by 0.07%.
The diff coverage is 64.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2926      +/-   ##
==========================================
- Coverage   40.90%   40.82%   -0.08%     
==========================================
  Files         166      166              
  Lines       13985    13985              
==========================================
- Hits         5721     5710      -11     
- Misses       7835     7847      +12     
+ Partials      429      428       -1     
Impacted Files Coverage Δ
pkg/dashboard/apiserver/event/event.go 19.63% <ø> (ø)
pkg/dashboard/apiserver/archive/archive.go 31.93% <64.28%> (ø)
.../workflow/controllers/workflow_entry_reconciler.go 49.18% <0.00%> (-7.03%) ⬇️
pkg/workflow/controllers/chaos_node_reconciler.go 58.16% <0.00%> (-3.16%) ⬇️
pkg/workflow/controllers/task_reconciler.go 6.70% <0.00%> (+0.80%) ⬆️
pkg/workflow/controllers/serial_node_reconciler.go 61.13% <0.00%> (+1.55%) ⬆️
...g/workflow/controllers/parallel_node_reconciler.go 62.02% <0.00%> (+1.89%) ⬆️
pkg/workflow/controllers/deadline_reconciler.go 69.62% <0.00%> (+2.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9522623...53677ca. Read the comment docs.

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@g1eny0ung g1eny0ung requested review from iguoyr and STRRL June 22, 2022 06:31
@g1eny0ung
Copy link
Member Author

Note: To solve #3386, I move all inline types in every sub-package under apiserver into the sub package types. This can prevent swag generate the type name automatically.

@g1eny0ung
Copy link
Member Author

Hi @g1eny0ung , I tried to resolve the conflict by regenerating the swagger.yaml.

But it seems swag failed to parse import alias with u "github.com/chaos-mesh/chaos-mesh/pkg/dashboard/apiserver/utils":

2022/04/25 07:09:07 ParseComment error in file pkg/dashboard/apiserver/template/template.go :can not find schema type: "u.APIError"

@STRRL 😵 Sorry I missed this comment. It works now.

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@g1eny0ung g1eny0ung merged commit 046961d into chaos-mesh:master Jul 8, 2022
@g1eny0ung g1eny0ung deleted the feat/update-api branch July 8, 2022 10:37
STRRL pushed a commit to Garima-Negi/chaos-mesh that referenced this pull request Sep 13, 2022
)

* feat: OpenAPI to TypeScript API Client and Forms

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: license checker

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: go (verify)

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: add comments

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: reuse kubebuilder marks

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update according to RFC

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: prevent ui:form appearing in crds

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: add missing actions

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update lockfile

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: support PhysicalMachineChaos

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: merge commands into codegen

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: license checker

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: ci

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: supplement another ignore check

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update package info

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update README

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: gen HTTPChaos

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update changelog

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: remove nested ignores

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: remove remaining markers

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: typo

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: supplement comments

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* feat: update API requests with OpenAPI generated

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: ci

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: swag

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: upgrade swag to v1.8.3

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: update CHANGELOG

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: update dev-env

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: update swag init

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* test: transform auto-bind

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: pass the right params

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: follow the revive suggestion

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: go mod

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: chaos-mesh#3386

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* chore: go mod tidy

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix(ci): make tidy

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: STRRL <im@strrl.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/dashboard component/ui rebuild-build-env-image rebuild build-env image in this PR rebuild-dev-env-image rebuild dev-env image in this PR size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dashboard(apiserver): swag generates random definitions in different builds
4 participants