Skip to content

Commit

Permalink
chore: fix unit tests after merging #1499 (#1558)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubogdan authored Apr 17, 2023
1 parent acb0508 commit 45df9a3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func (g *Gen) writeGoDocV3(packageName string, output io.Writer, openAPI *v3.Ope
generator, err := template.New("oas3.tmpl").Funcs(template.FuncMap{
"printDoc": func(v string) string {
// Add schemes
v = "{\n \"schemes\": {{ marshal .Schemes }}," + v[1:]
v = "{\n \"schemes\": " + config.LeftTemplateDelim + " marshal .Schemes " + config.RightTemplateDelim + "," + v[1:]
// Sanitize backticks
return strings.Replace(v, "`", "`+\"`\"+`", -1)
},
Expand All @@ -524,9 +524,9 @@ func (g *Gen) writeGoDocV3(packageName string, output io.Writer, openAPI *v3.Ope
OpenAPI: openAPI.OpenAPI,
Info: &v3.Extendable[v3.Info]{
Spec: &v3.Info{
Description: "{{escape .Description}}",
Title: "{{.Title}}",
Version: "{{.Version}}",
Description: config.LeftTemplateDelim + "escape .Description" + config.RightTemplateDelim,
Title: config.LeftTemplateDelim + ".Title" + config.RightTemplateDelim,
Version: config.LeftTemplateDelim + ".Version" + config.RightTemplateDelim,
TermsOfService: openAPI.Info.Spec.TermsOfService,
Contact: openAPI.Info.Spec.Contact,
License: openAPI.Info.Spec.License,
Expand Down
2 changes: 1 addition & 1 deletion gen/gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func TestGen_BuildDocCustomDelims(t *testing.T) {
}
}

cmd := exec.Command("go", "build", "-buildmode=plugin", "github.com/swaggo/swag/testdata/delims")
cmd := exec.Command("go", "build", "-buildmode=plugin", "github.com/swaggo/swag/v2/testdata/delims")

cmd.Dir = config.SearchDir

Expand Down
4 changes: 3 additions & 1 deletion gen/src/oas2.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by swaggo/swag{{ if .GeneratedTime }} at {{ .Timestamp }}{{ end }}. DO NOT EDIT.

package docs
package {{.PackageName}}

import "github.com/swaggo/swag/v2"

Expand All @@ -16,6 +16,8 @@ var SwaggerInfo{{ if ne .InstanceName "swagger" }}{{ .InstanceName }} {{- end }}
Description: {{ printf "%q" .Description}},
InfoInstanceName: {{ printf "%q" .InstanceName }},
SwaggerTemplate: docTemplate{{ if ne .InstanceName "swagger" }}{{ .InstanceName }} {{- end }},
LeftDelim: {{ printf "%q" .LeftTemplateDelim}},
RightDelim: {{ printf "%q" .RightTemplateDelim}},
}

func init() {
Expand Down
6 changes: 4 additions & 2 deletions gen/src/oas3.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by swaggo/swag{{ if .GeneratedTime }} at {{ .Timestamp }}{{ end }}. DO NOT EDIT
// Code generated by swaggo/swag{{ if .GeneratedTime }} at {{ .Timestamp }}{{ end }}. DO NOT EDIT.

package docs
package {{.PackageName}}

import "github.com/swaggo/swag/v2"

Expand All @@ -13,6 +13,8 @@ var SwaggerInfo{{ if ne .InstanceName "swagger" }}{{ .InstanceName }} {{- end }}
Description: {{ printf "%q" .Description}},
InfoInstanceName: {{ printf "%q" .InstanceName }},
SwaggerTemplate: docTemplate{{ if ne .InstanceName "swagger" }}{{ .InstanceName }} {{- end }},
LeftDelim: {{ printf "%q" .LeftTemplateDelim}},
RightDelim: {{ printf "%q" .RightTemplateDelim}},
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/swaggo/swag
module github.com/swaggo/swag/v2

go 1.18

Expand Down
6 changes: 3 additions & 3 deletions testdata/delims/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

import (
"github.com/swaggo/swag"
"github.com/swaggo/swag/testdata/delims/api"
_ "github.com/swaggo/swag/testdata/delims/docs"
"github.com/swaggo/swag/v2"
"github.com/swaggo/swag/v2/testdata/delims/api"
_ "github.com/swaggo/swag/v2/testdata/delims/docs"
)

func ReadDoc() string {
Expand Down

0 comments on commit 45df9a3

Please sign in to comment.