mirror of
https://github.com/BishopFox/sj.git
synced 2026-11-10 01:41:27 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e2e5fbebc | ||
|
|
a77f9f46bb | ||
|
|
5554e2bd30 | ||
|
|
09c460e768 |
No files matched your search
+11
-14
@@ -98,22 +98,19 @@ func MakeRequest(client http.Client, method, target string, timeout int64, reqDa
|
||||
continue
|
||||
}
|
||||
|
||||
key := Headers[i][:delimIndex]
|
||||
value := Headers[i][delimIndex+1:]
|
||||
key := strings.TrimSpace(Headers[i][:delimIndex])
|
||||
value := strings.TrimSpace(Headers[i][delimIndex+1:])
|
||||
|
||||
if len(Headers) == 2 {
|
||||
if key == "User-Agent" {
|
||||
UserAgent = value
|
||||
}
|
||||
if key == "Content-Type" {
|
||||
contentType = value
|
||||
}
|
||||
if key == "Accept" {
|
||||
accept = value
|
||||
}
|
||||
} else {
|
||||
req.Header.Set(key, value)
|
||||
if key == "User-Agent" {
|
||||
UserAgent = value
|
||||
}
|
||||
if key == "Content-Type" {
|
||||
contentType = value
|
||||
}
|
||||
if key == "Accept" {
|
||||
accept = value
|
||||
}
|
||||
req.Header.Set(key, value)
|
||||
}
|
||||
|
||||
// User-Agent handling
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ $ sj convert -u https://petstore.swagger.io/v2/swagger.json -o openapi.json`,
|
||||
log.Error("Command not specified. See the --help flag for usage.")
|
||||
}
|
||||
},
|
||||
Version: "2.0.2",
|
||||
Version: "2.0.4",
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
||||
+4
-3
@@ -96,6 +96,8 @@ func GenerateRequests(bodyBytes []byte, client http.Client) {
|
||||
if serverURL, ok := srv["url"].(string); ok {
|
||||
if strings.Contains(serverURL, "://") {
|
||||
apiTarget = serverURL
|
||||
} else if serverURL == "/" {
|
||||
basePath = ""
|
||||
} else {
|
||||
basePath = serverURL
|
||||
apiTarget = u.Scheme + "://" + u.Host
|
||||
@@ -205,7 +207,7 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
|
||||
|
||||
}
|
||||
|
||||
if strings.Contains(curl, "-d") {
|
||||
if strings.Contains(curl, "-d '") {
|
||||
bodyData += fmt.Sprintf("&%s=%s", propertyItem, pValue)
|
||||
curl = strings.TrimSuffix(curl, "'")
|
||||
curl += fmt.Sprintf("&%s=%s'", propertyItem, pValue)
|
||||
@@ -213,7 +215,6 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
|
||||
bodyData += fmt.Sprintf("%s=%s", propertyItem, pValue)
|
||||
curl += fmt.Sprintf(" -d '%s=%s'", propertyItem, pValue)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
|
||||
case "header":
|
||||
curl += fmt.Sprintf(" -H \"%s: %s\"", name, pValue)
|
||||
case "body":
|
||||
if strings.Contains(curl, "-d") {
|
||||
if strings.Contains(curl, "-d '") {
|
||||
bodyData += fmt.Sprintf("&%s=%s", name, pValue)
|
||||
curl = strings.TrimSuffix(curl, "'")
|
||||
curl += fmt.Sprintf("&%s=%s'", name, pValue)
|
||||
|
||||
Reference in new issue
Block a user