See the comment in tools.go, I cannot fully explain what's happening here. Somehow, Go 1.14 wants to use the vendored version of oapi-codegen but without this file, oapi-codegen isn't vendored so the generation fails. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
20 lines
414 B
Go
20 lines
414 B
Go
package util
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/getkin/kin-openapi/openapi3"
|
|
)
|
|
|
|
func LoadSwagger(filePath string) (swagger *openapi3.Swagger, err error) {
|
|
|
|
loader := openapi3.NewSwaggerLoader()
|
|
loader.IsExternalRefsAllowed = true
|
|
|
|
u, err := url.Parse(filePath)
|
|
if err == nil && u.Scheme != "" && u.Host != "" {
|
|
return loader.LoadSwaggerFromURI(u)
|
|
} else {
|
|
return loader.LoadSwaggerFromFile(filePath)
|
|
}
|
|
}
|