definitions

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	FileName           string             `yaml:"-" json:"-"`                                                // FileName is the name of the file that contains the definition
	FullPath           string             `yaml:"-" json:"-"`                                                // FullPath is the full path of the file that contains the definition
	Name               string             `yaml:"name" json:"name" validate:"required"`                      // Name is the name of the endpoint
	IsEnabled          bool               `yaml:"enabled" json:"enabled"`                                    // IsEnabled is a boolean that indicates if the endpoint is enabled (not contained in the definition)
	BaseUrl            string             `yaml:"base_url" json:"baseUrl" validate:"required"`               // BaseUrl is the base path of the endpoint
	ExcludedValidators []string           `yaml:"excluded_validators" json:"excludedValidators"`             // ExcludedValidators is a list of validators that should not be used for this endpoint
	QueryParameters    []query.Definition `yaml:"query_parameters" json:"queryParameters"`                   // QueryParameters are all the query parameters that should be added to the call
	Format             string             `yaml:"format" json:"format" validate:"required"`                  // Format is the response format of the
	Variables          []Variable         `yaml:"variables" json:"variables"`                                // Variables are all the variables that should be interpolated in the base url and the query parameters
	ResponseSchema     []SchemaEntry      `yaml:"response_schema" json:"responseSchema" validate:"required"` // ResponseSchema describes how the response should look like
}

Endpoint is the definition of an endpoint to test with all its query parameters, variables and its result schema

func Endpoints

func Endpoints() ([]Endpoint, error)

Endpoints uses parseDefinition to parse all the definitions found in the definitions/ directory. Directories and Files that start with the ignorePrefix are ignored.

type SchemaEntry

type SchemaEntry struct {
	Name       string        `yaml:"name" json:"name" validate:"required"`         // Name is the name of the field
	Type       string        `yaml:"type" json:"type" validate:"required"`         // Type is the type of the field
	Minimum    interface{}   `yaml:"min" json:"min"`                               // Minimum is the minimum allowed value of the field
	Maximum    interface{}   `yaml:"max" json:"max"`                               // Maximum is the maximum allowed value of the field
	IsRequired bool          `yaml:"required" json:"required" validate:"required"` // Required is true if the field is required (not null or not empty in case of an array)
	Fields     []SchemaEntry `yaml:"fields" json:"fields" validate:"required"`     // Fields describe the children of this field if the field is an object or array
}

SchemaEntry is a field definition of the response

type Variable

type Variable struct {
	Name       string   `yaml:"name" json:"name" validate:"required"`         // Name is the name of the variable
	IsConstant bool     `yaml:"constant" json:"constant" validate:"required"` // IsConstant is true if the value of the variable is constant or else false
	Values     []string `yaml:"values" json:"values" validate:"required"`     // Values are all the possible values of the variable (only 1 in case of a constant)
}

Variable describes a variable that should be interpolated in the base url and the query parameters

func (Variable) Value

func (v Variable) Value(index int) any

type VariableMap

type VariableMap map[string]any

VariableMap is a map of variables that will be generated from a collection of EndpointParameter and will be used when executing the go template

func (VariableMap) Env

func (m VariableMap) Env(key string) string

Env is a function that returns the value of a given environment variable

func (VariableMap) Now

func (m VariableMap) Now(format string) string

Now is a function that returns the current time in the given format (see Time.Format)

Jump to

Keyboard shortcuts

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