Documentation ¶
Index ¶
- func ApplyResponseOverlay(response Response, data interface{}) error
- func ExpandOperationIDs(document *loads.Document)
- func ExpandPaths(document *loads.Document, basePath string)
- func StubSchema(schema spec.Schema) interface{}
- type Operation
- type Overlay
- type PathItem
- type Response
- type StubGenerator
- type StubGeneratorOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyResponseOverlay ¶
ApplyResponseOverlay expects data to be passed by reference. The response overlay will be applied by merging/overriding data.
func ExpandOperationIDs ¶
ExpandOperationIDs the operationId field can be omitted in the spec. Codegen tools will automatically generate a default value for this field but go-openapi does not. ExpandOperationIDs will expand empty operationId fields into a useful name for usage in error/logging.
func ExpandPaths ¶
ExpandPaths modifies all the paths in the openapi document by prefixing them with the basePath
func StubSchema ¶
StubSchema returns a struct that matches the openapi schema with values filled with randomly generated data
Types ¶
type Overlay ¶
func EmptyOverlay ¶
func EmptyOverlay() Overlay
EmptyOverlay is used when the user doesn't provide and overlay file. it's just used inplace of a nil value.
func LoadOverlayFile ¶
LoadOverlayFile reads an overlay.yaml file into an Overlay struct
type StubGenerator ¶
type StubGenerator struct {
// contains filtered or unexported fields
}
StubGenerator is the main type used to interact with this library's feature set
func NewStubGenerator ¶
func NewStubGenerator(urlOrPath string, options StubGeneratorOptions) (*StubGenerator, error)
NewStubGenerator loads an OpenAPI spec from the given url/path and returns a StubGenerator
func (*StubGenerator) FindOperation ¶
func (stub *StubGenerator) FindOperation(httpPath string, httpMethod string) (*spec.Operation, error)
FindOperation returns the best matching OpenAPI operation from the Spec given an HTTP Request
func (*StubGenerator) FindResponse ¶
FindResponse returns either the default response from an operation or the response with the lowest HTTP status code (i.e. success codes over error codes)
func (*StubGenerator) StubResponse ¶
func (stub *StubGenerator) StubResponse(path string, method string) (interface{}, error)
StubResponse returns data that matches the schema for a given Operation in the OpenAPI spec. The Operation is determined by a path and method
type StubGeneratorOptions ¶
StubGeneratorOptions that can configure the stub generator