diff --git a/pkg/loader/url.go b/pkg/loader/url.go index 95249478..c050edba 100644 --- a/pkg/loader/url.go +++ b/pkg/loader/url.go @@ -133,6 +133,20 @@ func loadURL(ctx context.Context, cache *cache.Client, base *source, name string func getWithDefaults(req *http.Request) ([]byte, error) { originalPath := req.URL.Path + + // First, try to get the original path as is. It might be an OpenAPI definition. + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if resp.StatusCode == http.StatusOK { + if toolBytes, err := io.ReadAll(resp.Body); err == nil && isOpenAPI(toolBytes) != 0 { + return toolBytes, nil + } + } + for i, def := range types.DefaultFiles { base := path.Base(originalPath) if !strings.Contains(base, ".") {