Response Variables

Request Data

You can use variable data in response. The variables will be defined as tags like this

Request data: Use them if you want to add request data in your response.

  • request.scheme
  • request.hostname
  • request.port
  • request.path (full path)
  • request.path."key"
  • request.query."key"
  • request.cookie."key"
  • request.fragment
  • request.url (full url with scheme, hostname, port, path and query parameters)
  • request.autority (return scheme, hostname and port (optional))
  • request.body

You can extract information from the request body too, using a dot notation path:

  • request.body."key" (support for application/json, application/xml and application/x-www-form-urlencoded requests)
  • request.body."deep"."key" (support for application/json, application/xml requests)

Quick overview of the path syntax available to extract values form the request: https://github.com/tidwall/gjson#path-syntax

External streams: Perfect for embedding big payloads or getting data from another service.

  • file.contents(FILE_PATH)
  • http.contents(URL)

Fake Data

Monster Mock provides a rich set of random variables that you can use in your mock response in other to make them more realistic.

  • fake.Brand
  • fake.Character
  • fake.Characters
  • fake.CharactersN(n)
  • fake.City
  • fake.Color
  • fake.Company
  • fake.Continent
  • fake.Country
  • fake.CreditCardVisa
  • fake.CreditCardMasterCard
  • fake.CreditCardAmericanExpress
  • fake.Currency
  • fake.CurrencyCode
  • fake.Day
  • fake.Digits
  • fake.DigitsN(n)
  • fake.EmailAddress
  • fake.FirstName
  • fake.FullName
  • fake.LastName
  • fake.Gender
  • fake.Hex(n) - random hexidecimal string n characters in length
  • fake.IPv4
  • fake.Language
  • fake.Model
  • fake.Month
  • fake.Year
  • fake.Paragraph
  • fake.Paragraphs
  • fake.ParagraphsN(n)
  • fake.Phone
  • fake.Product
  • fake.Sentence
  • fake.Sentences
  • fake.SentencesN(n)
  • fake.SimplePassword
  • fake.State
  • fake.StateAbbrev
  • fake.Street
  • fake.StreetAddress
  • fake.UserName
  • fake.WeekDay
  • fake.Word
  • fake.Words
  • fake.WordsN(n)
  • fake.Zip
  • fake.Int(n) - random positive integer less than or equal to n
  • fake.IntMinMax(min, max) - random positive number greater or equal to min and less than max
  • fake.Float(n) - random positive floating point number less than n
  • fake.UUID - generates a unique id