curl-runnings-0.16.0: A framework for declaratively writing curl based API tests

Safe HaskellNone
LanguageHaskell2010

Testing.CurlRunnings.Internal.Payload

Description

A module defining the Payload type. This is used in specifications to represent request body data. Currently JSON and URLEncoded bodies are supported.

The module provides a FromJSON instance to parse a Payload from a specification.

Payload is parsed from an object containing two keys: bodyType and content.

The value of the bodyType field must be either json or urlencoded and this indicates how the request data should be encoded.

When bodyType is `urlencoded ` the value of the content field must be an object with string, numeric or boolean values.

When bodyType is json the value of the content field will be used as the JSON payload.

If bodyType is not present then the whole object is used as the JSON payload.

Examples: 1. A URLEncoded request payload:

 requestData:
    bodyType: urlencoded
    content:
      key1: value
      key2: true
      key3: 10.22

2: A JSON request payload using bodyType:

 requestData:
    bodyType: json
    content:
      key1: value
      key2: [1,2,3]

3: A JSON request payload without using bodyType:

 requestData:
    key1: value
    key2: [1,2,3]

Documentation