Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,42 @@ gen_repo_fields:
docker_gen_swag:
$(DOCKER) run -v $(shell pwd):/universe --rm $(DMS_GO_COMPILER_IMAGE) sh -c "cd /universe &&make gen_swag"

gen_swag:
gen_swag: check_swag_version
./internal/apiserver/cmd/swag/swagger_${HOST_OS}_${HOST_ARCH} generate spec -m -w ./internal/apiserver/cmd/server/ -o ./api/swagger.yaml
./internal/apiserver/cmd/swag/swagger_${HOST_OS}_${HOST_ARCH} generate spec -i ./api/swagger.yaml -o ./api/swagger.json

check_swag_version:
@SWAG_BIN=./internal/apiserver/cmd/swag/swagger_${HOST_OS}_${HOST_ARCH}; \
SWAG_VER=$$($$SWAG_BIN version | grep 'version:' | awk '{print $$2}'); \
MATCHING_GO_VER="unknown"; \
MAPPINGS="v0.33.1:1.24.0 v0.31.0:1.22 v0.30.4:1.19 v0.29.0:1.18"; \
for m in $$MAPPINGS; do \
v=$${m%%:*}; g=$${m#*:}; \
if [ "$$v" = "$$SWAG_VER" ]; then MATCHING_GO_VER="$$g"; break; fi; \
done; \
if [ "$$MATCHING_GO_VER" = "unknown" ]; then \
echo "Fetching Go version for $$SWAG_VER from GitHub..."; \
MATCHING_GO_VER=$$(curl -sL --connect-timeout 2 https://raw.githubusercontent.com/go-swagger/go-swagger/$$SWAG_VER/go.mod | grep "^go " | awk '{print $$2}' 2>/dev/null); \
if [ -z "$$MATCHING_GO_VER" ]; then MATCHING_GO_VER="unknown"; fi; \
fi; \
PROJECT_GO_VER=$$(grep "^go " go.mod | awk '{print $$2}'); \
SYSTEM_GO_VER=$$(go version | awk '{print $$3}' | sed 's/go//'); \
echo "Project go.mod Version: $$PROJECT_GO_VER"; \
echo "Swagger Version: $$SWAG_VER (Expected Go: $$MATCHING_GO_VER)"; \
echo "System Go Version: $$SYSTEM_GO_VER"; \
if [ "$$MATCHING_GO_VER" != "unknown" ]; then \
PROJECT_GO_MAJOR=$$(echo $$PROJECT_GO_VER | cut -d. -f1,2); \
MATCH_GO_VER_MAJOR=$$(echo $$MATCHING_GO_VER | cut -d. -f1,2); \
SYSTEM_GO_MAJOR=$$(echo $$SYSTEM_GO_VER | cut -d. -f1,2); \
if [ "$$PROJECT_GO_MAJOR" != "$$MATCH_GO_VER_MAJOR" ]; then \
echo "Warning: Current Swagger generator ($$SWAG_VER, Go $$MATCHING_GO_VER) does not match project's go.mod ($$PROJECT_GO_VER)."; \
echo "Please update the Swagger generator to match the project Go version."; \
fi; \
if [ "$$PROJECT_GO_MAJOR" != "$$SYSTEM_GO_MAJOR" ]; then \
echo "Warning: Your system Go version ($$SYSTEM_GO_VER) does not match project's go.mod ($$PROJECT_GO_VER)."; \
fi; \
fi

open_swag_server:
./internal/apiserver/cmd/swag/swagger_${HOST_OS}_${HOST_ARCH} serve --no-open -F=swagger --port 36666 ./api/swagger.yaml

Expand Down
4 changes: 2 additions & 2 deletions api/dms/service/v1/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ type ListDBServiceTipsReq struct {
// in:query
FilterDBType string `json:"filter_db_type" query:"filter_db_type"`
// Required: false
// enum: save_audit_plan,create_workflow,create_export_task
// enum: ["save_audit_plan","create_workflow","create_export_task"]
// in:query
FunctionalModule string `json:"functional_module" query:"functional_module" validate:"omitempty,oneof=save_audit_plan create_workflow create_export_task"`
}
Expand Down Expand Up @@ -360,7 +360,7 @@ type ListGlobalDBServicesReq struct {
// in:query
OrderBy dmsCommonV1.DBServiceOrderByField `query:"order_by" json:"order_by"`
// the db service connection
// enum: connect_success,connect_failed
// enum: ["connect_success","connect_failed"]
// in:query
FilterLastConnectionTestStatus *string `query:"filter_last_connection_test_status" json:"filter_last_connection_test_status" validate:"omitempty,oneof=connect_success connect_failed"`
// TODO This parameter is deprecated and will be removed soon.
Expand Down
2 changes: 1 addition & 1 deletion api/dms/service/v1/operation_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type OperationRecordListItem struct {
OperationAction string `json:"operation_action"`
OperationContent string `json:"operation_content"`
ProjectName string `json:"project_name"`
// enum: succeeded,failed
// enum: ["succeeded","failed"]
Status string `json:"status"`
}

Expand Down
2 changes: 1 addition & 1 deletion api/dms/service/v2/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ListGlobalDBServicesReq struct {
// in:query
OrderBy dmsCommonV1.DBServiceOrderByField `query:"order_by" json:"order_by"`
// the db service connection
// enum: connect_success,connect_failed
// enum: ["connect_success","connect_failed"]
// in:query
FilterLastConnectionTestStatus *string `query:"filter_last_connection_test_status" json:"filter_last_connection_test_status" validate:"omitempty,oneof=connect_success connect_failed"`
// filter db services by environment tag
Expand Down
10 changes: 6 additions & 4 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8624,6 +8624,12 @@
},
"x-go-package": "github.com/actiontech/dms/api/dms/service/v1"
},
"DateTime": {
"description": "DateTime is a time but it serializes to ISO8601 format with millis\nIt knows how to read 3 different variations of a RFC3339 date time.\nMost APIs we encounter want either millisecond or second precision times.\nThis just tries to make it worry-free.",
"type": "string",
"format": "date-time",
"x-go-package": "github.com/go-openapi/strfmt"
},
"DbServiceConnections": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -9922,10 +9928,6 @@
"x-go-package": "github.com/actiontech/dms/api/dms/service/v1"
},
"I18nStr": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"x-go-package": "github.com/actiontech/dms/pkg/dms-common/i18nPkg"
},
"ImportDBService": {
Expand Down
12 changes: 9 additions & 3 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,15 @@ definitions:
x-go-name: Params
type: object
x-go-package: github.com/actiontech/dms/api/dms/service/v1
DateTime:
description: |-
DateTime is a time but it serializes to ISO8601 format with millis
It knows how to read 3 different variations of a RFC3339 date time.
Most APIs we encounter want either millisecond or second precision times.
This just tries to make it worry-free.
format: date-time
type: string
x-go-package: github.com/go-openapi/strfmt
DbServiceConnections:
properties:
db_service_uid:
Expand Down Expand Up @@ -2394,9 +2403,6 @@ definitions:
type: object
x-go-package: github.com/actiontech/dms/api/dms/service/v1
I18nStr:
additionalProperties:
type: string
type: object
x-go-package: github.com/actiontech/dms/pkg/dms-common/i18nPkg
ImportDBService:
properties:
Expand Down
Binary file modified internal/apiserver/cmd/swag/swagger_linux_amd64
Binary file not shown.
2 changes: 1 addition & 1 deletion pkg/dms-common/api/dms/v1/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type ListDBServiceReq struct {
// in:query
FilterByBusiness string `query:"filter_by_business" json:"filter_by_business"`
// the db service connection
// enum: connect_success,connect_failed
// enum: ["connect_success","connect_failed"]
// in:query
FilterLastConnectionTestStatus *string `query:"filter_last_connection_test_status" json:"filter_last_connection_test_status" validate:"omitempty,oneof=connect_success connect_failed"`
// the db service host
Expand Down
4 changes: 2 additions & 2 deletions pkg/dms-common/api/dms/v2/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ListDBServiceReq struct {
// in:query
OrderBy v1.DBServiceOrderByField `query:"order_by" json:"order_by"`
// the db service connection
// enum: connect_success,connect_failed
// enum: ["connect_success","connect_failed"]
// in:query
FilterLastConnectionTestStatus *string `query:"filter_last_connection_test_status" json:"filter_last_connection_test_status" validate:"omitempty,oneof=connect_success connect_failed"`
// the db service host
Expand Down Expand Up @@ -110,4 +110,4 @@ type ListDBService struct {
LastConnectionTestStatus v1.LastConnectionTestStatus `json:"last_connection_test_status"`
// DB connect test error message
LastConnectionTestErrorMessage string `json:"last_connection_test_error_message,omitempty"`
}
}