asyrjasalo / RESTinstance

Robot Framework library for RESTful JSON APIs
https://asyrjasalo.github.io/RESTinstance
GNU Lesser General Public License v3.0
204 stars 84 forks source link

A new keyword "Last REST Instance" is implemented #105

Open TeddyTeddy opened 3 years ago

TeddyTeddy commented 3 years ago

This keyword allows the very last instance to be written to a file. This becomes handy, when you just made a request and you want to get the instance for it.

A sample usage would be:

*** Keywords ***
Gather Instances While Creating Parameterized Resources
    [Arguments]     ${record list}         ${private token}
    FOR     ${record}    IN      @{record list}
        POST    /projects       body=${record}[json_resource]    headers=${private token}
        Last Rest Instance      file_path=${record}[on_create_instance]      sort_keys=True     # instance for the POST request
    END
asimell commented 3 years ago

@TeddyTeddy This functionality seems to exist already? You can give a file_path argument to Output keyword, which then writes your output into a file.

TeddyTeddy commented 3 years ago

@asimell , as per your comment:

@TeddyTeddy This functionality seems to exist already? You can give a file_path argument to Output keyword, which then writes your output into a file.

Hi! Yes, output keyword does write the request & response schema to a file, but it does not write the whole instance. The instance is a larger entity, which is composed of:

If we want to have the instance as a record into a file, this utility keyword "Last REST Instance" would be helpful.

asyrjasalo commented 3 years ago

I think @asimell is correct. There is a way to achieve above without adding a new keyword.