eykrehbein / strest

⚡️ CI-ready tests for REST APIs configured in YAML
MIT License
1.74k stars 59 forks source link

Allow usage of array data from previous responses in Value() #41

Closed adiman9 closed 6 years ago

adiman9 commented 6 years ago

I found that I had a use case where I needed to take an id from an object that was part of an array in a response and use that id to test the next endpoint.

datalist: [
    {
       "id": "someId",
       "data": "some data"
    }
]

I then wanted to be able to do this inside the next request:

data:
   json:
      id: Value(myPreviousRequest.datalist[0].id)

This PR implements that functionality and allows for arbitrary nesting of arrays.

jgroom33 commented 6 years ago

I think this already works with the following syntax: Value(myPreviousRequest.datalist.0.id)

adiman9 commented 6 years ago

ahh ye, that would make sense actually. But it is really not the most intuitive way to having it work.

jgroom33 commented 6 years ago

well, now both work 👍

jgroom33 commented 5 years ago

disregard: <$ foo.bar.0.baz $> does not work <$ foo.bar[0]baz $> does not work <$ foo.bar[0]['baz'] $> does work <$ foo.bar[0].baz $> does work