Argument
This element comprises of the details about parameter, header and variables of the resource.
Possible Locations
Child Elements
- Deprecate
- Description
- Content required recurrent
Attributes
Name | Type | Description |
---|---|---|
name required |
String | Name of the argument. |
required | Boolean | It represents the requirement status of an argument in the resource.
|
length | Integer (CSV) | Indicates the minimum and maximum number of values separated by a comma. You can also provide only the maximum value. |
location required |
String (enum) | Location of the argument for your resource. The possible values are param, header, variable. |
delimiter | String | Represents the delimiter for multiple values in an argument. |
style | String (enum) | The separator style that ZEST should use to separate the list of arguments. The possible values are:
|
condition | String | The condition which needs to be true in order to accept the arguments. Check here to learn more about condition. |
concurrent | String (CSV) | Name of the argument which must be passed simultaneously with this argument. |
non-concurrent | String (CSV) | Name of the argument that must not be allowed to pass simultaneously with this argument. |
visibility | String (enum) | Decides who can view and use the element. The possible values are internal, private, public. The default value is public. |
If you are writing an argument for the URL path variable, the name attribute of the argument should be as same as the variable name provided in the url. For instance, /travel_bureau/v4/trips/{id} is an URL path and the argument name should be id (name of url path variable).
Samples
Simple Argument
For the trips resource, you want to add two parameters. Following are the details of it,
copy- destination: Possible values are destination names from the destinations resource. This parameter is mandatory and accepts a character length of 1 to 20. - include: Possible value is 'adventure_activities'. The key adventure_activities should be visible in the response only if this parameter is present in the request.
Here is the argument for the first requirement,
copy<argument name="destination" location="param" required="true"> <content> <encode type="text/plain" /> <structure> <property type="string" path="destinations:$.destination_name" length="1,20" /> </structure> </content> </argument>
Now, for the second requirement, construct the argument as follows:
copy<argument name="include" location="param"> <content> <encode type="text/plain" /> <structure> <property type="string" values="adventure_activities" /> </structure> </content> </argument>
For the adventure_activities <property> to appear only when this argument is used, you need to add the condition-for-response attribute in the property.
copy<property name="adventure_activities" type="collections" condition-for-response="REQUEST:$.params.include != null" />
Refer to the data path and conditions pages to learn more about the construction of conditions and data path used in this sample.
Complex Argument
For the same trips resource, you want to configure three other arguments. Following are the requirements for the parameters,
copy- travelers: Possible values are traveler names from travelers resource. This is a mandatory parameter and supports CSV . It can have a minimum of 1 and maximum of 10 values. - page: This parameter must not be picked along with the travelers parameter. This should be of integer type. The value can fall between 1 to 500. - page_token: This parameter must be picked with the page parameter only when its value is greater than 11. This should be of string type.
Now, write the argument with the necessary attributes to obtain these requirements as shown here.
copy<argument name="travelers" location="param" required="true" length="1,50" style="delimiter" delimiter="," non-concurrent="page"> <content> <encode type="text/plain" /> <structure> <property type="string" path="travelers:$.traveler_name"/> </structure> </content> </argument> <argument name="page" location="param" non-concurrent="travelers" concurrent="page"> <content> <encode type="text/plain" /> <structure> <property type="integer" range="1,500"/> </structure> </content> </argument> <argument name="page_token" location="param" concurrent="page" condition="REQUEST:$.params.page > 10"> <content> <encode type="text/plain" /> <structure> <property type="string"/> </structure> </content> </argument>
Last Updated 2025-05-30 16:54:59 +0530 +0530
Yes
No
Send your feedback to us