CRUD flow chaining
Create a record, then read, update and delete that same record.
chainingvariablesoverwritescrud
What it does
Stores the id returned by the create request and injects it into the path of the get, update and delete requests. orderOfOperations runs the requests in create, read, update, delete order, so each step works on real data instead of spec examples.
portman-config.json
{ "version": 1, "tests": { "contractTests": [ { "openApiOperation": "*::/crm/*", "statusSuccess": { "enabled": true }, "schemaValidation": { "enabled": true } } ] }, "assignVariables": [ { "openApiOperation": "POST::/crm/leads", "collectionVariables": [ { "responseBodyProp": "data.id", "name": "leadsAdd.id" } ] } ], "overwrites": [ { "openApiOperation": "GET::/crm/leads/{id}", "overwriteRequestPathVariables": [ { "key": "id", "value": "{{leadsAdd.id}}", "overwrite": true } ] }, { "openApiOperation": "PATCH::/crm/leads/{id}", "overwriteRequestPathVariables": [ { "key": "id", "value": "{{leadsAdd.id}}", "overwrite": true } ] }, { "openApiOperation": "DELETE::/crm/leads/{id}", "overwriteRequestPathVariables": [ { "key": "id", "value": "{{leadsAdd.id}}", "overwrite": true } ] } ], "globals": { "stripResponseExamples": true, "orderOfOperations": [ "POST::/crm/leads", "GET::/crm/leads/{id}", "PATCH::/crm/leads/{id}", "DELETE::/crm/leads/{id}", "GET::/crm/leads" ] }}Run it
terminal
$ npx @apideck/portman -l ./openapi.yaml -c ./portman-config.json -b http://localhost:3050 -n trueNotes
- To chain every resource with one rule, use the template expression name "<tag>Id" with value "{{<tag>Id}}" as shown in the Assign variables docs.
- orderOfOperations sorts requests within their folder, so keep the chained requests under the same tag.