gdutils

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 34 Imported by: 1

README

gdutils Go Reference Coverage

GDUTILS

Simple library with methods useful for e2e testing of HTTP(s) API using JSON/YAML/XML.

Downloading

go get github.com/pawelWritesCode/gdutils

Skeleton that allows to write E2E tests covering any HTTP API using godog & gdutils almost instantly with minimal configuration. https://github.com/pawelWritesCode/godog-http-api

Simple usage:
ac := gdutils.NewDefaultAPIContext(false, "")

if err := ac.RequestPrepare("GET", "https://random-d.uk/api/v2/list", "DUCK_GIFS_LIST"); err != nil {
	return err
}

if err := ac.RequestSend("DUCK_GIFS_LIST"); err != nil {
    return err
}

if err := ac.AssertStatusCodeIs(200); err != nil {
    return err
}

if err := ac.AssertResponseFormatIs(format.JSON); err != nil {
    return err
}

if err := ac.AssertNodeIsType(format.JSON, "$.gifs", types.Array); err != nil {
    return err
}

Available methods:
NAME DESCRIPTION
Sending HTTP(s) requests:
RequestSendWithBodyAndHeaders Sends HTTP(s) request with provided body and headers.
RequestPrepare Prepare HTTP(s) request
RequestSetHeaders Sets provided headers for previously prepared request
RequestSetForm Sets provided form for previously prepared request
RequestSetCookies Sets provided cookies for previously prepared request
RequestSetBody Sets body for previously prepared request
RequestSend Sends previously prepared HTTP(s) request
Random data generation:
GenerateRandomInt Generates random integer from provided range and save it under provided cache key
GenerateFloat64 Generates random float from provided range and save it under provided cache key
GeneratorRandomRunes Creates generator for random strings from provided charset in provided range
GeneratorRandomSentence Creates generator for random sentence from provided charset in provided range
GetTimeAndTravel Accepts time object and move in time by given time interval
GenerateTimeAndTravel Creates current time object and move in time by given time interval
Preserving data:
SaveNode Saves from last response body JSON node under given cacheKey key
SaveHeader Saves into cache given header value
Save Saves into cache arbitrary passed value
Debugging:
DebugPrintResponseBody Prints last response from request
DebugStart Starts debugging mode
DebugStop Stops debugging mode
Flow control:
Wait Stops test execution for provided amount of time
Assertions:
AssertResponseHeaderExists Checks whether last HTTP(s) response has given header
AssertResponseHeaderNotExists Checks whether last HTTP(s) response doesn't have given header
AssertResponseHeaderValueIs Checks whether last HTTP(s) response has given header with provided value
AssertStatusCodeIs Checks last HTTP(s) response status code
AssertStatusCodeIsNot Checks if last HTTP(s) response status code is not of provided value
AssertResponseFormatIs Checks whether last HTTP(s) response body has given data format
AssertResponseFormatIsNot Checks whether last HTTP(s) response body doesn't have given data format
AssertNodeExists Checks whether last response body contains given key
AssertNodeNotExists Checks whether last response body doesn't contain given key
AssertNodesExist Checks whether last HTTP(s) response body JSON has given nodes
AssertNodeIsTypeAndValue Compares json node value from expression to expected by user
AssertNodeIsTypeAndHasOneOfValues Compares node value from expression to expected by user set of values
AssertNodeContainsSubString Checks whether node value from expression contains given substring
AssertNodeNotContainsSubString Checks whether node value from expression doesn't contain given substring
AssertNodeIsType Checks whether node from last HTTP(s) response body is of provided type
AssertNodeIsNotType Checks whether node from last HTTP(s) response body is not of provided type
AssertNodeMatchesRegExp Checks whether last HTTP(s) response body JSON node matches regExp
AssertNodeNotMatchesRegExp Checks whether last HTTP(s) response body JSON node doesn't match regExp
AssertNodeSliceLengthIs checks whether given key is slice and has given length
AssertNodeSliceLengthIsNot checks whether given key is slice and doesn't have given length
AssertResponseMatchesSchemaByReference Validates last HTTP(s) response body against provided in reference JSON schema
AssertResponseMatchesSchemaByString Validates last HTTP(s) response body against provided JSON schema
AssertNodeMatchesSchemaByString Validates last HTTP(s) response body JSON node against provided JSON schema
AssertNodeMatchesSchemaByReference Validates last HTTP(s) response body JSON node against provided in reference JSON schema
AssertTimeBetweenRequestAndResponseIs Asserts that last HTTP(s) request-response time is <= than expected
AssertResponseCookieExists Checks whether last HTTP(s) response has given cookie
AssertResponseCookieNotExists Checks whether last HTTP(s) response doesn't have given cookie
AssertResponseCookieValueIs Checks whether last HTTP(s) response has given cookie of given value
AssertResponseCookieValueMatchesRegExp Checks whether last HTTP(s) response has given cookie matching provided regExp
AssertResponseCookieValueNotMatchesRegExp Checks whether last HTTP(s) response has given cookie is not matching provided regExp

Documentation

Overview

Package gdutils provides APIContext struct with methods that may be used for behavioral testing of HTTP API.

APIContext may be initialized by two ways:

First, returns *APIContext with default services:

func NewDefaultAPIContext(isDebug bool, jsonSchemaDir string) *APIContext

Second, more customisable returns *APIContext with provided services:

func NewAPIContext(cli *http.Client, c cache.Cache, jv SchemaValidators, p PathFinders, f Formatters, t TypeMappers, d debugger.Debugger) *APIContext

No matter which way you choose, you can inject your custom services afterwards with one of available setters:

func (apiCtx *APIContext) SetDebugger(d debugger.Debugger)
func (apiCtx *APIContext) SetCache(c cache.Cache)
func (apiCtx *APIContext) SetRequestDoer(r httpctx.RequestDoer)
func (apiCtx *APIContext) SetTemplateEngine(t template.Engine)
func (apiCtx *APIContext) SetSchemaStringValidator(j validator.SchemaValidator)
func (apiCtx *APIContext) SetSchemaReferenceValidator(j validator.SchemaValidator)
func (apiCtx *APIContext) SetJSONPathFinder(r pathfinder.PathFinder)
func (apiCtx *APIContext) SetJSONFormatter(jf formatter.Formatter)
func (apiCtx *APIContext) SetXMLPathFinder(r pathfinder.PathFinder)
func (apiCtx *APIContext) SetXMLFormatter(xf formatter.Formatter)
func (apiCtx *APIContext) SetYAMLFormatter(yd formatter.Formatter)
func (apiCtx *APIContext) SetYAMLPathFinder(r pathfinder.PathFinder)
func (apiCtx *APIContext) SetHTMLPathFinder(r pathfinder.PathFinder)
func (apiCtx *APIContext) SetJSONTypeMapper(c types.Checker)
func (apiCtx *APIContext) SetYAMLTypeMapper(c types.Checker)
func (apiCtx *APIContext) SetGoTypeMapper(c types.Checker)

Those services will be used in utility methods and can be accessed directly if needed (to use in any custom methods). For example, if you want to use your own debugger - because default one is not suitable for you, create your own struct, implement debugger.Debugger interface on it, and then inject it with "func (apiCtx *APIContext) SetDebugger(d debugger.Debugger)" method.

Testing HTTP API usually consist of the following aspects:

* Data generation:

func (apiCtx *APIContext) GenerateRandomInt(from, to int, cacheKey string) error
func (apiCtx *APIContext) GenerateFloat64(from, to float64, cacheKey string) error
func (apiCtx *APIContext) GeneratorRandomRunes(charset string) func(from, to int, cacheKey string) error
func (apiCtx *APIContext) GeneratorRandomSentence(charset string, wordMinLength, wordMaxLength int) func(from, to int, cacheKey string) error
func (apiCtx *APIContext) GetTimeAndTravel(t time.Time, timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error
func (apiCtx *APIContext) GenerateTimeAndTravel(timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

* Sending HTTP(s) requests:

func (apiCtx *APIContext) RequestSendWithBodyAndHeaders(method, urlTemplate string, bodyTemplate string) error

or

func (apiCtx *APIContext) RequestPrepare(method, urlTemplate, cacheKey string) error
func (apiCtx *APIContext) RequestSetHeaders(cacheKey string, headersTemplate string) error
func (apiCtx *APIContext) RequestSetForm(cacheKey, formTemplate string) error
func (apiCtx *APIContext) RequestSetCookies(cacheKey, cookiesTemplate string) error
func (apiCtx *APIContext) RequestSetBody(cacheKey string, bodyTemplate string) error
func (apiCtx *APIContext) RequestSend(cacheKey string) error

* Assertions:

func (apiCtx *APIContext) AssertStatusCodeIs(code int) error
func (apiCtx *APIContext) AssertStatusCodeIsNot(code int) error
func (apiCtx *APIContext) AssertResponseFormatIs(dataFormat format.DataFormat) error
func (apiCtx *APIContext) AssertResponseFormatIsNot(dataFormat format.DataFormat) error
func (apiCtx *APIContext) AssertResponseCookieExists(name string) error
func (apiCtx *APIContext) AssertResponseCookieNotExists(name string) error
func (apiCtx *APIContext) AssertResponseCookieValueIs(name, valueTemplate string) error
func (apiCtx *APIContext) AssertResponseCookieValueNotMatchesRegExp(name, regExpTemplate string) error
func (apiCtx *APIContext) AssertNodesExist(dataFormat format.DataFormat, expressionsTemplates string) error
func (apiCtx *APIContext) AssertNodeExists(dataFormat format.DataFormat, exprTemplate string) error
func (apiCtx *APIContext) AssertNodeNotExists(dataFormat format.DataFormat, exprTemplate string) error
func (apiCtx *APIContext) AssertNodeIsType(dataFormat format.DataFormat, exprTemplate string, inType types.DataType) error
func (apiCtx *APIContext) AssertNodeIsNotType(dataFormat format.DataFormat, exprTemplate string, inType types.DataType) error
func (apiCtx *APIContext) AssertNodeMatchesRegExp(dataFormat format.DataFormat, exprTemplate, regExpTemplate string) error
func (apiCtx *APIContext) AssertNodeNotMatchesRegExp(dataFormat format.DataFormat, exprTemplate, regExpTemplate string) error
func (apiCtx *APIContext) AssertNodeIsTypeAndValue(dataFormat format.DataFormat, exprTemplate string, dataType types.DataType, dataValue string) error
func (apiCtx *APIContext) AssertNodeIsTypeAndHasOneOfValues(dataFormat format.DataFormat, exprTemplate string, dataType types.DataType, valuesTemplates string) error
func (apiCtx *APIContext) AsserNodeNotContainsSubString(dataFormat format.DataFormat, exprTemplate string, subTemplate string) error
func (apiCtx *APIContext) AsserNodeContainsSubString(dataFormat format.DataFormat, exprTemplate string, subTemplate string) error
func (apiCtx *APIContext) AssertNodeSliceLengthIs(dataFormat format.DataFormat, exprTemplate string, length int) error
func (apiCtx *APIContext) AssertNodeSliceLengthIsNot(dataFormat format.DataFormat, exprTemplate string, length int) error
func (apiCtx *APIContext) AssertResponseHeaderExists(name string) error
func (apiCtx *APIContext) AssertResponseHeaderNotExists(name string) error
func (apiCtx *APIContext) AssertResponseHeaderValueIs(name, value string) error
func (apiCtx *APIContext) AssertResponseMatchesSchemaByReference(referenceTemplate string) error
func (apiCtx *APIContext) AssertResponseMatchesSchemaByString(schemaTemplate string) error
func (apiCtx *APIContext) AssertNodeMatchesSchemaByString(dataFormat format.DataFormat, exprTemplate, schemaTemplate string) error
func (apiCtx *APIContext) AssertNodeMatchesSchemaByReference(dataFormat format.DataFormat, exprTemplate, referenceTemplate string) error
func (apiCtx *APIContext) AssertTimeBetweenRequestAndResponseIs(timeInterval time.Duration) error

* Preserving nodes:

func (apiCtx *APIContext) SaveNode(dataFormat format.DataFormat, exprTemplate, cacheKey string) error
func (apiCtx *APIContext) SaveHeader(name, cacheKey string) error
func (apiCtx *APIContext) Save(valueTemplate, cacheKey string) error

* Flow control:

func (apiCtx *APIContext) Wait(timeInterval time.Duration) error

* Debugging:

func (apiCtx *APIContext) DebugPrintResponseBody() error
func (apiCtx *APIContext) DebugStart() error
func (apiCtx *APIContext) DebugStop() error

Here is example lib usage to test endpoint returning list of ducks gifs:

	ac := gdutils.NewDefaultAPIContext(false, "")

	if err := ac.RequestPrepare("GET", "https://random-d.uk/api/v2/list", "DUCK_GIFS_LIST"); err != nil {
		return err
	}

	if err := ac.RequestSend("DUCK_GIFS_LIST"); err != nil {
   		return err
	}

	if err := ac.AssertStatusCodeIs(200); err != nil {
   		return err
	}

	if err := ac.AssertResponseFormatIs(format.JSON); err != nil {
   		return err
	}

	if err := ac.AssertNodeIsType(format.JSON, "$.gifs", types.Array); err != nil {
   		return err
	}

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultTransport http.RoundTripper = &http.Transport{
	TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}

Functions

This section is empty.

Types

type APIContext added in v0.14.1

type APIContext struct {
	// Debugger represents debugger.
	Debugger debugger.Debugger

	// Cache is storage for data.
	Cache cache.Cache

	// RequestDoer is service that has ability to send HTTP(s) requests.
	RequestDoer httpctx.RequestDoer

	// TemplateEngine is entity that has ability to work with template values.
	TemplateEngine template.Engine

	// SchemaValidators holds validators available to validate data against schemas.
	SchemaValidators SchemaValidators

	// PathFinders are entities that has ability to obtain data from different data formats.
	PathFinders PathFinders

	// Formatters are entities that has ability to format data in particular format.
	Formatters Formatters

	// TypeMappers are entities that has ability to map underlying data type into different format data type.
	TypeMappers TypeMappers
	// contains filtered or unexported fields
}

APIContext holds utility services for working with HTTP(s) API.

func NewAPIContext added in v0.14.1

NewAPIContext returns *APIContext

func NewDefaultAPIContext added in v0.14.1

func NewDefaultAPIContext(isDebug bool, jsonSchemaDir string) *APIContext

NewDefaultAPIContext returns *APIContext with default services. jsonSchemaDir may be empty string or valid full path to directory with JSON schemas.

func (*APIContext) AssertNodeContainsSubString added in v1.1.0

func (apiCtx *APIContext) AssertNodeContainsSubString(dataFormat df.DataFormat, exprTemplate string, subTemplate string) error

AssertNodeContainsSubString AsserNodeContainsSubString checks whether value of last HTTP response node, obtained using exprTemplate is string type and contains given substring

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.AssertNodeContainsSubString(df.JSON, "user", "abcd")
fmt.Println(err)
Output:

node 'user' string value doesn't contain any occurrence of 'abcd'

func (*APIContext) AssertNodeExists added in v1.0.0

func (apiCtx *APIContext) AssertNodeExists(dataFormat df.DataFormat, exprTemplate string) error

AssertNodeExists checks whether last response body contains given node. expr should be valid according to injected PathFinder for given data format

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader("{}"))})

err := apiCtx.AssertNodeExists(df.JSON, "user")
fmt.Println(err)
Output:

node 'user' could not be found within last response body, reason: could not find node using provided expression: 'user', err: could not find node, using expression user

func (*APIContext) AssertNodeIsNotType added in v1.0.0

func (apiCtx *APIContext) AssertNodeIsNotType(dataFormat df.DataFormat, exprTemplate string, inType types.DataType) error

AssertNodeIsNotType checks whether node from last response body is of provided type. available types are listed in types subpackage. expr should be valid according to injected PathResolver.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user":"abc"}`))})

err := apiCtx.AssertNodeIsNotType(df.JSON, "user", types.String)
fmt.Println(err)
Output:

node 'user' has type 'string', but expected not to be

func (*APIContext) AssertNodeIsType added in v1.0.0

func (apiCtx *APIContext) AssertNodeIsType(dataFormat df.DataFormat, exprTemplate string, inType types.DataType) error

AssertNodeIsType checks whether node from last response body is of provided type. available types are listed in types subpackage. expr should be valid according to injected PathResolver.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user":"abc"}`))})

err := apiCtx.AssertNodeIsType(df.JSON, "user", types.Number)
fmt.Println(err)
Output:

expected node 'user' to be 'number', but node value is detected as 'string' in terms of JSON and 'string' in terms of Go

func (*APIContext) AssertNodeIsTypeAndHasOneOfValues added in v1.1.0

func (apiCtx *APIContext) AssertNodeIsTypeAndHasOneOfValues(dataFormat df.DataFormat, exprTemplate string, dataType types.DataType, valuesTemplates string) error

AssertNodeIsTypeAndHasOneOfValues checks whether node value obtained using exprTemplate matches one of values held by valuesTemplates argument. Values should be separated by comma (,) and may contain template values.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.AssertNodeIsTypeAndHasOneOfValues(df.JSON, "user", types.String, "def, ghi")
fmt.Println(err)
Output:

node 'user' doesn't contain any of: []string{"def", "ghi"}

func (*APIContext) AssertNodeIsTypeAndValue added in v1.0.0

func (apiCtx *APIContext) AssertNodeIsTypeAndValue(dataFormat df.DataFormat, exprTemplate string, dataType types.DataType, dataValue string) error

AssertNodeIsTypeAndValue compares node value from expression to expected by user dataValue of given by user dataType Available data types are listed in switch section in each case directive. expr should be valid according to injected PathFinder for provided dataFormat.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.AssertNodeIsTypeAndValue(df.JSON, "user", types.String, "def")
fmt.Println(err)
Output:

node 'user' has string value: 'abc', but expected: 'def'

func (*APIContext) AssertNodeMatchesRegExp added in v1.0.0

func (apiCtx *APIContext) AssertNodeMatchesRegExp(dataFormat df.DataFormat, exprTemplate, regExpTemplate string) error

AssertNodeMatchesRegExp checks whether last response body node matches provided regExp.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.AssertNodeMatchesRegExp(df.JSON, "user", `ac.*`)
fmt.Println(err)
Output:

node 'user' does not match regExp: 'ac.*'

func (*APIContext) AssertNodeMatchesSchemaByReference added in v1.0.0

func (apiCtx *APIContext) AssertNodeMatchesSchemaByReference(dataFormat df.DataFormat, exprTemplate, referenceTemplate string) error

AssertNodeMatchesSchemaByReference validates last response body node against schema as provided in referenceTemplate

func (*APIContext) AssertNodeMatchesSchemaByString added in v1.0.0

func (apiCtx *APIContext) AssertNodeMatchesSchemaByString(dataFormat df.DataFormat, exprTemplate, schemaTemplate string) error

AssertNodeMatchesSchemaByString validates last response body JSON node against schema

func (*APIContext) AssertNodeNotContainsSubString added in v1.1.0

func (apiCtx *APIContext) AssertNodeNotContainsSubString(dataFormat df.DataFormat, exprTemplate string, subTemplate string) error

AssertNodeNotContainsSubString AsserNodeNotContainsSubString checks whether value of last HTTP response node, obtained using exprTemplate is string type and doesn't contain given substring

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.AssertNodeNotContainsSubString(df.JSON, "user", "a")
fmt.Println(err)
Output:

node 'user' string value contain some 'a', but expected not to

func (*APIContext) AssertNodeNotExists added in v1.0.0

func (apiCtx *APIContext) AssertNodeNotExists(dataFormat df.DataFormat, exprTemplate string) error

AssertNodeNotExists checks whether last response body does not contain given node. expr should be valid according to injected PathFinder for given data format

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.AssertNodeNotExists(df.JSON, "user")
fmt.Println(err)
Output:

json node 'user' exists

func (*APIContext) AssertNodeNotMatchesRegExp added in v1.0.0

func (apiCtx *APIContext) AssertNodeNotMatchesRegExp(dataFormat df.DataFormat, exprTemplate, regExpTemplate string) error

AssertNodeNotMatchesRegExp checks whether last response body node does not match provided regExp.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.AssertNodeNotMatchesRegExp(df.JSON, "user", `ab.*`)
fmt.Println(err)
Output:

node 'user' matches regExp: 'ab.*', but expected not to

func (*APIContext) AssertNodeSliceLengthIs added in v1.0.0

func (apiCtx *APIContext) AssertNodeSliceLengthIs(dataFormat df.DataFormat, exprTemplate string, length int) error

AssertNodeSliceLengthIs checks whether given key is slice and has given length expr should be valid according to injected PathFinder for provided dataFormat

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user":[]}`))})

err := apiCtx.AssertNodeSliceLengthIs(df.JSON, "user", 1)
fmt.Println(err)
Output:

node 'user' contains slice(array) which has length: 0, but expected: 1

func (*APIContext) AssertNodeSliceLengthIsNot added in v1.0.0

func (apiCtx *APIContext) AssertNodeSliceLengthIsNot(dataFormat df.DataFormat, exprTemplate string, length int) error

AssertNodeSliceLengthIsNot checks whether given key is slice and has not given length expr should be valid according to injected PathFinder for provided dataFormat

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user":[]}`))})

err := apiCtx.AssertNodeSliceLengthIsNot(df.JSON, "user", 0)
fmt.Println(err)
Output:

node 'user' contains slice(array) which has length: 0, but expected not to have it

func (*APIContext) AssertNodesExist added in v1.0.0

func (apiCtx *APIContext) AssertNodesExist(dataFormat df.DataFormat, expressionsTemplate string) error

AssertNodesExist checks whether last request body has keys defined in string separated by comma nodeExprs should be valid according to injected PathFinder expressions separated by comma (,)

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user":"abc"}`))})

err := apiCtx.AssertNodesExist(df.JSON, "user, address, roles")
fmt.Println(err)
Output:

node 'address', err: could not find node using provided expression: 'address', err: could not find node, using expression address
node 'roles', err: could not find node using provided expression: 'roles', err: could not find node, using expression roles

func (*APIContext) AssertResponseCookieExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseCookieExists(name string) error

AssertResponseCookieExists checks whether last HTTP(s) response has cookie of given name.

func (*APIContext) AssertResponseCookieNotExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseCookieNotExists(name string) error

AssertResponseCookieNotExists checks whether last HTTP(s) response does not have cookie of given name.

func (*APIContext) AssertResponseCookieValueIs added in v1.0.0

func (apiCtx *APIContext) AssertResponseCookieValueIs(name, valueTemplate string) error

AssertResponseCookieValueIs checks whether last HTTP(s) response has cookie of given name and value.

func (*APIContext) AssertResponseCookieValueMatchesRegExp added in v1.1.0

func (apiCtx *APIContext) AssertResponseCookieValueMatchesRegExp(name, regExpTemplate string) error

AssertResponseCookieValueMatchesRegExp checks whether last HTTP(s) response has cookie of given name and value matching regExp.

func (*APIContext) AssertResponseCookieValueNotMatchesRegExp added in v1.1.0

func (apiCtx *APIContext) AssertResponseCookieValueNotMatchesRegExp(name, regExpTemplate string) error

AssertResponseCookieValueNotMatchesRegExp checks whether last HTTP(s) response has cookie of given name and value is not matching provided regExp.

func (*APIContext) AssertResponseFormatIs added in v1.0.0

func (apiCtx *APIContext) AssertResponseFormatIs(dataFormat df.DataFormat) error

AssertResponseFormatIs checks whether last response body has given data format. Available data formats are listed in format package.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader("abc"))})

err := apiCtx.AssertResponseFormatIs(df.JSON)
fmt.Println(err)
Output:

response body doesn't have format json

func (*APIContext) AssertResponseFormatIsNot added in v1.0.0

func (apiCtx *APIContext) AssertResponseFormatIsNot(dataFormat df.DataFormat) error

AssertResponseFormatIsNot checks whether last response body has not given data format. Available data formats are listed in format package.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader("{}"))})

err := apiCtx.AssertResponseFormatIsNot(df.JSON)
fmt.Println(err)
Output:

response body has format json

func (*APIContext) AssertResponseHeaderExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseHeaderExists(name string) error

AssertResponseHeaderExists checks whether last HTTP response has given header.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Header: map[string][]string{"Content-Type": {"application/json"}}})

err := apiCtx.AssertResponseHeaderExists("Content-Length")
fmt.Println(err)
Output:

could not find header 'Content-Length' in last HTTP response

func (*APIContext) AssertResponseHeaderNotExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseHeaderNotExists(name string) error

AssertResponseHeaderNotExists checks whether last HTTP response does not have given header.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Header: map[string][]string{"Content-Type": {"application/json"}}})

err := apiCtx.AssertResponseHeaderNotExists("content-type")
fmt.Println(err)
Output:

last HTTP(s) response has header 'content-type', but expected not to

func (*APIContext) AssertResponseHeaderValueIs added in v1.0.0

func (apiCtx *APIContext) AssertResponseHeaderValueIs(name, valueTemplate string) error

AssertResponseHeaderValueIs checks whether last HTTP response has given header with provided valueTemplate.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Header: map[string][]string{"Content-Type": {"application/json"}}})

err := apiCtx.AssertResponseHeaderValueIs("content-type", "application/json+ld")
fmt.Println(err)
Output:

last HTTP(s) response contains header 'content-type', but it's expected value: 'application/json+ld', is not equal to actual value: 'application/json'

func (*APIContext) AssertResponseMatchesSchemaByReference added in v1.0.0

func (apiCtx *APIContext) AssertResponseMatchesSchemaByReference(referenceTemplate string) error

AssertResponseMatchesSchemaByReference validates last response body against schema as provided in referenceTemplate. referenceTemplate may be: URL or full/relative path

func (*APIContext) AssertResponseMatchesSchemaByString added in v1.0.0

func (apiCtx *APIContext) AssertResponseMatchesSchemaByString(schema string) error

AssertResponseMatchesSchemaByString validates last response body against schema.

func (*APIContext) AssertStatusCodeIs added in v1.0.0

func (apiCtx *APIContext) AssertStatusCodeIs(code int) error

AssertStatusCodeIs compare last response status code with given in argument.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{StatusCode: 201})

err := apiCtx.AssertStatusCodeIs(200)
fmt.Println(err)
Output:

expected status code 200, but got 201

func (*APIContext) AssertStatusCodeIsNot added in v1.0.0

func (apiCtx *APIContext) AssertStatusCodeIsNot(code int) error

AssertStatusCodeIsNot asserts that last response status code is not provided.

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{StatusCode: 200})

err := apiCtx.AssertStatusCodeIsNot(200)
fmt.Println(err)
Output:

expected status code different than 200, but got 200

func (*APIContext) AssertTimeBetweenRequestAndResponseIs added in v1.0.0

func (apiCtx *APIContext) AssertTimeBetweenRequestAndResponseIs(timeInterval time.Duration) error

AssertTimeBetweenRequestAndResponseIs asserts that last HTTP request-response time is <= than expected timeInterval. timeInterval should be string acceptable by time.ParseDuration func

func (*APIContext) DebugPrintResponseBody added in v1.0.0

func (apiCtx *APIContext) DebugPrintResponseBody() error

DebugPrintResponseBody prints last response from request.

func (*APIContext) DebugStart added in v1.0.0

func (apiCtx *APIContext) DebugStart() error

DebugStart starts debugging mode

func (*APIContext) DebugStop added in v1.0.0

func (apiCtx *APIContext) DebugStop() error

DebugStop stops debugging mode

func (*APIContext) GenerateFloat64 added in v1.0.0

func (apiCtx *APIContext) GenerateFloat64(from, to float64, cacheKey string) error

GenerateFloat64 generates random float from provided range and preserve it under given cacheKey key.

Example
apiCtx := NewDefaultAPIContext(false, "")

if err := apiCtx.GenerateFloat64(0, 0, "MYFLOAT"); err != nil {
	log.Fatal(err)

	return
}

myFloat, err := apiCtx.Cache.GetSaved("MYFLOAT")
if err != nil {
	log.Fatal(err)

	return
}

fmt.Println(myFloat)
Output:

0

func (*APIContext) GenerateRandomInt added in v1.0.0

func (apiCtx *APIContext) GenerateRandomInt(from, to int, cacheKey string) error

GenerateRandomInt generates random integer from provided range and preserve it under given cacheKey key.

Example
apiCtx := NewDefaultAPIContext(false, "")

if err := apiCtx.GenerateRandomInt(2, 2, "MYINT"); err != nil {
	log.Fatal(err)

	return
}

myInt, err := apiCtx.Cache.GetSaved("MYINT")
if err != nil {
	log.Fatal(err)

	return
}

fmt.Println(myInt)
Output:

2

func (*APIContext) GenerateTimeAndTravel added in v1.0.0

func (apiCtx *APIContext) GenerateTimeAndTravel(timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

GenerateTimeAndTravel creates current time object, move timeDuration in time and save it in cache under given cacheKey.

func (*APIContext) GeneratorRandomRunes added in v1.0.0

func (apiCtx *APIContext) GeneratorRandomRunes(charset string) func(from, to int, cacheKey string) error

GeneratorRandomRunes creates random runes generator func using provided charset return func creates runes from provided range and preserve it under given cacheKey

Example
apiCtx := NewDefaultAPIContext(false, "")

generateA := apiCtx.GeneratorRandomRunes("A")
err := generateA(2, 2, "TWO_A")
if err != nil {
	log.Fatal(err)

	return
}

myA, err := apiCtx.Cache.GetSaved("TWO_A")
if err != nil {
	log.Fatal(err)

	return
}

fmt.Println(myA)
Output:

AA

func (*APIContext) GeneratorRandomSentence added in v1.0.0

func (apiCtx *APIContext) GeneratorRandomSentence(charset string, wordMinLength, wordMaxLength int) func(from, to int, cacheKey string) error

GeneratorRandomSentence creates generator func for creating random sentences each sentence has length from - to as provided in params and is saved in provided cacheKey

Example
apiCtx := NewDefaultAPIContext(false, "")

generateA := apiCtx.GeneratorRandomSentence("A", 2, 2)
err := generateA(2, 2, "TWO_WORDS_A")
if err != nil {
	log.Fatal(err)

	return
}

myA, err := apiCtx.Cache.GetSaved("TWO_WORDS_A")
if err != nil {
	log.Fatal(err)

	return
}

fmt.Println(myA)
Output:

AA AA

func (*APIContext) GetLastResponse added in v0.14.1

func (apiCtx *APIContext) GetLastResponse() (*http.Response, error)

GetLastResponse returns last HTTP(s) response.

func (*APIContext) GetLastResponseBody added in v0.14.1

func (apiCtx *APIContext) GetLastResponseBody() ([]byte, error)

GetLastResponseBody returns last HTTP(s) response body. internally method creates new NoPCloser on last response so this method is safe to reuse many times

func (*APIContext) GetPreparedRequest added in v0.14.1

func (apiCtx *APIContext) GetPreparedRequest(cacheKey string) (*http.Request, error)

GetPreparedRequest returns prepared request from cache or error if failed

func (*APIContext) GetTimeAndTravel added in v1.0.0

func (apiCtx *APIContext) GetTimeAndTravel(t time.Time, timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

GetTimeAndTravel accepts time object, move timeDuration in time and save it in cache under given cacheKey.

func (*APIContext) RequestPrepare added in v1.0.0

func (apiCtx *APIContext) RequestPrepare(method, urlTemplate, cacheKey string) error

RequestPrepare prepares new request and saves it in cache under cacheKey

func (*APIContext) RequestSend added in v1.0.0

func (apiCtx *APIContext) RequestSend(cacheKey string) error

RequestSend sends previously prepared HTTP(s) request.

func (*APIContext) RequestSendWithBodyAndHeaders added in v1.0.0

func (apiCtx *APIContext) RequestSendWithBodyAndHeaders(method, urlTemplate string, bodyAndHeaderTemplate string) error
	RequestSendWithBodyAndHeaders sends HTTP(s) requests with provided body and headers.

	Argument "method" indices HTTP request method for example: "POST", "GET" etc.
 	Argument "urlTemplate" should be full valid URL. May include template values.
	Argument "bodyTemplate" should contain data (may include template values)
	in JSON or YAML format with keys "body" and "headers".

func (*APIContext) RequestSetBody added in v1.0.0

func (apiCtx *APIContext) RequestSetBody(cacheKey, bodyTemplate string) error

RequestSetBody sets body for previously prepared request bodyTemplate may be in any format and accepts template values

func (*APIContext) RequestSetCookies added in v1.0.0

func (apiCtx *APIContext) RequestSetCookies(cacheKey, cookiesTemplate string) error

RequestSetCookies sets cookies for previously prepared request. cookiesTemplate should be YAML or JSON deserializable on []http.Cookie.

func (*APIContext) RequestSetForm added in v1.0.0

func (apiCtx *APIContext) RequestSetForm(cacheKey, formTemplate string) error

RequestSetForm sets form for previously prepared request. Internally method sets proper Content-Type: multipart/form-data header. formTemplate should be YAML or JSON deserializable on map[string]string.

func (*APIContext) RequestSetHeaders added in v1.0.0

func (apiCtx *APIContext) RequestSetHeaders(cacheKey, headersTemplate string) error

RequestSetHeaders sets provided headers for previously prepared request. incoming data should be in JSON or YAML format

func (*APIContext) ResetState added in v0.14.1

func (apiCtx *APIContext) ResetState(isDebug bool)

ResetState resets state of APIContext to initial.

func (*APIContext) Save added in v1.0.0

func (apiCtx *APIContext) Save(valueTemplate, cacheKey string) error

Save saves into cache arbitrary passed data.

Example
apiCtx := NewDefaultAPIContext(false, "")

apiCtx.Cache.Save("MY_KEY", "MY_VAL")

val, err := apiCtx.Cache.GetSaved("MY_KEY")
if err != nil {
	fmt.Println(err)

	return
}

fmt.Println(val)
Output:

MY_VAL

func (*APIContext) SaveHeader added in v1.0.0

func (apiCtx *APIContext) SaveHeader(name, cacheKey string) error

SaveHeader saves from last response header value under given cache key

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Header: map[string][]string{"Content-Type": {"application/json"}}})

if err := apiCtx.SaveHeader("content-type", "CONTENT_TYPE_VALUE"); err != nil {
	fmt.Println(err)

	return
}

val, err := apiCtx.Cache.GetSaved("CONTENT_TYPE_VALUE")
if err != nil {
	fmt.Println(err)

	return
}

fmt.Println(val)
Output:

application/json

func (*APIContext) SaveNode added in v1.0.0

func (apiCtx *APIContext) SaveNode(dataFormat df.DataFormat, exprTemplate, cacheKey string) error

SaveNode saves from last response body node under given cache key. expr should be valid according to injected PathResolver of given data type

Example
apiCtx := NewDefaultAPIContext(false, "")

// instead of sending real HTTP(s) request with apiCtx.RequestSend
// we simply mock last HTTP(s) request's response
apiCtx.Cache.Save(httpcache.LastHTTPResponseCacheKey, &http.Response{Body: io.NopCloser(strings.NewReader(`{"user": "abc"}`))})

err := apiCtx.SaveNode(df.JSON, "user", "USER_NAME")
if err != nil {
	fmt.Println(err)

	return
}

val, err := apiCtx.Cache.GetSaved("USER_NAME")
if err != nil {
	fmt.Println(err)

	return
}

fmt.Println(val)
Output:

abc

func (*APIContext) SetCache added in v0.14.1

func (apiCtx *APIContext) SetCache(c cache.Cache)

SetCache sets new Cache for APIContext.

func (*APIContext) SetDebugger added in v0.14.1

func (apiCtx *APIContext) SetDebugger(d debugger.Debugger)

SetDebugger sets new debugger for APIContext.

func (*APIContext) SetGoTypeMapper added in v1.1.0

func (apiCtx *APIContext) SetGoTypeMapper(c types.Mapper)

SetGoTypeMapper sets new type mapper for Go.

func (*APIContext) SetHTMLPathFinder added in v1.2.0

func (apiCtx *APIContext) SetHTMLPathFinder(r pathfinder.PathFinder)

SetHTMLPathFinder sets new HTML pathfinder for APIContext.

func (*APIContext) SetJSONFormatter added in v0.14.1

func (apiCtx *APIContext) SetJSONFormatter(jf formatter.Formatter)

SetJSONFormatter sets new JSON formatter for APIContext.

func (*APIContext) SetJSONPathFinder added in v0.14.1

func (apiCtx *APIContext) SetJSONPathFinder(r pathfinder.PathFinder)

SetJSONPathFinder sets new JSON pathfinder for APIContext.

func (*APIContext) SetJSONTypeMapper added in v1.1.0

func (apiCtx *APIContext) SetJSONTypeMapper(c types.Mapper)

SetJSONTypeMapper sets new type mapper for JSON.

func (*APIContext) SetRequestDoer added in v0.14.1

func (apiCtx *APIContext) SetRequestDoer(r httpctx.RequestDoer)

SetRequestDoer sets new RequestDoer for APIContext.

func (*APIContext) SetSchemaReferenceValidator added in v0.14.1

func (apiCtx *APIContext) SetSchemaReferenceValidator(j validator.SchemaValidator)

SetSchemaReferenceValidator sets new schema ReferenceValidator for APIContext.

func (*APIContext) SetSchemaStringValidator added in v0.14.1

func (apiCtx *APIContext) SetSchemaStringValidator(j validator.SchemaValidator)

SetSchemaStringValidator sets new schema StringValidator for APIContext.

func (*APIContext) SetTemplateEngine added in v0.14.1

func (apiCtx *APIContext) SetTemplateEngine(t template.Engine)

SetTemplateEngine sets new template Engine for APIContext.

func (*APIContext) SetXMLFormatter added in v0.14.1

func (apiCtx *APIContext) SetXMLFormatter(xf formatter.Formatter)

SetXMLFormatter sets new XML formatter for APIContext.

func (*APIContext) SetXMLPathFinder added in v0.14.1

func (apiCtx *APIContext) SetXMLPathFinder(r pathfinder.PathFinder)

SetXMLPathFinder sets new XML pathfinder for APIContext.

func (*APIContext) SetYAMLFormatter added in v0.14.1

func (apiCtx *APIContext) SetYAMLFormatter(yd formatter.Formatter)

SetYAMLFormatter sets new YAML formatter for APIContext.

func (*APIContext) SetYAMLPathFinder added in v0.14.1

func (apiCtx *APIContext) SetYAMLPathFinder(r pathfinder.PathFinder)

SetYAMLPathFinder sets new YAML pathfinder for APIContext.

func (*APIContext) SetYAMLTypeMapper added in v1.1.0

func (apiCtx *APIContext) SetYAMLTypeMapper(c types.Mapper)

SetYAMLTypeMapper sets new type mapper for YAML.

func (*APIContext) Wait added in v1.0.0

func (apiCtx *APIContext) Wait(timeInterval time.Duration) error

Wait waits for given timeInterval amount of time

type BodyHeaders added in v0.7.4

type BodyHeaders struct {

	// Body should contain HTTP(s) request body
	Body any

	// Headers should contain HTTP(s) request headers
	Headers map[string]string
}

BodyHeaders is entity that holds information about request body and request headers.

type CustomTransport added in v1.2.0

type CustomTransport struct {
	http.RoundTripper
}

func (*CustomTransport) RoundTrip added in v1.2.0

func (ct *CustomTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Formatters added in v0.12.0

type Formatters struct {
	// JSON is entity that has ability to serialize and deserialize JSON bytes.
	JSON formatter.Formatter

	// YAML is entity that has ability to serialize and deserialize YAML bytes.
	YAML formatter.Formatter

	// XML is entity that has ability to serialize and deserialize XML bytes.
	XML formatter.Formatter
}

Formatters is container for entities that know how to serialize and deserialize data.

type PathFinders added in v0.12.0

type PathFinders struct {
	// JSON is entity that has ability to obtain data from bytes in JSON format.
	JSON pathfinder.PathFinder

	// YAML is entity that has ability to obtain data from bytes in YAML format.
	YAML pathfinder.PathFinder

	// XML is entity that has ability to obtain data from bytes in XML format.
	XML pathfinder.PathFinder

	// HTML is entity that has ability to obtain data from bytes in HTML format.
	HTML pathfinder.PathFinder
}

PathFinders is container for different data types pathfinders.

type SchemaValidators added in v0.12.0

type SchemaValidators struct {
	// StringValidator represents entity that has ability to validate document against string of containing schema.
	StringValidator validator.SchemaValidator

	// ReferenceValidator represents entity that has ability to validate document against string with reference
	// to schema, which may be URL or relative/full OS path for example.
	ReferenceValidator validator.SchemaValidator
}

SchemaValidators is container for JSON schema validators.

type TypeMappers added in v1.1.0

type TypeMappers struct {
	// JSON is entity that has ability to map underlying data type into JSON data type
	JSON types.Mapper

	// YAML is entity that has ability to map underlying data type into YAML data type
	YAML types.Mapper

	// GO is entity that has ability to map underlying data type into GO-like data type
	GO types.Mapper
}

TypeMappers is container for different data format mappers

Directories

Path Synopsis
pkg
Package pkg holds packages used for steps.
Package pkg holds packages used for steps.
cache
Package cache holds definition of Cache used for storing and retrieving data.
Package cache holds definition of Cache used for storing and retrieving data.
debugger
Package debugger holds definition of Debugger.
Package debugger holds definition of Debugger.
formatter
Package formatter holds utilities for working with different data formats.
Package formatter holds utilities for working with different data formats.
httpcache
Package httpcache connects package httpctx and cache
Package httpcache connects package httpctx and cache
httpctx
Package httpctx holds utilities for working with HTTP protocol.
Package httpctx holds utilities for working with HTTP protocol.
mathutils
Package mathutils holds utilities related with mathematics.
Package mathutils holds utilities related with mathematics.
pathfinder
Package pathfinder holds utilities for working with JSON path.
Package pathfinder holds utilities for working with JSON path.
reflectutils
Package reflectutils holds utility methods related with reflect package.
Package reflectutils holds utility methods related with reflect package.
schema
Package schema holds services that allows to validate JSON string against a schema.
Package schema holds services that allows to validate JSON string against a schema.
template
Package template holds utilities for working with templates.
Package template holds utilities for working with templates.
types
Package types holds utilities for working with different formats data types.
Package types holds utilities for working with different formats data types.
validator
Package validator holds utilities for validating data.
Package validator holds utilities for validating data.

Jump to

Keyboard shortcuts

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