openapi

package
v0.0.0-...-bdd1cc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFormat   = errors.New("invalid format specified")
	ErrFormatDetection = errors.New("unable to detect format")
	ErrEmptyContent    = errors.New("empty content provided")
	ErrMissingURL      = errors.New("URL is required")
)
View Source
var DefaultCredentials = struct {
	BasicAuthUser string
	BasicAuthPass string
	BearerToken   string
	ApiKey        string
}{
	BasicAuthUser: "admin",
	BasicAuthPass: "admin",
	BearerToken:   "default-bearer-token",
	ApiKey:        "default-api-key",
}
View Source
var Headers []string

Functions

func EnforceSingleContentType

func EnforceSingleContentType(newContentType string)

func ExtractSpecFromJS

func ExtractSpecFromJS(bodyBytes []byte) []byte

func GenerateRequests

func GenerateRequests(input OpenapiParseInput) ([]string, error)

func HandleSchemaReference

func HandleSchemaReference(schema *openapi3.SchemaRef)

func PrintSpecInfo

func PrintSpecInfo(i openapi3.Info)

func SetScheme

func SetScheme(swaggerURL string) (scheme string)

func TrimHostScheme

func TrimHostScheme(apiTarget, fullUrlHost string) (host string)

TrimHostScheme trims the scheme from the provided URL if the '-T' flag is supplied to sj.

Types

type CheckSecDefsInput

type CheckSecDefsInput struct {
	Doc3          openapi3.T `json:"doc3"`
	BasicAuthUser string     `json:"basic_auth_user"`
	BasicAuthPass string     `json:"basic_auth_pass"`
	BearerToken   string     `json:"bearer_token"`
	ApiKey        string     `json:"api_key"`
}

type CheckSecDefsOutput

type CheckSecDefsOutput struct {
	ApiInQuery           bool                             `json:"api_in_query"`
	ApiKey               string                           `json:"api_key,omitempty"`
	ApiKeyName           string                           `json:"api_key_name,omitempty"`
	Headers              map[string][]string              `json:"headers"`
	SecuritySchemes      map[string]SecuritySchemeDetails `json:"security_schemes"`
	FoundBasicAuth       bool                             `json:"found_basic_auth"`
	FoundBearerToken     bool                             `json:"found_bearer_token"`
	FoundApiKey          bool                             `json:"found_api_key"`
	BasicAuthString      string                           `json:"basic_auth_string,omitempty"`
	HumanReadableSummary string                           `json:"human_readable_summary"`
	Examples             map[string]string                `json:"examples"`
	UsedCredentials      map[string]string                `json:"used_credentials"`
}

func CheckSecDefs

func CheckSecDefs(input CheckSecDefsInput) CheckSecDefsOutput

type Format

type Format string
const (
	FormatJSON Format = "json"
	FormatYAML Format = "yaml"
	FormatJS   Format = "js"
)

func DetectFormat

func DetectFormat(url string, headers http.Header, content []byte) (Format, error)

func DetectFormatFromContent

func DetectFormatFromContent(content []byte) Format

func DetectFormatFromHeader

func DetectFormatFromHeader(headers http.Header) Format

func DetectFormatFromURL

func DetectFormatFromURL(url string) Format

func ValidateFormat

func ValidateFormat(format string) (Format, error)

type OpenapiParseInput

type OpenapiParseInput struct {
	BodyBytes  []byte
	SwaggerURL string
	Format     string
}

type SchemaReference

type SchemaReference struct {
	Required   []string
	Type       string
	Properties struct {
		Property struct {
			Type      string
			Format    string
			Example   string
			Reference string
			XML       struct {
				Name      string
				Namespace string
				Prefix    string
				Attribute bool
				Wrapped   bool
			}
		}
	}
}

type SecuritySchemeDetails

type SecuritySchemeDetails struct {
	Type        string `json:"type"`
	Name        string `json:"name,omitempty"`
	In          string `json:"in,omitempty"`
	Scheme      string `json:"scheme,omitempty"`
	Description string `json:"description,omitempty"`
}

type SwaggerRequest

type SwaggerRequest struct {
	ApiKey      string
	ApiKeyName  string
	ApiInQuery  bool
	BasePath    string
	Body        map[string]any
	BodyData    []byte
	Def         *openapi3.T `json:"-"`
	Path        string
	Paths       []string
	Query       url.Values
	RawQuery    string
	ResultsJSON []string
	URL         url.URL
}

func (SwaggerRequest) AddParametersToRequest

func (s SwaggerRequest) AddParametersToRequest(op *openapi3.Operation) SwaggerRequest

This whole function needs to be refactored/cleaned up a bit

func (SwaggerRequest) BuildDefinedRequests

func (s SwaggerRequest) BuildDefinedRequests(method string, pathItem *openapi3.PathItem, op *openapi3.Operation) SwaggerRequest

func (SwaggerRequest) GetBasePath

func (s SwaggerRequest) GetBasePath() string

func (SwaggerRequest) IterateOverPaths

func (s SwaggerRequest) IterateOverPaths() SwaggerRequest

func (SwaggerRequest) SetParametersFromSchema

func (s SwaggerRequest) SetParametersFromSchema(param *openapi3.ParameterRef, location, schemaRef string, req *openapi3.RequestBodyRef, counter int) SwaggerRequest

type VerboseResult

type VerboseResult struct {
	Method  string `json:"method"`
	Preview string `json:"preview"`
	Status  int    `json:"status"`
	Target  string `json:"target"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL