The template added in #1774 breaks when there is one import mapping of value "-":
{{ if .ImportMapping }}
pathPrefix := path.Dir(pathToFile)
{{ end }}
{{ range $key, $value := .ImportMapping }}
{{ range $key, $value := .ImportMapping }}{{- if ne $value.Path "-"}}
for rawPath, rawFunc := range {{ $value.Name }}.PathToRawSpec(path.Join(pathPrefix, "{{ $key }}")) {
if _, ok := res[rawPath]; ok {
// it is not possible to compare functions in golang, so always overwrite the old value
}
res[rawPath] = rawFunc
}
{{- end }}
{{- end }}{{- end }}
return res
Results in this generated code:
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
res := make(map[string]func() ([]byte, error))
if len(pathToFile) > 0 {
res[pathToFile] = rawSpec
}
pathPrefix := path.Dir(pathToFile)
return res
}
And this error
go build
gen.go:366:2: declared and not used: pathPrefix
The template added in #1774 breaks when there is one import mapping of value
"-":{{ if .ImportMapping }} pathPrefix := path.Dir(pathToFile) {{ end }} {{ range $key, $value := .ImportMapping }} {{ range $key, $value := .ImportMapping }}{{- if ne $value.Path "-"}} for rawPath, rawFunc := range {{ $value.Name }}.PathToRawSpec(path.Join(pathPrefix, "{{ $key }}")) { if _, ok := res[rawPath]; ok { // it is not possible to compare functions in golang, so always overwrite the old value } res[rawPath] = rawFunc } {{- end }} {{- end }}{{- end }} return resResults in this generated code:
And this error