Documentation
¶
Index ¶
- Constants
- func IsSpecContentType(ct string) bool
- func ParseAndFeed(data []byte, baseURL string, service *httpmsg.Service, ...) (int, error)
- func ParseSpec(data []byte, baseURL string, service *httpmsg.Service) ([]*httpmsg.HttpRequestResponse, error)
- func ParseSpecTyped(specType SpecType, data []byte, baseURL string, service *httpmsg.Service) ([]*httpmsg.HttpRequestResponse, error)
- type SpecType
Constants ¶
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 ¶
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.
func DetectSpecType ¶
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.