mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-28 01:36:56 +08:00
fix: Fix the issue of generating Swagger documents with actual parameters (#10379)
This commit is contained in:
parent
7e8581a7de
commit
725d03b41e
5 changed files with 1737 additions and 52 deletions
|
|
@ -8,12 +8,31 @@ import (
|
|||
|
||||
// @title 1Panel
|
||||
// @version 2.0
|
||||
// @description 开源Linux面板
|
||||
// @description Top-Rated Web-based Linux Server Management Tool
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @host localhost
|
||||
// @license.name GPL-3.0
|
||||
// @license.url https://www.gnu.org/licenses/gpl-3.0.html
|
||||
// @BasePath /api/v2
|
||||
// @schemes http https
|
||||
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @description Custom Token Format, Format: md5('1panel' + API-Key + UnixTimestamp).
|
||||
// @description ```
|
||||
// @description eg:
|
||||
// @description curl -X GET "http://{host}:{port}/api/v2/toolbox/device/base" \
|
||||
// @description -H "1Panel-Token: <1panel_token>" \
|
||||
// @description -H "1Panel-Timestamp: <current_unix_timestamp>"
|
||||
// @description ```
|
||||
// @description - `1Panel-Token` is the key for the panel API Key.
|
||||
// @type apiKey
|
||||
// @in Header
|
||||
// @name 1Panel-Token
|
||||
// @securityDefinitions.apikey Timestamp
|
||||
// @type apiKey
|
||||
// @in header
|
||||
// @name 1Panel-Timestamp
|
||||
// @description - `1Panel-Timestamp` is the Unix timestamp of the current time in seconds.
|
||||
|
||||
func main() {
|
||||
if err := cmd.RootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -124,6 +124,12 @@ func TestGenerateSwaggerDoc(t *testing.T) {
|
|||
}
|
||||
newSwagger.Paths[key] = val
|
||||
}
|
||||
for key, val := range coreSwagger.Definitions {
|
||||
if _, ok := newSwagger.Definitions[key]; ok {
|
||||
fmt.Printf("duplicate definitions were found: %s \n", key)
|
||||
}
|
||||
newSwagger.Definitions[key] = val
|
||||
}
|
||||
|
||||
newJson, err := json.MarshalIndent(newSwagger, "", "\t")
|
||||
if err != nil {
|
||||
|
|
@ -150,7 +156,7 @@ type Swagger struct {
|
|||
Host string `json:"host"`
|
||||
BasePath string `json:"basePath"`
|
||||
Paths map[string]interface{} `json:"paths"`
|
||||
Definitions interface{} `json:"definitions"`
|
||||
Definitions map[string]interface{} `json:"definitions"`
|
||||
}
|
||||
|
||||
func loadDefaultDocs() string {
|
||||
|
|
@ -166,7 +172,7 @@ var SwaggerInfo = &swag.Spec{
|
|||
BasePath: "/api/v2",
|
||||
Schemes: []string{},
|
||||
Title: "1Panel",
|
||||
Description: "开源Linux面板",
|
||||
Description: "Top-Rated Web-based Linux Server Management Tool",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ import (
|
|||
)
|
||||
|
||||
// @title 1Panel
|
||||
// @version 1.0
|
||||
// @description Open Source Linux Panel
|
||||
// @version 2.0
|
||||
// @description Top-Rated Web-based Linux Server Management Tool
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @BasePath /api/v1
|
||||
// @license.name GPL-3.0
|
||||
// @license.url https://www.gnu.org/licenses/gpl-3.0.html
|
||||
// @BasePath /api/v2
|
||||
// @schemes http https
|
||||
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue