Skip to content

Commit

Permalink
Merge pull request #481 from lonnblad/programmatic-multiline-api-desc…
Browse files Browse the repository at this point in the history
…ription

Fixed JSON issue with Multiline API Description
  • Loading branch information
ubogdan committed Jul 29, 2019
2 parents c19280e + 5c2a121 commit c2f6613
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/go-openapi/spec"
"go/format"
"io"
"log"
Expand All @@ -14,6 +13,8 @@ import (
"text/template"
"time"

"github.com/go-openapi/spec"

"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/swaggo/swag"
Expand Down Expand Up @@ -225,6 +226,7 @@ package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
Expand Down Expand Up @@ -254,6 +256,9 @@ var SwaggerInfo = swaggerInfo{
type s struct{}
func (s *s) ReadDoc() string {
sInfo := SwaggerInfo
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface{}) string {
a, _ := json.Marshal(v)
Expand All @@ -265,7 +270,7 @@ func (s *s) ReadDoc() string {
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, SwaggerInfo); err != nil {
if err := t.Execute(&tpl, sInfo); err != nil {
return doc
}
Expand Down

0 comments on commit c2f6613

Please sign in to comment.