parser

package
v0.22.0-beta Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParameterInBody   = "body"
	ParameterInCookie = openapi3.ParameterInCookie
	ParameterInPath   = openapi3.ParameterInPath
	ParameterInHeader = openapi3.ParameterInHeader
	ParameterInQuery  = openapi3.ParameterInQuery
)

Variables

This section is empty.

Functions

func FillHttpParam

func FillHttpParam(param *Param) bool

Fill parser.Param.Value based on parser.Param.Type (type considers first value of the list)

func FillHttpParams

func FillHttpParams(params *[]Param)

concurrently fills http params

Types

type DocHttpParams

type DocHttpParams struct {
	// Request Information
	HttpMethod string
	Url        string
	Path       string

	// Security Requirements
	Security []map[string][]string

	// Request Params
	BodyParams   []Param
	CookieParams []Param
	HeaderParams []Param
	PathParams   []Param
	QueryParams  []Param

	// Response Params
	ResponseParams []Param
}

DocHttpParams holds useful information about payloads and security requirements from the docs

func (*DocHttpParams) String

func (d *DocHttpParams) String() string

type DocInterface

type DocInterface interface {
	SetDoc(doc interface{}) error
	GetDocHttpParams() []*DocHttpParams
	SetDocHttpParams() error
	SetBaseUrl(baseurl string) error
	GetBaseUrl() *string
	FuzzDocHttpParams()
}

type OpenApi

type OpenApi struct {
	BaseUrl       *string
	DocHttpParams []*DocHttpParams
	// contains filtered or unexported fields
}

func (*OpenApi) AssignParamsToSlices

func (o *OpenApi) AssignParamsToSlices(params openapi3.Parameters, httpPathParams, cookieParams, headerParams, queryParams, bodyParams *[]Param)

assigns openapi3 params to their respective params (path, cookie, header, query)

func (*OpenApi) FuzzDocHttpParams

func (o *OpenApi) FuzzDocHttpParams()

Fuzz Doc Http Param Values based on type

func (*OpenApi) GetBaseUrl

func (o *OpenApi) GetBaseUrl() *string

Get Base Url Warning: This method should be invoked only after SetBaseUrl method

func (*OpenApi) GetDocHttpParams

func (o *OpenApi) GetDocHttpParams() []*DocHttpParams

For interface usage: to retrieve DocHttpParams value

func (*OpenApi) HttpOperationToDocHttpParams

func (o *OpenApi) HttpOperationToDocHttpParams(HttpMethod, path string, httpOperation *openapi3.Operation, pathParams []Param) []*DocHttpParams

func (*OpenApi) SetBaseUrl

func (o *OpenApi) SetBaseUrl(baseUrl string) error

Set BaseUrl for OpenApi struct

func (*OpenApi) SetDoc

func (o *OpenApi) SetDoc(doc interface{}) error

func (*OpenApi) SetDocHttpParams

func (o *OpenApi) SetDocHttpParams() error

for interface usage: configure DocHttpParams value

type Param

type Param struct {
	Name        string
	In          string
	Required    bool
	Type        []string // string, integer, boolean, object, array
	Value       interface{}
	ContentType string
}

func (*Param) String

func (p *Param) String() string

type Parser

type Parser struct {
	Version string
	BaseUrl string

	IsOpenApi             bool // else Swagger
	IsExternalRefsAllowed bool

	// OAS validation opts
	DisableExamplesValidation       bool
	DisableSchemaDefaultsValidation bool
	DisableSchemaPatternValidation  bool

	// Parsed Docs
	Doc DocInterface
}

func NewParser

func NewParser(isExternalRefsAllowed, disableExamplesValidation, disableSchemaDefaultsValidation, disableSchemaPatternValidation bool) *Parser

func (*Parser) FuzzDocHttpParams

func (p *Parser) FuzzDocHttpParams()

func (*Parser) Parse

func (p *Parser) Parse(filename string, isUrl bool) (err error)

Parses and Populates file contents to Parser struct fields. Note: URLs only support JSON content for now.

type Swagger

type Swagger struct {
	// contains filtered or unexported fields
}

func (*Swagger) FuzzDocHttpParams

func (s *Swagger) FuzzDocHttpParams()

func (*Swagger) GetBaseUrl

func (s *Swagger) GetBaseUrl() *string

func (*Swagger) GetDocHttpParams

func (s *Swagger) GetDocHttpParams() []*DocHttpParams

func (*Swagger) SetBaseUrl

func (s *Swagger) SetBaseUrl(baseUrl string) error

func (*Swagger) SetDoc

func (s *Swagger) SetDoc(doc interface{}) error

func (*Swagger) SetDocHttpParams

func (s *Swagger) SetDocHttpParams() error

Jump to

Keyboard shortcuts

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