processing

processing

Methods

determineQueryType(param) → {string}

Source:
Determines the proper type for the Query parameter
Parameters:
Name Type Description
param object sway Parameter object to investigate
Returns:
Type
string

isNumberType(type) → {boolean}

Source:
evaluates if the given type is an OpenAPI number type or not
Parameters:
Name Type Description
type string type to be evaluated
Returns:
Type
boolean

lookupCustomQueryValue(code, op, path, options) → {any}

Source:
resolves any custom query values available for the given operation and path
Parameters:
Name Type Description
code number response status code being evaluated
op string the operation method being processed
path string API path being processed
options object for use in looking up the custom value
Returns:
Type
any

lookupCustomValue(name, location, code, op, path, options) → {any}

Source:
resolves any custom values available for the given parameter
Parameters:
Name Type Description
name string parameter name being looked up
location string where the parameter is in the request/response
code number response status code being evaluated
op string the operation method being processed
path string API path being processed
options object for use in looking up the custom value
Returns:
Type
any

pathify(path, param, value) → {string}

Source:
replaces the path paremeter in the given URL path with a sample value
Parameters:
Name Type Description
path string URL path to be pathified
param object sway Parameter object to use in pathify
value string | number a custom value to use in the pathify
Returns:
Type
string

process(api, options) → {processing.ProcessedSpec}

Source:
Processes the given API spec, creating test data artifacts
Parameters:
Name Type Description
api object API spec object to be processed
options object options to be used during processing
Returns:
Type
processing.ProcessedSpec

processHeaders(responseCode, op, path, top, options) → {object}

Source:
Determines the request headers for a transaction
Parameters:
Name Type Description
responseCode string response code being processed
op object parent operation object
path object parent path object
top object global properties
options object for use in processing headers
Returns:
Type
object

processOperations(api, parentPath, topLevel, options) → {Array.<processing.ProcessedOp>}

Source:
Processes the operations of the given Path object
Parameters:
Name Type Description
api object parsed OpenAPI spec object
parentPath object sway Path object being processed
topLevel object global spec properties
options object options to use during processing
Returns:
Type
Array.<processing.ProcessedOp>

processParams(code, op, path, options) → {processing.ProcessedParams}

Source:
Processes the parameters of a Path + Operation for use in a test
Parameters:
Name Type Description
code number response status code being processed
op object sway Operation object that's being processed
path object sway Path object that's being process
options object options to use during processing
Returns:
Type
processing.ProcessedParams

processPaths(api, topLevel, options) → {Array.<processing.ProcessedPath>}

Source:
Processes the paths defined by the api spec, or indicated by the options
Parameters:
Name Type Description
api object parsed OpenAPI spec object
topLevel object global spec properties
options object options to use during processing
Returns:
Type
Array.<processing.ProcessedPath>

processResponse(res, op, path, options) → {processing.ExpectedResponse}

Source:
Processes a sway Response for use in a test
Parameters:
Name Type Description
res object sway Response object being processed
op string the operation method being processed
path string API path being processed
options object options to use during processing
Returns:
Type
processing.ExpectedResponse

processTransactions(api, parentOp, parentPath, topLevel, options) → {Array.<processing.ProcessedTransaction>}

Source:
Processes the transactions for a given Path + Operation
Parameters:
Name Type Description
api object parsed OpenAPI spec object
parentOp object parent sway Operation object being processed
parentPath object parent sway Path object being processed
topLevel object global spec properties
options object options to use during processing
Returns:
Type
Array.<processing.ProcessedTransaction>

replaceNewlines(str) → {string}

Source:
Used to replace newlines with a space in each response.description
Parameters:
Name Type Description
str string string to replace newlines with spaces
Returns:
Type
string

Type Definitions

ExpectedResponse

Source:
Properties:
Name Type Description
statusCode number expected response status code
custom boolean indicates if the value was a custom injection
res object expected response body, if applicable; can be a generated sample
ExpectedResponse is the expected response generated based on the API spec
Type:
  • object

ProcessedParams

Source:
Properties:
Name Type Description
path string processed path with path parameter sample substitutions
body object the request body params
query object the request query params
formData object the request form data params
ProcessedParams is an object representing the processed request parameters for unit test compilation
Type:
  • object

ProcessedPath

Source:
Properties:
Name Type Description
name string name to be used in generation of a file name; based on the path
pathLevelDescription string the brief description to use at the top level 'describe' block
operations Array.<processing.ProcessedOp> Collection of operations processed for test compilation
ProcessedPath is the fully traversed path resource ready for unit test compilation
Type:
  • object

ProcessedSpec

Source:
Properties:
Name Type Description
host string Hostname to be used in the test requests; derived from the options or spec
scheme string HTTP schema to be used in the test requests; derived from the spec
basePath string Base path as defined by the spec
consumes Array.<string> Global content type 'consumes' collection
tests Array.<ProcessedPath> Collection of paths processed for test compilation
ProcessedSpec is the fully traversed spec processed for unit test compilation
Type:
  • object

ProcessedTransaction

Source:
Properties:
Name Type Description
testLevelDescription string the brief description to use in the test 'it' block
scheme string copied from the globally defined HTTP schema
host string copied from the globally defined hostname or as specified in the options
path string fully qualified path built with the base path; includes path param substitutions
op op the REST operation to use
body object the request body params
query object the request query params
formData object the request form data params
expected ExpectedResponse the expected response to use for test validation
hasSamples boolean flag indicating if the expected response includes sample values
consumes Array.<string> based on globally defined conumes or operation defined types
ProcessedTransaction is an HTTP transaction (request/response pair) processed for test compilation
Type:
  • object

ProcessedOp

Source:
Properties:
Name Type Description
operationLevelDescription string the brief description to use at the inner 'describe' block
transactions Array.<processing.ProcessedTransaction> Collection of transactions processed for test compilation
ProcessedOp is the fully traversed path operation ready for unit test compilation
Type:
  • object