Compare commits

...
2 Commits
2 changed files with 18 additions and 5 deletions

No files matched your search

+1 -1
View File
@@ -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.0",
Version: "2.0.2",
}
func Execute() {
+17 -4
View File
@@ -98,7 +98,7 @@ func GenerateRequests(bodyBytes []byte, client http.Client) {
apiTarget = serverURL
} else {
basePath = serverURL
apiTarget = u.Scheme + "://" + u.Host + serverURL
apiTarget = u.Scheme + "://" + u.Host
}
}
}
@@ -181,7 +181,20 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
var pValue string
if propertyName, ok := properties[propertyItem].(map[string]interface{}); ok {
if exampleValue, ok := propertyName["example"]; ok {
pValue = exampleValue.(string)
switch ex := exampleValue.(type) {
case string:
pValue = exampleValue.(string)
case []interface{}:
if len(ex) > 0 {
if v, ok := ex[0].(string); ok {
pValue = v
} else {
pValue = "1"
}
}
default:
pValue = "1"
}
} else if propertyType, ok := propertyName["type"].(string); ok {
// Attempt to prevent version strings from being improperly supplied (i.e. v1)
if propertyType == "string" && propertyName["name"] != "version" {
@@ -384,7 +397,7 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
jsonResultsStringArray = append(jsonResultsStringArray, ","+string(result))
}
if outputFormat == "console" {
writeLog(sc, basePath+logURL.Path, strings.ToUpper(method), errorDescriptions[sc], resp[:tempResponsePreviewLength])
writeLog(sc, logURL.Path, strings.ToUpper(method), errorDescriptions[sc], resp[:tempResponsePreviewLength])
}
}
} else {
@@ -394,7 +407,7 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
jsonResultsStringArray = append(jsonResultsStringArray, ","+string(result))
}
if outputFormat == "console" {
writeLog(sc, basePath+logURL.Path, strings.ToUpper(method), errorDescriptions[sc], resp[:tempResponsePreviewLength])
writeLog(sc, logURL.Path, strings.ToUpper(method), errorDescriptions[sc], resp[:tempResponsePreviewLength])
}
}