From 1357ee4cf8a3ad697677896f0ebe4ac1ad6b0f1e Mon Sep 17 00:00:00 2001 From: weiyang Date: Mon, 21 Aug 2017 18:31:24 +0800 Subject: [PATCH] [g_docs] Replace 'gopkg.in/yaml.v2' with 'github.com/ghodss/yaml' Signed-off-by: weiyang --- generate/swaggergen/g_docs.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index de114dd..f24936a 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -29,7 +29,7 @@ import ( "strings" "unicode" - "gopkg.in/yaml.v2" + "github.com/ghodss/yaml" "github.com/astaxie/beego/swagger" "github.com/astaxie/beego/utils" @@ -285,9 +285,14 @@ func GenerateDocs(curpath string) { defer fdyml.Close() defer fd.Close() dt, err := json.MarshalIndent(rootapi, "", " ") - dtyml, erryml := yaml.Marshal(rootapi) - if err != nil || erryml != nil { - panic(err) + if err != nil { + msg := fmt.Sprintf("failed to marshal api doc: %s", err) + panic(msg) + } + dtyml, erryml := yaml.JSONToYAML(dt) + if erryml != nil { + msg := fmt.Sprintf("failed to convert json bytes to yaml bytes: %s", erryml) + panic(msg) } _, err = fd.Write(dt) _, erryml = fdyml.Write(dtyml)