requestgen

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package requestgen turns a normalized OpenAPI spec into concrete HTTP requests, generating example values from schemas (ported/extended from BishopFox/sj).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateExample

func GenerateExample(sch *openapi3.Schema, opts Options, visited map[*openapi3.Schema]bool) any

GenerateExample recursively produces an example value for a schema.

func ResolveBase

func ResolveBase(s *spec.Spec, opts Options) string

ResolveBase returns the effective base URL Build will use: the explicit opts.BaseURL when set, otherwise the spec's server URL, trimmed of any trailing slash. Callers use it to avoid redundant re-scans against a base that matches the one already used.

Types

type Options

type Options struct {
	TestString  string
	CustomURL   string
	CustomEmail string
	CustomDate  string
	BaseURL     string // overrides server URL when set
	IncludeRisk bool   // include non-GET methods
}

Options controls value generation.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns sane defaults.

type Request

type Request struct {
	Method      string            `json:"method"`
	URL         string            `json:"url"`
	Path        string            `json:"path"` // template path (for grouping)
	Body        string            `json:"body,omitempty"`
	ContentType string            `json:"content_type,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
}

Request is a concrete generated HTTP request.

func Build

func Build(s *spec.Spec, opts Options) []Request

Build generates one request per operation in the spec.

Jump to

Keyboard shortcuts

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