feat: add swagger annotations for open API router #3885
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
@BasePath
incmd/manager/main.go
from/api/v1
to/
@tag.name
and@tag.description
annotations to describe the two API route groups@Router
annotations in handler files to use absolute paths instead of relative paths/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:

After:

Types of changes
Checklist