oapi

package
v0.0.0-...-079c800 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MockServerBaseURL = "MOCK_SERVER_BASE_URL"

MockServerBaseURL constant

Variables

This section is empty.

Functions

func MarshalScenarioToOpenAPI

func MarshalScenarioToOpenAPI(title string, version string, scenarios ...*types.APIScenario) ([]byte, error)

MarshalScenarioToOpenAPI converts open-api specs into json

func ScenarioToOpenAPI

func ScenarioToOpenAPI(title string, version string, scenarios ...*types.APIScenario) *openapi3.T

ScenarioToOpenAPI convert scenarios to open-api specs

Types

type APISpec

type APISpec struct {
	Title           string
	ID              string
	Description     string
	Path            string
	Method          types.MethodType
	SecuritySchemes openapi3.SecuritySchemes
	Request         Request
	Response        Response
}

APISpec structure

func Parse

func Parse(ctx context.Context, data []byte, dataTemplate fuzz.DataTemplateRequest) (specs []*APISpec, err error)

Parse parses Open-API and generates api scenarios

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 (*APISpec) BuildMockScenario

func (api *APISpec) BuildMockScenario(dataTemplate fuzz.DataTemplateRequest) (*types.APIScenario, error)

BuildMockScenario builds api scenario from open-API spec

type Property

type Property struct {
	Name        string
	Description string
	Type        string
	SubType     string
	Enum        []string
	Min         float64
	Max         float64
	In          string
	Pattern     string
	Format      string
	Required    bool
	Children    []Property
	// contains filtered or unexported fields
}

Property structure

func (*Property) String

func (prop *Property) String() string

func (*Property) Value

func (prop *Property) Value(dataTemplate fuzz.DataTemplateRequest) any

Value of the property

type Request

type Request struct {
	PathParams  []Property
	QueryParams []Property
	Headers     []Property
	Body        []Property
}

Request Body

type Response

type Response struct {
	ContentType string
	StatusCode  int
	Headers     []Property
	Body        []Property
}

Response Body

Jump to

Keyboard shortcuts

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