Skip to content

Using variable nested in helper #699

@iFederx

Description

@iFederx

Bug description

I'm not sure if this is a bug, maybe it's my fault.
I'm trying to create a mock for an API that returns a list of transactions.
Within each transaction I get the fields authorized amount and captured amount. The captured amount must be a causal number, but must not exceed the authorized amount.

To Reproduce

To achieve this, I've written the template below (application/json):

{
    "list": [
      {{# repeat (queryParam 'limit' '10') }}
          {{setVar 'amount' (faker 'datatype.number' min=100000 max=9999999999)}}
          {
              "amount": {
                "authorizedAmount": {{@amount}},
                "capturedAmount": {{int 100000 @amount}},
                "fee": 0,
                "currency": "EUR"
              },
              [...]
          }
      {{/ repeat }}

    ]
  }
}

but it seems that the higher limit @amount isn't considered.

How can I achieve the desired result?

Mockoon version:

1.18.1

OS / OS version:

Windows 10

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

✅ Done (ready for next release)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions