We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ff3f09 commit 6b0844fCopy full SHA for 6b0844f
openapi/openapi.go
@@ -5,6 +5,7 @@ import (
5
"io/ioutil"
6
"net/http"
7
"net/url"
8
+ "regexp"
9
"sort"
10
"strings"
11
@@ -15,6 +16,9 @@ import (
15
16
"github.com/spf13/cobra"
17
)
18
19
+// reOpenAPI3 is a regex used to detect OpenAPI files from their contents.
20
+var reOpenAPI3 = regexp.MustCompile(`['"]?openapi['"]?:\s*['"]?3`)
21
+
22
// OpenAPI Extensions
23
const (
24
// Change the CLI name for an operation or parameter
@@ -475,7 +479,7 @@ func (l *loader) Detect(resp *http.Response) bool {
475
479
body, _ := ioutil.ReadAll(resp.Body)
476
480
defer resp.Body.Close()
477
481
478
- if strings.Contains(string(body), "openapi: 3") {
482
+ if reOpenAPI3.Match(body) {
483
return true
484
}
485
0 commit comments