Documentation
¶
Overview ¶
Package parser provides parsers for various API specification formats
Package parser provides parsers for various API specification formats
Index ¶
- Variables
- func DetectInputType(filePath string) types.InputType
- func NormalizeMethod(method string) string
- func NormalizePath(path string) string
- func ParseEndpointList(list, baseURL string) ([]types.Endpoint, error)
- func ParseEndpointString(s, baseURL string) (types.Endpoint, error)
- func ParseMultiple(files []string, baseURL string) ([]types.Endpoint, error)
- type BurpExport
- type BurpItem
- type BurpParser
- type GraphQLArg
- type GraphQLDirective
- type GraphQLEnumValue
- type GraphQLField
- type GraphQLInputField
- type GraphQLOperation
- type GraphQLParser
- type GraphQLSchema
- type GraphQLType
- type GraphQLTypeRef
- type HAR
- type HARContent
- type HARCookie
- type HARCreator
- type HAREntry
- type HARLog
- type HARNameValue
- type HARParser
- type HARPostData
- type HARRequest
- type HARResponse
- type IntrospectionResponse
- type OpenAPIParser
- type Parser
- type PostmanAuth
- type PostmanBody
- type PostmanBodyOpts
- type PostmanCollection
- type PostmanHeader
- type PostmanInfo
- type PostmanItem
- type PostmanKeyValue
- type PostmanParser
- type PostmanRequest
- type PostmanURL
- type PostmanVar
- type RawParser
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedFormat = errors.New("unsupported file format") ErrInvalidInput = errors.New("invalid input") ErrFileNotFound = errors.New("file not found") ErrParseFailed = errors.New("failed to parse input") )
Errors
Functions ¶
func DetectInputType ¶
DetectInputType detects the input type from file extension and content
func NormalizeMethod ¶
NormalizeMethod normalizes HTTP method to uppercase
func ParseEndpointList ¶
ParseEndpointList parses a comma-separated list of endpoints
func ParseEndpointString ¶
ParseEndpointString parses a single endpoint string
Types ¶
type BurpExport ¶
BurpExport represents a Burp Suite XML export
type BurpItem ¶
type BurpItem struct {
Time string `xml:"time"`
URL string `xml:"url"`
Host string `xml:"host"`
Port string `xml:"port"`
Protocol string `xml:"protocol"`
Method string `xml:"method"`
Path string `xml:"path"`
Extension string `xml:"extension"`
Request string `xml:"request"`
RequestBase64 bool `xml:"request,attr"`
Status string `xml:"status"`
ResponseLength string `xml:"responselength"`
MimeType string `xml:"mimetype"`
Response string `xml:"response"`
ResponseBase64 bool `xml:"response,attr"`
Comment string `xml:"comment"`
}
BurpItem represents a single request/response
type BurpParser ¶
type BurpParser struct {
// contains filtered or unexported fields
}
BurpParser parses Burp Suite XML exports
func NewBurpParser ¶
func NewBurpParser(filePath, baseURL string) (*BurpParser, error)
NewBurpParser creates a new Burp parser
type GraphQLArg ¶
type GraphQLArg struct {
Name string `json:"name"`
Description string `json:"description"`
Type GraphQLTypeRef `json:"type"`
DefaultValue string `json:"defaultValue"`
}
GraphQLArg represents a field argument
type GraphQLDirective ¶
type GraphQLDirective struct {
Name string `json:"name"`
Description string `json:"description"`
Locations []string `json:"locations"`
Args []GraphQLArg `json:"args"`
}
GraphQLDirective represents a directive
type GraphQLEnumValue ¶
type GraphQLEnumValue struct {
Name string `json:"name"`
Description string `json:"description"`
IsDeprecated bool `json:"isDeprecated"`
}
GraphQLEnumValue represents an enum value
type GraphQLField ¶
type GraphQLField struct {
Name string `json:"name"`
Description string `json:"description"`
Args []GraphQLArg `json:"args"`
Type GraphQLTypeRef `json:"type"`
IsDeprecated bool `json:"isDeprecated"`
}
GraphQLField represents a field in a GraphQL type
type GraphQLInputField ¶
type GraphQLInputField struct {
Name string `json:"name"`
Description string `json:"description"`
Type GraphQLTypeRef `json:"type"`
DefaultValue string `json:"defaultValue"`
}
GraphQLInputField represents an input field
type GraphQLOperation ¶
type GraphQLOperation struct {
Name string
Type string // query, mutation, subscription
Arguments []GraphQLArg
ReturnType string
Description string
Depth int
}
GraphQLOperation represents a GraphQL operation
type GraphQLParser ¶
type GraphQLParser struct {
// contains filtered or unexported fields
}
GraphQLParser parses GraphQL schemas via introspection
func NewGraphQLParser ¶
func NewGraphQLParser(endpoint string, baseURL string) (*GraphQLParser, error)
NewGraphQLParser creates a new GraphQL parser
func (*GraphQLParser) GetOperations ¶
func (p *GraphQLParser) GetOperations() []GraphQLOperation
GetOperations returns all GraphQL operations
func (*GraphQLParser) GetSchema ¶
func (p *GraphQLParser) GetSchema() *GraphQLSchema
GetSchema returns the parsed schema
func (*GraphQLParser) Parse ¶
func (p *GraphQLParser) Parse() ([]types.Endpoint, error)
Parse performs introspection and returns endpoints
func (*GraphQLParser) SetHeaders ¶
func (p *GraphQLParser) SetHeaders(headers map[string]string)
SetHeaders sets custom headers for requests
func (*GraphQLParser) Type ¶
func (p *GraphQLParser) Type() types.InputType
Type returns the input type
type GraphQLSchema ¶
type GraphQLSchema struct {
Types []GraphQLType `json:"types"`
QueryType *GraphQLTypeRef `json:"queryType"`
MutationType *GraphQLTypeRef `json:"mutationType"`
Subscriptions *GraphQLTypeRef `json:"subscriptionType"`
Directives []GraphQLDirective `json:"directives"`
}
GraphQLSchema represents a GraphQL schema
type GraphQLType ¶
type GraphQLType struct {
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
Fields []GraphQLField `json:"fields"`
InputFields []GraphQLInputField `json:"inputFields"`
Interfaces []GraphQLTypeRef `json:"interfaces"`
EnumValues []GraphQLEnumValue `json:"enumValues"`
PossibleTypes []GraphQLTypeRef `json:"possibleTypes"`
}
GraphQLType represents a GraphQL type
type GraphQLTypeRef ¶
type GraphQLTypeRef struct {
Kind string `json:"kind"`
Name string `json:"name"`
OfType *GraphQLTypeRef `json:"ofType"`
}
GraphQLTypeRef represents a reference to a type
type HARContent ¶
type HARContent struct {
Size int `json:"size"`
MimeType string `json:"mimeType"`
Text string `json:"text,omitempty"`
}
HARContent represents response content
type HARCookie ¶
type HARCookie struct {
Name string `json:"name"`
Value string `json:"value"`
Path string `json:"path"`
Domain string `json:"domain"`
HTTPOnly bool `json:"httpOnly"`
Secure bool `json:"secure"`
}
HARCookie represents a cookie
type HARCreator ¶
HARCreator represents the creator
type HAREntry ¶
type HAREntry struct {
StartedDateTime string `json:"startedDateTime"`
Request HARRequest `json:"request"`
Response HARResponse `json:"response"`
}
HAREntry represents a single request/response pair
type HARLog ¶
type HARLog struct {
Version string `json:"version"`
Creator HARCreator `json:"creator"`
Entries []HAREntry `json:"entries"`
}
HARLog represents the log section
type HARNameValue ¶
HARNameValue represents a name-value pair
type HARParser ¶
type HARParser struct {
// contains filtered or unexported fields
}
HARParser parses HAR (HTTP Archive) files
func NewHARParser ¶
NewHARParser creates a new HAR parser
type HARPostData ¶
type HARPostData struct {
MimeType string `json:"mimeType"`
Text string `json:"text"`
Params []HARNameValue `json:"params,omitempty"`
}
HARPostData represents POST data
type HARRequest ¶
type HARRequest struct {
Method string `json:"method"`
URL string `json:"url"`
HTTPVersion string `json:"httpVersion"`
Headers []HARNameValue `json:"headers"`
QueryString []HARNameValue `json:"queryString"`
Cookies []HARCookie `json:"cookies"`
PostData *HARPostData `json:"postData,omitempty"`
}
HARRequest represents a request
type HARResponse ¶
type HARResponse struct {
Status int `json:"status"`
StatusText string `json:"statusText"`
HTTPVersion string `json:"httpVersion"`
Headers []HARNameValue `json:"headers"`
Content HARContent `json:"content"`
}
HARResponse represents a response
type IntrospectionResponse ¶
type IntrospectionResponse struct {
Data struct {
Schema GraphQLSchema `json:"__schema"`
} `json:"data"`
Errors []struct {
Message string `json:"message"`
} `json:"errors"`
}
IntrospectionResponse represents the introspection query response
type OpenAPIParser ¶
type OpenAPIParser struct {
// contains filtered or unexported fields
}
OpenAPIParser parses OpenAPI/Swagger specifications
func NewOpenAPIParser ¶
func NewOpenAPIParser(filePath, baseURL string) (*OpenAPIParser, error)
NewOpenAPIParser creates a new OpenAPI parser
func (*OpenAPIParser) Parse ¶
func (p *OpenAPIParser) Parse() ([]types.Endpoint, error)
Parse parses the OpenAPI specification
func (*OpenAPIParser) Type ¶
func (p *OpenAPIParser) Type() types.InputType
Type returns the input type
type Parser ¶
type Parser interface {
// Parse parses the input and returns a slice of endpoints
Parse() ([]types.Endpoint, error)
// Type returns the input type
Type() types.InputType
}
Parser defines the interface for API specification parsers
type PostmanAuth ¶
type PostmanAuth struct {
Type string `json:"type"`
Bearer []PostmanKeyValue `json:"bearer,omitempty"`
Basic []PostmanKeyValue `json:"basic,omitempty"`
APIKey []PostmanKeyValue `json:"apikey,omitempty"`
}
PostmanAuth represents authentication
type PostmanBody ¶
type PostmanBody struct {
Mode string `json:"mode"` // raw, formdata, urlencoded
Raw string `json:"raw"`
URLEncoded []PostmanKeyValue `json:"urlencoded"`
FormData []PostmanKeyValue `json:"formdata"`
Options *PostmanBodyOpts `json:"options"`
}
PostmanBody represents a request body
type PostmanBodyOpts ¶
type PostmanBodyOpts struct {
Raw struct {
Language string `json:"language"`
} `json:"raw"`
}
PostmanBodyOpts represents body options
type PostmanCollection ¶
type PostmanCollection struct {
Info PostmanInfo `json:"info"`
Item []PostmanItem `json:"item"`
Variable []PostmanVar `json:"variable"`
Auth *PostmanAuth `json:"auth,omitempty"`
}
PostmanCollection represents a Postman collection
type PostmanHeader ¶
type PostmanHeader struct {
Key string `json:"key"`
Value string `json:"value"`
Description string `json:"description"`
Disabled bool `json:"disabled"`
}
PostmanHeader represents a header
type PostmanInfo ¶
type PostmanInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Schema string `json:"schema"`
}
PostmanInfo represents collection info
type PostmanItem ¶
type PostmanItem struct {
Name string `json:"name"`
Description string `json:"description"`
Request *PostmanRequest `json:"request,omitempty"`
Item []PostmanItem `json:"item,omitempty"` // For folders
Auth *PostmanAuth `json:"auth,omitempty"`
}
PostmanItem represents an item (request or folder)
type PostmanKeyValue ¶
type PostmanKeyValue struct {
Key string `json:"key"`
Value string `json:"value"`
Description string `json:"description"`
Disabled bool `json:"disabled"`
Type string `json:"type"`
}
PostmanKeyValue represents a key-value pair
type PostmanParser ¶
type PostmanParser struct {
// contains filtered or unexported fields
}
PostmanParser parses Postman collection files
func NewPostmanParser ¶
func NewPostmanParser(filePath, baseURL string) (*PostmanParser, error)
NewPostmanParser creates a new Postman parser
func (*PostmanParser) Parse ¶
func (p *PostmanParser) Parse() ([]types.Endpoint, error)
Parse parses the Postman collection
func (*PostmanParser) Type ¶
func (p *PostmanParser) Type() types.InputType
Type returns the input type
type PostmanRequest ¶
type PostmanRequest struct {
Method string `json:"method"`
URL PostmanURL `json:"url"`
Header []PostmanHeader `json:"header"`
Body *PostmanBody `json:"body,omitempty"`
Description string `json:"description"`
Auth *PostmanAuth `json:"auth,omitempty"`
}
PostmanRequest represents a request
type PostmanURL ¶
type PostmanURL struct {
Raw string `json:"raw"`
Protocol string `json:"protocol"`
Host []string `json:"host"`
Path []string `json:"path"`
Query []PostmanKeyValue `json:"query"`
Variable []PostmanKeyValue `json:"variable"`
}
PostmanURL represents a URL (can be string or object)
func (*PostmanURL) UnmarshalJSON ¶
func (u *PostmanURL) UnmarshalJSON(data []byte) error
UnmarshalJSON handles both string and object URL formats
type PostmanVar ¶
type PostmanVar struct {
Key string `json:"key"`
Value string `json:"value"`
Type string `json:"type"`
}
PostmanVar represents a collection variable
type RawParser ¶
type RawParser struct {
// contains filtered or unexported fields
}
RawParser parses raw URLs and endpoint definitions
func NewRawParser ¶
NewRawParser creates a new raw URL parser
func NewRawParserFromFile ¶
NewRawParserFromFile creates a parser from a file containing URLs