specutil

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinSpecBodySize is the minimum body size to consider for spec detection.
	MinSpecBodySize = 50
	// MaxSpecBodySize is the maximum body size to consider for spec detection (10 MB).
	MaxSpecBodySize = 10 * 1024 * 1024
)

Variables

This section is empty.

Functions

func IsSpecContentType

func IsSpecContentType(ct string) bool

IsSpecContentType returns true if the content-type header suggests API spec content. XML types are included for WSDL/SOAP descriptions; they are broad, so the actual gate is DetectSpecType's strict WSDL marker check — a plain XML response (SVG, RSS, sitemap) passes this pre-filter but resolves to Unknown and is dropped.

func ParseAndFeed

func ParseAndFeed(data []byte, baseURL string, service *httpmsg.Service, feeder modkit.RequestFeeder) (int, error)

ParseAndFeed detects spec type, parses endpoints, and feeds them via the feeder. Returns the count of endpoints fed and any error.

func ParseSpec

func ParseSpec(data []byte, baseURL string, service *httpmsg.Service) ([]*httpmsg.HttpRequestResponse, error)

ParseSpec parses a spec of the given type and returns all extracted endpoints. If specType is Unknown, it auto-detects. Each endpoint is optionally stamped with the given service.

func ParseSpecTyped

func ParseSpecTyped(specType SpecType, data []byte, baseURL string, service *httpmsg.Service) ([]*httpmsg.HttpRequestResponse, error)

ParseSpecTyped parses a spec of a known type, skipping detection.

Types

type SpecType

type SpecType int

SpecType represents the type of API specification.

const (
	Unknown SpecType = iota
	OpenAPI
	Postman
	WSDL
)

func DetectSpecType

func DetectSpecType(data []byte) SpecType

DetectSpecType determines whether data is an OpenAPI/Swagger, Postman, or WSDL/SOAP service description. WSDL is checked first: it is XML, disjoint from the JSON/YAML specs, and its marker gate is strict (definitions + WSDL + SOAP namespaces), so it cannot be confused with the others.

func (SpecType) Label

func (t SpecType) Label() string

Label returns a human-readable name for the spec type, used in the "discovered a spec" progress notices so a WSDL isn't announced as an OpenAPI spec.

Jump to

Keyboard shortcuts

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