Skip to content

Commit 94ab8c2

Browse files
committed
improve
Signed-off-by: Grant Linville <[email protected]>
1 parent de94f28 commit 94ab8c2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/loader/url.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,17 @@ func getWithDefaults(req *http.Request) ([]byte, error) {
135135
originalPath := req.URL.Path
136136

137137
// First, try to get the original path as is.
138-
// It might be a raw tool file or an OpenAPI definition.
138+
// It might be an OpenAPI definition.
139139
resp, err := http.DefaultClient.Do(req)
140140
if err != nil {
141141
return nil, err
142142
}
143143
defer resp.Body.Close()
144144

145145
if resp.StatusCode == http.StatusOK {
146-
return io.ReadAll(resp.Body)
146+
if toolBytes, err := io.ReadAll(resp.Body); err == nil && isOpenAPI(toolBytes) != 0 {
147+
return toolBytes, nil
148+
}
147149
}
148150

149151
for i, def := range types.DefaultFiles {

0 commit comments

Comments
 (0)