api

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyItems = errors.New("empty items in array")

ErrEmptyItems -.

View Source
var ErrEmptyRequireField = errors.New("empty require field")

ErrEmptyRequireField -.

Functions

func IsPathMatchTemplate added in v0.6.0

func IsPathMatchTemplate(path, pathTemplate string) bool

IsPathMatchTemplate returns true if path matches template

func ParseArrayExample

func ParseArrayExample(data any) ([]any, error)

func ParseObjectExample

func ParseObjectExample(data any) (map[string]any, error)

Types

type API

type API struct {
	Operations []Operation
}

API -.

func (API) FindResponse

func (a API) FindResponse(params FindResponseParams) (Response, error)

FindResponse -.

type ArrayExampleError

type ArrayExampleError struct {
	Data any
}

ArrayExampleError -.

func (*ArrayExampleError) Error

func (e *ArrayExampleError) Error() string

type ArraySchema

type ArraySchema struct {
	Type    Schema
	Example []interface{}
}

ArraySchema -.

func (ArraySchema) ExampleValue

func (a ArraySchema) ExampleValue() any

ExampleValue -.

type BooleanSchema

type BooleanSchema struct {
	Example bool
}

BooleanSchema -.

func (BooleanSchema) ExampleValue

func (b BooleanSchema) ExampleValue() any

ExampleValue -.

type Builder

type Builder struct {
	OpenAPI    openapi.OpenAPI
	Operations []Operation
}

func (*Builder) Add

func (b *Builder) Add(path, method string, o *openapi.Operation) error

Add -.

func (*Builder) Build

func (b *Builder) Build() (API, error)

Build -.

func (*Builder) Set

func (b *Builder) Set(path, method string, o *openapi.Operation) (Operation, error)

Set -.

type FakerSchema

type FakerSchema struct {
	Example any
}

FakerSchema -.

func (FakerSchema) ExampleValue

func (f FakerSchema) ExampleValue() any

ExampleValue -.

type FieldType

type FieldType struct {
	Required bool
	Type     string
}

FieldType -.

type FindResponseError

type FindResponseError struct {
	Method string
	Path   string
}

FindResponseError -.

func (*FindResponseError) Error

func (e *FindResponseError) Error() string

Error -.

type FindResponseParams

type FindResponseParams struct {
	Path      string
	Method    string
	Body      io.ReadCloser
	MediaType string
}

FindResponseParams -.

type FloatSchema

type FloatSchema struct {
	Example float64
}

FloatSchema -.

func (FloatSchema) ExampleValue

func (f FloatSchema) ExampleValue() any

ExampleValue -.

type IntSchema

type IntSchema struct {
	Example int64
}

IntSchema -.

func (IntSchema) ExampleValue

func (i IntSchema) ExampleValue() any

ExampleValue -.

type ObjectExampleError

type ObjectExampleError struct {
	Data any
}

ObjectExampleError -.

func (*ObjectExampleError) Error

func (e *ObjectExampleError) Error() string

Error -.

type ObjectSchema

type ObjectSchema struct {
	Properties map[string]Schema
	Example    map[string]any
}

ObjectSchema -.

func (ObjectSchema) ExampleValue

func (o ObjectSchema) ExampleValue() any

ExampleValue -.

type Operation

type Operation struct {
	Method    string
	Path      string
	Body      map[string]FieldType
	Responses []Response
}

Operation -.

type Response

type Response struct {
	StatusCode int
	MediaType  string
	Schema     Schema
	Example    any
	Examples   map[string]any
}

Response -.

func (Response) ExampleValue

func (r Response) ExampleValue(key string) any

ExampleValue -.

type Schema

type Schema interface {
	ExampleValue() any
}

Schema -.

type SchemaTypeError

type SchemaTypeError struct {
	SchemaType string
}

SchemaTypeError -.

func (*SchemaTypeError) Error

func (e *SchemaTypeError) Error() string

type StringSchema

type StringSchema struct {
	Example string
}

StringSchema -.

func (StringSchema) ExampleValue

func (s StringSchema) ExampleValue() any

ExampleValue -.

Jump to

Keyboard shortcuts

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