-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ccfish86/develop
Develop
- Loading branch information
Showing
70 changed files
with
8,978 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
在[[wI2L/fizz: Gin wrapper with OpenAPI 3 spec generation (github.com)](https://github.com/wI2L/fizz)]的基础上,追加了UI。 | ||
|
||
主要是以下几点: | ||
|
||
1. 参考了`springdoc`的处理方式,后续版本(如果使用的人多)可以尝试支持多个分组 | ||
2. 使用了针对swagger2和springdoc(openapi v3)的UI,即[[Knife4j Knife4j is a set of Swagger2 and OpenAPI3 All-in-one enhancement solution ](https://github.com/xiaoymin/knife4j)]的`knife4j-vue3`项目 | ||
|
||
开发时注意事项,因使用了`内嵌`静态资源文件的库,所以需要`golang 1.16`以上的支持。 | ||
|
||
更新`knife4j-vue3`时,只需要使用`npm`将编译后的`dist/`内容复制到本项目的`/ui/knife4go`下即可。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,44 @@ | ||
module github.com/wI2L/fizz | ||
module github.com/ccfish86/fizz/v2 | ||
|
||
go 1.12 | ||
go 1.17 | ||
|
||
require ( | ||
github.com/Pallinder/go-randomdata v1.2.0 | ||
github.com/gin-contrib/cors v1.3.0 | ||
github.com/gin-gonic/gin v1.7.7 | ||
github.com/go-playground/validator/v10 v10.9.0 // indirect | ||
github.com/gin-gonic/gin v1.8.1 | ||
github.com/gofrs/uuid v3.2.0+incompatible | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/uuid v1.1.1 // indirect | ||
github.com/juju/errors v0.0.0-20220622220526-54a94488269b | ||
github.com/stretchr/testify v1.7.2 | ||
github.com/wI2L/fizz v0.22.0 | ||
golang.org/x/text v0.3.7 | ||
gopkg.in/yaml.v2 v2.4.0 | ||
) | ||
|
||
require ( | ||
github.com/loopfz/gadgeto v0.9.0 // indirect | ||
github.com/mcorbin/gadgeto v0.12.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/gin-contrib/sse v0.1.0 // indirect | ||
github.com/go-playground/locales v0.14.0 // indirect | ||
github.com/go-playground/universal-translator v0.18.0 // indirect | ||
github.com/go-playground/validator/v10 v10.11.0 // indirect | ||
github.com/goccy/go-json v0.9.8 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/juju/errors v0.0.0-20190930114154-d42613fe1ab9 | ||
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect | ||
github.com/juju/testing v0.0.0-20190723135506-ce30eb24acd2 // indirect | ||
github.com/loopfz/gadgeto v0.9.0 | ||
github.com/leodido/go-urn v1.2.1 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
github.com/stretchr/testify v1.7.0 | ||
github.com/ugorji/go v1.2.6 // indirect | ||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect | ||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect | ||
golang.org/x/text v0.3.7 | ||
google.golang.org/protobuf v1.27.1 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/ugorji/go/codec v1.2.7 // indirect | ||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect | ||
golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect | ||
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/go-playground/validator.v9 v9.30.0 // indirect | ||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ui | ||
|
||
type SwaggerConfig struct { | ||
ConfigUrl string `json:"configUrl"` | ||
DisplayRequestDuration bool `json:"displayRequestDuration"` | ||
Oauth2RedirectUrl string `json:"oauth2RedirectUrl"` | ||
OperationsSorter string `json:"operationsSorter"` | ||
ValidatorUrl string `json:"validatorUrl"` | ||
Urls *[]SwaggerUrl `json:"urls"` | ||
} | ||
|
||
type SwaggerUrl struct { | ||
Url string `json:"url"` | ||
Name string `json:"name"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package ui | ||
|
||
import ( | ||
"bytes" | ||
"html/template" | ||
"io" | ||
"io/fs" | ||
"strings" | ||
"time" | ||
) | ||
|
||
type fsWrapper struct { | ||
fs fs.FS | ||
jsonFileName string | ||
} | ||
|
||
func FsWrapper(fs fs.FS, jsonFilePath string) *fsWrapper { | ||
return &fsWrapper{ | ||
fs: fs, | ||
jsonFileName: jsonFilePath, | ||
} | ||
} | ||
|
||
func (f *fsWrapper) Open(name string) (fs.File, error) { | ||
if strings.HasSuffix(name, "index.html") { | ||
tpl, err := template.ParseFS(f.fs, "index.gohtml") | ||
if err != nil { | ||
return nil, err | ||
} | ||
data := map[string]interface{}{ | ||
"openApiJson": strings.TrimPrefix(f.jsonFileName, "/"), | ||
} | ||
|
||
buf := new(bytes.Buffer) | ||
if err = tpl.Execute(buf, data); err != nil { | ||
return nil, err | ||
} | ||
|
||
return fsWrapperFile{ | ||
r: io.NopCloser(bytes.NewReader(buf.Bytes())), | ||
fInfo: fileInfoMock{ | ||
name: name, | ||
size: int64(buf.Len()), | ||
}, | ||
}, nil | ||
} | ||
|
||
return f.fs.Open(name) | ||
} | ||
|
||
type fsWrapperFile struct { | ||
r io.ReadCloser | ||
fInfo fs.FileInfo | ||
} | ||
|
||
func (f fsWrapperFile) Stat() (fs.FileInfo, error) { | ||
return f.fInfo, nil | ||
} | ||
|
||
func (f fsWrapperFile) Read(bytes []byte) (int, error) { | ||
return f.r.Read(bytes) | ||
} | ||
|
||
func (f fsWrapperFile) Close() error { | ||
return f.r.Close() | ||
} | ||
|
||
type fileInfoMock struct { | ||
name string | ||
size int64 | ||
} | ||
|
||
func (f fileInfoMock) Name() string { | ||
return f.name | ||
} | ||
|
||
func (f fileInfoMock) Size() int64 { | ||
return f.size | ||
} | ||
|
||
func (f fileInfoMock) Mode() fs.FileMode { | ||
return fs.FileMode(0) | ||
} | ||
|
||
func (f fileInfoMock) ModTime() time.Time { | ||
return time.Now() | ||
} | ||
|
||
func (f fileInfoMock) IsDir() bool { | ||
return false | ||
} | ||
|
||
func (f fileInfoMock) Sys() interface{} { | ||
panic("implement me") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="./favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title></title> | ||
<script type="module" crossorigin src="./webjars/js/doc-3e371862.js"></script> | ||
<link rel="stylesheet" href="./webjars/css/doc-c5acc9d0.css"> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
|
||
</body> | ||
</html> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.