Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions common/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ func Capitalize(s string) string {
// AppendStrings adds non-empty strings from in to out and returns a new slice.
func AppendStrings(out []string, in []string, prefix string) []string {
for _, s := range in {
if s != "" {
out = append(out, prefix+s)
for _, line := range strings.Split(s, "\n") {
if line != "" {
out = append(out, prefix+line)
}
}
}
return out
Expand Down
29 changes: 28 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,34 @@ func main() {
opt := renderer.NewOptions()
opt.DeReference = true

swagger := openapi.NewOpenAPIRenderer(openapi.NewMetaData("", ""), opt)
meta := openapi.NewMetaData("main.go demo", "v1.0.0")
meta.Info.Description = "Demonstration of OpenAPI rendering."
meta.Info.TermsOfService = "https://some.site/tos"
meta.Info.Contact = &openapi.ContactObject{
Name: "Contact Name",
URL: "https://some.site/contact",
Email: "contact@some.site",
}
meta.Info.License = &openapi.LicenseObject{
Name: "This is the license.",
URL: "https://license.server/license",
}
meta.ExternalDocs = &openapi.ExternalDocumentationObject{
URL: "https://some.site/docs",
Description: "This is the documentation site.",
}
meta.Servers = []*openapi.ServerObject{
{
URL: "https://a.b.com/",
Description: "Main server",
},
{
URL: "https://a.b.c.com/",
Description: "Backup server",
},
}

swagger := openapi.NewOpenAPIRenderer(meta, opt)
outLines, err := swagger.ProcessSchema(schema)
if err != nil {
fmt.Println(err)
Expand Down
Loading