parser

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreSchemasEqual

func AreSchemasEqual(a, b Schema) bool

AreSchemasEqual checks if two schemas are semantically equivalent

func GetPathParameters

func GetPathParameters(path, template string) map[string]string

GetPathParameters extracts parameters from a path given its template

Types

type AuthDetector

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

AuthDetector analyzes API traffic to detect authentication schemes

func NewAuthDetector

func NewAuthDetector() *AuthDetector

NewAuthDetector creates a new auth detector

func (*AuthDetector) AnalyzeTransaction

func (d *AuthDetector) AnalyzeTransaction(req *http.Request, resp *http.Response)

AnalyzeTransaction analyzes an API transaction for authentication information

func (*AuthDetector) GetAuthSchemes

func (d *AuthDetector) GetAuthSchemes() []AuthScheme

GetAuthSchemes returns all detected authentication schemes

type AuthScheme

type AuthScheme struct {
	Type        string // http, apiKey, oauth2, openIdConnect
	Scheme      string // basic, bearer, digest (for http type)
	Description string
	In          string // header, query, cookie (for apiKey type)
	Name        string // header name or query parameter name
	Format      string // JWT, etc. (for bearer token)
	Example     string
}

AuthScheme represents an authentication scheme

type PathPatternDetector

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

PathPatternDetector detects path patterns from observed URLs

func NewPathPatternDetector

func NewPathPatternDetector() *PathPatternDetector

NewPathPatternDetector creates a new path pattern detector

func (*PathPatternDetector) AddPath

func (d *PathPatternDetector) AddPath(path string)

AddPath adds a path to the detector for analysis

func (*PathPatternDetector) AnalyzePatterns

func (d *PathPatternDetector) AnalyzePatterns()

AnalyzePatterns analyzes all observed paths to detect patterns

func (*PathPatternDetector) GetPatterns

func (d *PathPatternDetector) GetPatterns() map[string]string

GetPatterns returns all detected patterns

func (*PathPatternDetector) TemplatizePath

func (d *PathPatternDetector) TemplatizePath(path string) string

TemplatizePath converts a concrete path to a templated path if it matches a pattern

type Schema

type Schema struct {
	Type         string            `json:"type,omitempty"`
	Format       string            `json:"format,omitempty"`
	Properties   map[string]Schema `json:"properties,omitempty"`
	Items        *Schema           `json:"items,omitempty"`
	Required     []string          `json:"required,omitempty"`
	Enum         []interface{}     `json:"enum,omitempty"`
	Example      interface{}       `json:"example,omitempty"`
	AllOf        []Schema          `json:"allOf,omitempty"`
	OneOf        []Schema          `json:"oneOf,omitempty"`
	AnyOf        []Schema          `json:"anyOf,omitempty"`
	Not          *Schema           `json:"not,omitempty"`
	Default      interface{}       `json:"default,omitempty"`
	Nullable     bool              `json:"nullable,omitempty"`
	ReadOnly     bool              `json:"readOnly,omitempty"`
	WriteOnly    bool              `json:"writeOnly,omitempty"`
	XML          map[string]string `json:"xml,omitempty"`
	ExternalDocs map[string]string `json:"externalDocs,omitempty"`
	Deprecated   bool              `json:"deprecated,omitempty"`
}

Schema represents an OpenAPI schema

func ApplyTypeInference

func ApplyTypeInference(schema Schema, samples []interface{}, maxSamples int) Schema

ApplyTypeInference enhances an existing schema with improved type detection

type SchemaMerger

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

SchemaMerger merges multiple schemas into a single comprehensive schema

func NewSchemaMerger

func NewSchemaMerger() *SchemaMerger

NewSchemaMerger creates a new schema merger

func (*SchemaMerger) AddSchema

func (m *SchemaMerger) AddSchema(path, method string, schema Schema)

AddSchema adds a schema to the merger for the given path and method

func (*SchemaMerger) MergeSchemas

func (m *SchemaMerger) MergeSchemas(path, method string) Schema

MergeSchemas merges all schemas for the given path and method

type TypeInferrer

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

TypeInferrer analyzes values to determine their types more intelligently

func NewTypeInferrer

func NewTypeInferrer(maxSamples int) *TypeInferrer

NewTypeInferrer creates a new type inference engine

func (*TypeInferrer) AddSample

func (t *TypeInferrer) AddSample(path string, value interface{})

AddSample adds a new sample value for analysis

func (*TypeInferrer) InferSchema

func (t *TypeInferrer) InferSchema(path string) *Schema

InferSchema generates a refined schema based on collected samples

func (*TypeInferrer) ResetSamples

func (t *TypeInferrer) ResetSamples()

ResetSamples clears all collected samples

Jump to

Keyboard shortcuts

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