Documentation
¶
Index ¶
- Constants
- func BuildRouter(doc *openapi3.T) (routers.Router, error)
- func MarshalScenarioToOpenAPI(title string, version string, scenarios ...*types.APIScenario) ([]byte, error)
- func ScenarioToOpenAPI(title string, version string, scenarios ...*types.APIScenario) *openapi3.T
- type APISpec
- func Parse(ctx context.Context, config *types.Configuration, data []byte, ...) (specs []*APISpec, updated []byte, doc *openapi3.T, err error)
- func ParseAPISpec(title string, method types.MethodType, path string, op *openapi3.Operation, ...) (specs []*APISpec)
- func ParseAPISpecWithDiscriminatorVariants(title string, method types.MethodType, path string, op *openapi3.Operation, ...) []*APISpec
- type DiscriminatorVariant
- type Property
- type Request
- type Response
Constants ¶
const MockServerBaseURL = "MOCK_SERVER_BASE_URL"
MockServerBaseURL constant
Variables ¶
This section is empty.
Functions ¶
func BuildRouter ¶
BuildRouter builds a legacy kin-openapi router from a parsed OpenAPI document. The router is used with openapi3filter.FindRoute for response schema validation.
func MarshalScenarioToOpenAPI ¶
func MarshalScenarioToOpenAPI(title string, version string, scenarios ...*types.APIScenario) ([]byte, error)
MarshalScenarioToOpenAPI converts open-api specs into json
func ScenarioToOpenAPI ¶
ScenarioToOpenAPI convert scenarios to open-api specs
Types ¶
type APISpec ¶
type APISpec struct {
Title string
ID string
Summary string
Description string
Path string
Method types.MethodType
Tags []string
Deprecated bool
ExternalDocsURL string
RequestBodyRequired bool
SecuritySchemes openapi3.SecuritySchemes
Request Request
Response Response
}
APISpec structure
func Parse ¶
func Parse(ctx context.Context, config *types.Configuration, data []byte, dataTemplate fuzz.DataTemplateRequest) (specs []*APISpec, updated []byte, doc *openapi3.T, err error)
Parse parses Open-API and generates api scenarios. Returns specs, the re-serialized spec bytes, the parsed openapi3.T document, and any error.
func ParseAPISpec ¶
func ParseAPISpec( title string, method types.MethodType, path string, op *openapi3.Operation, dataTemplate fuzz.DataTemplateRequest) (specs []*APISpec)
ParseAPISpec converts open-api operation to API specs
func ParseAPISpecWithDiscriminatorVariants ¶
func ParseAPISpecWithDiscriminatorVariants( title string, method types.MethodType, path string, op *openapi3.Operation, dataTemplate fuzz.DataTemplateRequest, ) []*APISpec
ParseAPISpecWithDiscriminatorVariants is like ParseAPISpec but generates one *APISpec per discriminator variant when a response body schema contains oneOf/anyOf. For schemas without discriminator variants, behavior is identical to ParseAPISpec.
func (*APISpec) BuildMockScenario ¶
func (api *APISpec) BuildMockScenario(dataTemplate fuzz.DataTemplateRequest) (*types.APIScenario, error)
BuildMockScenario builds api scenario from open-API spec
type DiscriminatorVariant ¶
DiscriminatorVariant holds a named variant schema from a oneOf/anyOf discriminator.
func DiscriminatorVariants ¶
func DiscriminatorVariants(schema *openapi3.Schema) []DiscriminatorVariant
DiscriminatorVariants returns named variants for a oneOf/anyOf schema. Uses discriminator.mapping keys when present; otherwise derives names from $ref paths or falls back to "variant0", "variant1", etc. Returns nil when the schema has no oneOf/anyOf branches.
type Property ¶
type Property struct {
Name string
Title string // schema title
Description string
Type string
SubType string
Enum []string
Const string // single allowed value (highest priority in Value())
Default string // default value used when no other value is generated
Example string // example value from OpenAPI spec
Min float64
Max float64
ExclusiveMin bool // minimum bound is exclusive (OAI 3.0)
ExclusiveMax bool // maximum bound is exclusive (OAI 3.0)
MultipleOf float64 // value must be a multiple of this (0 = no constraint)
UniqueItems bool // array items must be unique
MinProps uint64 // minimum number of object properties
MaxProps uint64 // maximum number of object properties (0 = no limit)
In string
Pattern string
Format string
Required bool
Deprecated bool
Nullable bool
ReadOnly bool
WriteOnly bool
Style string // parameter serialization style (form, simple, matrix, etc.)
Explode bool // expand array/object parameters into individual values
Children []Property
// contains filtered or unexported fields
}
Property structure