-
I'm learning how to use # Set a general rule to assign a postman <tab>id variable from the response bodies
# of any POST or GET requests
assignVariables:
- openApiOperation: POST::*
collectionVariables:
- responseBodyProp: id
name: <tag>Id
- openApiOperation: GET::*
excludeForOperations:
- "GET::/*/{id}"
collectionVariables:
- responseBodyProp: <tag>[0].id
name: <tag>Id
# Set a general rule to use the most recently assigned id variable from the
# previous POST or GET request as the id to use in any requests that take an id
overwrites:
- openApiOperation: "*::/*/{id}"
overwriteRequestPathVariables:
- key: id
value: '{{<tag>Id}}'
overwrite: true Is it possible to do any customized logic when assigning variables? For example, I might want to check if a Postman environment variable As another example, I might want to walk a list of objects in a responseBody and examine each object's I think it would be possible to do something like this using the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There is no option to assign variables based on certain conditions, except for the "openApiOperation". Your best option would be using the "extendTests", which can be used to inject any custom script (you can even put them in JS files and Both mentioned cases ( However, you can assign a specific response property, based on if exist or not. But it will not evaluate the content of the response property. For validation of the content of the response properties, you can use https://github.com/apideck-libraries/portman?tab=readme-ov-file#portman---contenttests-properties but that is to build test cases, not to apply logic for assigning variables. |
Beta Was this translation helpful? Give feedback.
There is no option to assign variables based on certain conditions, except for the "openApiOperation".
The objective was to let Portman generate static scripts, tests, variables,... based on the OpenAPI content
Your best option would be using the "extendTests", which can be used to inject any custom script (you can even put them in JS files and
file:
reference, for easier management of the scripts of "extendTests").Both mentioned cases (
isMockServer
orcolor
) are very specific and best scenario's for "extendTests".However, you can assign a specific response property, based on if exist or not. But it will not evaluate the content of the response property.
For validation of the content of…