You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
572 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package CommonUtil
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
)
var swaggerFile = "docs/swagger.json"
/**
功能读取swagger的生成json
作者:黄海
时间2020-03-16
*/
func ReadSwaggerJson() interface{} {
//读取doc目录下的swagger.json
f, err := os.Open(swaggerFile)
if err != nil {
log.Fatal("读取swagger.json失败")
return nil
}
content, _ := ioutil.ReadAll(f)
var jsonBody interface{}
err = json.Unmarshal(content, &jsonBody)
if err != nil {
fmt.Println("ERROR: ", err.Error())
return nil
}
return jsonBody
}