Documentation
¶
Index ¶
- Variables
- func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client, replayClient *http.Client) error
- func CheckAndConfigureProxy() (client http.Client, replayClient *http.Client, err error)
- func CheckSecuritySchemes(spec map[string]interface{})
- func EnforceSingleContentType(newContentType string)
- func Execute()
- func ExtractJSONFromJSSpec(bodyBytes []byte) ([]byte, bool)
- func ExtractSpecFromJS(bodyBytes []byte) []byte
- func ExtractSpecURLsFromHTML(htmlContent, pageURL string) []string
- func GenerateExample(node *SchemaNode) interface{}
- func GenerateRequests(bodyBytes []byte, client http.Client, replayClient *http.Client) error
- func MakeRequest(client http.Client, method, target string, timeout int64, reqData io.Reader) ([]byte, string, int, error)
- func MakeRequestFull(client http.Client, method, target string, timeout int64, reqData io.Reader) ([]byte, string, int, string, string, error)
- func PrintSpecInfo(spec map[string]interface{})
- func ReplayRequest(replayClient *http.Client, method, target string, timeout int64, ...)
- func ResolveExternalRef(ref string, baseDir string) map[string]interface{}
- func ResolveRef(spec map[string]interface{}, ref string) map[string]interface{}
- func ResolveRefWithContext(spec map[string]interface{}, ref string) (map[string]interface{}, map[string]interface{})
- func SafelyUnmarshalSpec(data []byte) (map[string]interface{}, error)
- func SetScheme(swaggerURL string) (scheme string)
- func SummarizeOperationSecurity(spec map[string]interface{})
- func TrimHostScheme(apiTarget, fullUrlHost string) (host string)
- func UnmarshalSpec(bodyBytes []byte) (*openapi3.T, error)
- func WriteConvertedDefinitionFile(data []byte)
- func XmlFromObject(obj map[string]interface{}) string
- type Result
- type SchemaNode
- type VerboseResult
Constants ¶
This section is empty.
Variables ¶
var ( Headers []string UserAgent string )
var Mode string
Functions ¶
func BuildRequestsFromPaths ¶
func CheckAndConfigureProxy ¶
func CheckSecuritySchemes ¶
func CheckSecuritySchemes(spec map[string]interface{})
func EnforceSingleContentType ¶
func EnforceSingleContentType(newContentType string)
func Execute ¶
func Execute()
Execute runs the root command. It is the single place in the package that terminates the process: command and library code return errors up to here instead of calling os.Exit, which keeps that logic testable and reusable.
func ExtractJSONFromJSSpec ¶
ExtractJSONFromJSSpec scans a Swagger-UI-style JavaScript bundle for an OpenAPI/Swagger document assigned to a top-level var/let/const. If the captured value is itself a wrapper object (swagger-ui-express / swagger-ui bundle config), it unwraps one level via the swaggerDoc/spec/openapi keys. Returns the extracted JSON bytes and true on success, or the original bytes and false on failure.
func ExtractSpecFromJS ¶
func ExtractSpecURLsFromHTML ¶
ExtractSpecURLsFromHTML returns the spec/initializer URLs referenced by a Swagger UI page (or swagger-config JSON), resolved against pageURL and deduped.
func GenerateExample ¶
func GenerateExample(node *SchemaNode) interface{}
func GenerateRequests ¶
func MakeRequest ¶
func MakeRequest(client http.Client, method, target string, timeout int64, reqData io.Reader) ([]byte, string, int, error)
MakeRequest returns the body bytes, body string, and status code. It wraps MakeRequestFull for callers that do not need the Content-Type.
func MakeRequestFull ¶
func MakeRequestFull(client http.Client, method, target string, timeout int64, reqData io.Reader) ([]byte, string, int, string, string, error)
MakeRequestFull also returns the response Content-Type and the User-Agent sent. Taking body and Content-Type from one response avoids a second request per URL.
func PrintSpecInfo ¶
func PrintSpecInfo(spec map[string]interface{})
func ReplayRequest ¶
func ReplayRequest(replayClient *http.Client, method, target string, timeout int64, reqData io.Reader, userAgent string)
userAgent is the one the replayed request carried, so the copy reproduces it.
func ResolveExternalRef ¶
func ResolveRef ¶
func ResolveRefWithContext ¶
func ResolveRefWithContext(spec map[string]interface{}, ref string) (map[string]interface{}, map[string]interface{})
ResolveRefWithContext resolves a reference and returns both the resolved schema and the spec it came from
func SafelyUnmarshalSpec ¶
func SummarizeOperationSecurity ¶
func SummarizeOperationSecurity(spec map[string]interface{})
SummarizeOperationSecurity prints, to stderr, the effective security requirement of every declared operation. It is computed from the spec alone (no requests), so it runs for automate, endpoints, and prepare alike, and it stays off stdout to keep that stream pipeable.
func TrimHostScheme ¶
TrimHostScheme trims the scheme from the provided URL if the '-T' flag is supplied to sj.
func WriteConvertedDefinitionFile ¶
func WriteConvertedDefinitionFile(data []byte)
func XmlFromObject ¶
Types ¶
type Result ¶
type Result struct {
Method string `json:"method"`
Status int `json:"status"`
Target string `json:"target"`
// ContentType names the request body encoding this result came from. It is
// omitted unless an operation was tested under more than one, so
// single-variant output is unchanged.
ContentType string `json:"contentType,omitempty"`
// Security is the effective security requirement the spec declares for this
// operation (e.g. "bearerAuth", "public"). Omitted when undeclared.
Security string `json:"security,omitempty"`
// MissingAuth is set when the spec marks this operation as requiring auth but
// it returned a 2xx with no matching credential supplied — a possible broken
// access control finding.
MissingAuth bool `json:"missingAuth,omitempty"`
}
type SchemaNode ¶
type SchemaNode struct {
Type string
Properties map[string]*SchemaNode
Items *SchemaNode
Required map[string]bool
Enum []interface{}
Example interface{}
Ref string
OneOf []*SchemaNode
AnyOf []*SchemaNode
AdditionalProperties *SchemaNode
}
func ExpandSchema ¶
type VerboseResult ¶
type VerboseResult struct {
Method string `json:"method"`
Preview string `json:"preview"`
Status int `json:"status"`
Target string `json:"target"`
Curl string `json:"curl"`
ContentType string `json:"contentType,omitempty"`
Security string `json:"security,omitempty"`
MissingAuth bool `json:"missingAuth,omitempty"`
}