Documentation ¶
Overview ¶
Package helpers contains helper and utility functions used by the validator. Trying to avoid using the package name utils anymore, as it's too generic and can cause conflicts with other packages - however I feel this pattern will suffer the exact same fate with time.
Index ¶
- Constants
- func CollapseCSVIntoFormStyle(key string, value string) string
- func CollapseCSVIntoPipeDelimitedStyle(key string, values []string) string
- func CollapseCSVIntoSpaceDelimitedStyle(key string, values []string) string
- func ConstructKVFromCSV(values string) map[string]interface{}
- func ConstructKVFromLabelEncoding(values string) map[string]interface{}
- func ConstructKVFromMatrixCSV(values string) map[string]interface{}
- func ConstructMapFromCSV(csv string) map[string]interface{}
- func ConstructParamMapFromDeepObjectEncoding(values []*QueryParam) map[string]interface{}
- func ConstructParamMapFromFormEncodingArray(values []*QueryParam) map[string]interface{}
- func ConstructParamMapFromPipeEncoding(values []*QueryParam) map[string]interface{}
- func ConstructParamMapFromQueryParamInput(values map[string][]*QueryParam) map[string]interface{}
- func ConstructParamMapFromSpaceEncoding(values []*QueryParam) map[string]interface{}
- func DoesFormParamContainDelimiter(value, style string) bool
- func ExplodeQueryValue(value, style string) []string
- func ExtractContentType(contentType string) (string, string, string)
- func ExtractOperation(request *http.Request, item *v3.PathItem) *v3.Operation
- func ExtractParamsForOperation(request *http.Request, item *v3.PathItem) []*v3.Parameter
- func ExtractSecurityForOperation(request *http.Request, item *v3.PathItem) []*base.SecurityRequirement
- type QueryParam
Constants ¶
const ( ParameterValidation = "parameter" ParameterValidationPath = "path" ParameterValidationQuery = "query" ParameterValidationHeader = "header" ParameterValidationCookie = "cookie" RequestBodyValidation = "requestBody" Schema = "schema" ResponseBodyValidation = "response" RequestBodyContentType = "contentType" ResponseBodyResponseCode = "statusCode" SpaceDelimited = "spaceDelimited" PipeDelimited = "pipeDelimited" DefaultDelimited = "default" MatrixStyle = "matrix" LabelStyle = "label" Pipe = "|" Comma = "," Space = " " SemiColon = ";" Asterisk = "*" Period = "." Equals = "=" Integer = "integer" Number = "number" Slash = "/" Object = "object" String = "string" Array = "array" Boolean = "boolean" DeepObject = "deepObject" Header = "header" Cookie = "cookie" Path = "path" Form = "form" Query = "query" JSONContentType = "application/json" JSONType = "json" ContentTypeHeader = "Content-Type" Charset = "charset" Boundary = "boundary" Preferred = "preferred" FailSegment = "**&&FAIL&&**" )
Variables ¶
This section is empty.
Functions ¶
func ConstructKVFromCSV ¶
ConstructKVFromCSV will construct a map from a comma separated value string that denotes key value pairs.
func ConstructKVFromLabelEncoding ¶
ConstructKVFromLabelEncoding will construct a map from a comma separated value string that denotes key value pairs.
func ConstructKVFromMatrixCSV ¶
ConstructKVFromMatrixCSV will construct a map from a comma separated value string that denotes key value pairs.
func ConstructMapFromCSV ¶
ConstructMapFromCSV will construct a map from a comma separated value string.
func ConstructParamMapFromDeepObjectEncoding ¶
func ConstructParamMapFromDeepObjectEncoding(values []*QueryParam) map[string]interface{}
ConstructParamMapFromDeepObjectEncoding will construct a map from the query parameters that are encoded as deep objects. It's kind of a crazy way to do things, but hey, each to their own.
func ConstructParamMapFromFormEncodingArray ¶
func ConstructParamMapFromFormEncodingArray(values []*QueryParam) map[string]interface{}
ConstructParamMapFromFormEncodingArray will construct a map from the query parameters that are encoded as form encoded values.
func ConstructParamMapFromPipeEncoding ¶
func ConstructParamMapFromPipeEncoding(values []*QueryParam) map[string]interface{}
ConstructParamMapFromPipeEncoding will construct a map from the query parameters that are encoded as pipe separated values. Perhaps the most sane way to delimit/encode properties.
func ConstructParamMapFromQueryParamInput ¶
func ConstructParamMapFromQueryParamInput(values map[string][]*QueryParam) map[string]interface{}
ConstructParamMapFromQueryParamInput will construct a param map from an existing map of *QueryParam slices.
func ConstructParamMapFromSpaceEncoding ¶
func ConstructParamMapFromSpaceEncoding(values []*QueryParam) map[string]interface{}
ConstructParamMapFromSpaceEncoding will construct a map from the query parameters that are encoded as space delimited values. This is perhaps the worst way to delimit anything other than a paragraph of text.
func DoesFormParamContainDelimiter ¶
DoesFormParamContainDelimiter will determine if a form parameter contains a delimiter.
func ExplodeQueryValue ¶
ExplodeQueryValue will explode a query value based on the style (space, pipe, or form/default).
func ExtractContentType ¶
ExtractContentType extracts the content type from the request header. First return argument is the content type of the request.The second (optional) argument is the charset of the request. The third (optional) argument is the boundary of the type (only used with forms really).
func ExtractOperation ¶
ExtractOperation extracts the operation from the path item based on the request method. If there is no matching operation found, then nil is returned.
func ExtractParamsForOperation ¶
ExtractParamsForOperation will extract the parameters for the operation based on the request method. Both the path level params and the method level params will be returned.
func ExtractSecurityForOperation ¶ added in v0.0.33
func ExtractSecurityForOperation(request *http.Request, item *v3.PathItem) []*base.SecurityRequirement
ExtractSecurityForOperation will extract the security requirements for the operation based on the request method.
Types ¶
type QueryParam ¶
QueryParam is a struct that holds the key, values and property name for a query parameter it's used for complex query types that need to be parsed and tracked differently depending on the encoding styles used.