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: add swagger annotations for open API router #3885

Merged
merged 1 commit into from
Mar 13, 2025

Conversation

BruceAko
Copy link
Member

Update swagger annotations to support multiple API route groups.

Description

This PR fixes an issue in Swagger documentation generation where the Swagger annotation incorrectly defined the BasePath as /api/v1, while in reality the Dragonfly Manager service provides two sets of API routes: /api/v1 and /oapi/v1.

Specifically, the changes include:

  1. Changed the @BasePath in cmd/manager/main.go from /api/v1 to /
  2. Added @tag.name and @tag.description annotations to describe the two API route groups
  3. Modified the @Router annotations in handler files to use absolute paths instead of relative paths
  4. Added dual route path annotations for handlers used in both /api/v1 and /oapi/v1 route groups (such as job and cluster handlers)

Related Issue

close #3884

Motivation and Context

The previous Swagger configuration only reflected APIs under the /api/v1 route, causing APIs under the /oapi/v1 route to be either invisible or incorrectly pathed in the Swagger documentation. This change ensures that the Swagger documentation properly displays all API endpoints of the Dragonfly Manager.

This is important for API users and developers as they need complete and accurate API documentation to use Dragonfly's APIs correctly. This change improves the completeness and accuracy of the documentation, making it easier for API consumers to understand and utilize all available functionality in Dragonfly.

Screenshots

Before:
af359355f4d28f27d015ee8d9be2b700

After:
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@BruceAko BruceAko requested a review from a team as a code owner March 13, 2025 01:28
Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: BruceAko <chongzhi@hust.edu.cn>
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.08%. Comparing base (5eec091) to head (328f19a).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3885      +/-   ##
==========================================
- Coverage   35.08%   35.08%   -0.01%     
==========================================
  Files         337      337              
  Lines       39273    39273              
==========================================
- Hits        13780    13777       -3     
- Misses      24591    24594       +3     
  Partials      902      902              
Flag Coverage Δ
unittests 35.08% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
api/manager/docs.go 0.00% <ø> (ø)
cmd/manager/main.go 0.00% <ø> (ø)
manager/handlers/application.go 69.69% <ø> (ø)
manager/handlers/bucket.go 41.46% <ø> (ø)
manager/handlers/cluster.go 69.69% <ø> (ø)
manager/handlers/config.go 69.69% <ø> (ø)
manager/handlers/job.go 50.42% <ø> (ø)
manager/handlers/oauth.go 69.69% <ø> (ø)
manager/handlers/peer.go 67.34% <ø> (ø)
manager/handlers/permission.go 100.00% <ø> (ø)
... and 8 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gaius-qi gaius-qi merged commit a700f5e into dragonflyoss:main Mar 13, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Swagger annotations to support open API router
2 participants