Skip to content

Commit eab2821

Browse files
committed
Better support for resolving relative path refs
1 parent 5d19e0d commit eab2821

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
- Better support for resolving relative path references.
89
- Be more resilient to parser panics when using `--watch`
910
- Update Docker build to use Go 1.12 and Go modules.
1011
- Enhance example-from-schema generation code. Support enums, string formats,

apisprout.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"math/rand"
1111
"mime"
1212
"net/http"
13+
"net/url"
1314
"os"
1415
"path/filepath"
1516
"strconv"
@@ -227,8 +228,13 @@ func load(uri string, data []byte) (swagger *openapi3.Swagger, router *openapi3f
227228
loader := openapi3.NewSwaggerLoader()
228229
loader.IsExternalRefsAllowed = true
229230

230-
swagger, err := loader.LoadSwaggerFromData(data)
231+
var u *url.URL
232+
u, err = url.Parse(uri)
233+
if err != nil {
234+
return
235+
}
231236

237+
swagger, err = loader.LoadSwaggerFromDataWithPath(data, u)
232238
if err != nil {
233239
return
234240
}

0 commit comments

Comments
 (0)