mirror of https://github.com/1Panel-dev/1Panel
style: 修改swagger文件位置
parent
306e5c5b9e
commit
cec416b674
|
@ -18,10 +18,10 @@ import (
|
|||
type NginxService struct {
|
||||
}
|
||||
|
||||
func (n NginxService) GetNginxConfig() (dto.FileInfo, error) {
|
||||
func (n NginxService) GetNginxConfig() (response.FileInfo, error) {
|
||||
nginxInstall, err := getAppInstallByKey(constant.AppNginx)
|
||||
if err != nil {
|
||||
return dto.FileInfo{}, err
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
configPath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "conf", "nginx.conf")
|
||||
info, err := files.NewFileInfo(files.FileOption{
|
||||
|
@ -29,9 +29,9 @@ func (n NginxService) GetNginxConfig() (dto.FileInfo, error) {
|
|||
Expand: true,
|
||||
})
|
||||
if err != nil {
|
||||
return dto.FileInfo{}, err
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
return dto.FileInfo{FileInfo: *info}, nil
|
||||
return response.FileInfo{FileInfo: *info}, nil
|
||||
}
|
||||
|
||||
func (n NginxService) GetConfigByScope(req request.NginxScopeReq) ([]response.NginxParam, error) {
|
||||
|
|
|
@ -41,7 +41,7 @@ type IWebsiteService interface {
|
|||
DeleteWebsiteDomain(domainId uint) error
|
||||
GetNginxConfigByScope(req request.NginxScopeReq) (*response.WebsiteNginxConfig, error)
|
||||
UpdateNginxConfigByScope(req request.NginxConfigUpdate) error
|
||||
GetWebsiteNginxConfig(websiteId uint) (dto.FileInfo, error)
|
||||
GetWebsiteNginxConfig(websiteId uint) (response.FileInfo, error)
|
||||
GetWebsiteHTTPS(websiteId uint) (response.WebsiteHTTPS, error)
|
||||
OpWebsiteHTTPS(req request.WebsiteHTTPSOp) (response.WebsiteHTTPS, error)
|
||||
PreInstallCheck(req request.WebsiteInstallCheckReq) ([]response.WebsitePreInstallCheck, error)
|
||||
|
@ -382,19 +382,19 @@ func (w WebsiteService) UpdateNginxConfigByScope(req request.NginxConfigUpdate)
|
|||
return updateNginxConfig(constant.NginxScopeServer, params, &website)
|
||||
}
|
||||
|
||||
func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint) (dto.FileInfo, error) {
|
||||
func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint) (response.FileInfo, error) {
|
||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteId))
|
||||
if err != nil {
|
||||
return dto.FileInfo{}, err
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
|
||||
nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppNginx))
|
||||
if err != nil {
|
||||
return dto.FileInfo{}, err
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
nginxInstall, err := appInstallRepo.GetFirst(appInstallRepo.WithAppId(nginxApp.ID))
|
||||
if err != nil {
|
||||
return dto.FileInfo{}, err
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
|
||||
configPath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "conf", "conf.d", website.Alias+".conf")
|
||||
|
@ -404,9 +404,9 @@ func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint) (dto.FileInfo, err
|
|||
Expand: true,
|
||||
})
|
||||
if err != nil {
|
||||
return dto.FileInfo{}, err
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
return dto.FileInfo{FileInfo: *info}, nil
|
||||
return response.FileInfo{FileInfo: *info}, nil
|
||||
}
|
||||
|
||||
func (w WebsiteService) GetWebsiteHTTPS(websiteId uint) (response.WebsiteHTTPS, error) {
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"contact": {}
|
||||
},
|
||||
"paths": {}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
info:
|
||||
contact: {}
|
||||
paths: {}
|
||||
swagger: "2.0"
|
|
@ -5,10 +5,10 @@ import (
|
|||
"net/http"
|
||||
|
||||
v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
|
||||
"github.com/1Panel-dev/1Panel/backend/docs"
|
||||
"github.com/1Panel-dev/1Panel/backend/i18n"
|
||||
"github.com/1Panel-dev/1Panel/backend/middleware"
|
||||
rou "github.com/1Panel-dev/1Panel/backend/router"
|
||||
"github.com/1Panel-dev/1Panel/cmd/server/docs"
|
||||
"github.com/1Panel-dev/1Panel/cmd/server/web"
|
||||
ginI18n "github.com/gin-contrib/i18n"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -38,17 +38,19 @@ func setWebStatic(rootRouter *gin.Engine) {
|
|||
|
||||
func Routers() *gin.Engine {
|
||||
Router := gin.Default()
|
||||
|
||||
docs.SwaggerInfo.BasePath = "/api/v1"
|
||||
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
|
||||
|
||||
Router.Use(middleware.OperationLog())
|
||||
Router.Use(middleware.CSRF())
|
||||
Router.Use(middleware.LoadCsrfToken())
|
||||
|
||||
setWebStatic(Router)
|
||||
docs.SwaggerInfo.BasePath = "/api/v1"
|
||||
|
||||
Router.Use(i18n.GinI18nLocalize())
|
||||
Router.GET("/api/v1/info", v1.ApiGroupApp.BaseApi.GetSafetyStatus)
|
||||
Router.GET("/api/v1/:code", v1.ApiGroupApp.BaseApi.SafeEntrance)
|
||||
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
|
||||
|
||||
Router.SetFuncMap(template.FuncMap{
|
||||
"Localize": ginI18n.GetMessage,
|
||||
|
|
|
@ -10,7 +10,12 @@ const docTemplate = `{
|
|||
"info": {
|
||||
"description": "{{escape .Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
|
@ -20,12 +25,12 @@ const docTemplate = `{
|
|||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "",
|
||||
Host: "",
|
||||
BasePath: "",
|
||||
Version: "1.0",
|
||||
Host: "localhost",
|
||||
BasePath: "/api/v1",
|
||||
Schemes: []string{},
|
||||
Title: "",
|
||||
Description: "",
|
||||
Title: "1Panel",
|
||||
Description: "开源Linux面板",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "开源Linux面板",
|
||||
"title": "1Panel",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "localhost",
|
||||
"basePath": "/api/v1",
|
||||
"paths": {}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
basePath: /api/v1
|
||||
host: localhost
|
||||
info:
|
||||
contact: {}
|
||||
description: 开源Linux面板
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
termsOfService: http://swagger.io/terms/
|
||||
title: 1Panel
|
||||
version: "1.0"
|
||||
paths: {}
|
||||
swagger: "2.0"
|
|
@ -2,8 +2,21 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/1Panel-dev/1Panel/backend/server"
|
||||
_ "github.com/1Panel-dev/1Panel/cmd/server/docs"
|
||||
)
|
||||
|
||||
// @title 1Panel
|
||||
// @version 1.0
|
||||
// @description 开源Linux面板
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
// @host localhost
|
||||
// @BasePath /api/v1
|
||||
|
||||
//go:generate swag init -o ./docs -d ../../backend/app/api/v1 -g ../../../../cmd/server/main.go
|
||||
func main() {
|
||||
server.Start()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue