I apologize for asking this on the dedicated DEV forum... I am not able to
get any answers elsewhere. I am hoping someone here can guide me.

I am modifying the velocity_template.xml file so that any new API published
will use the input and output transformations that I would need. I am stuck
at the response part due to JSON and $ character. The first block below is
from my velocity_template.xml and second block is from the generated API
from source view. Can someone help me on how I can preserve the entire
expression under <args> section?

/            <payloadFactory media-type="json">
               <format>
                        {
                          "apiName": "$1",
                          "apiVersion": "$2",
                          "runResponse": 
                                {
                                        "runId": "$3",
                                        "runStart": "$4",
                                        "runEnd": "$5",
                                        "flowResponse": "$6",
                                        "flowResult": "$7" 
                                }
                        }                                       
                </format>
               <args>
                  <arg evaluator="xml"
expression="get-property('apiName')"/>
                  <arg evaluator="xml"
expression="get-property('apiVersion')"/>
                  <arg evaluator="json"
expression="$.runResponse.runReturn.item[0].value"/>
                  <arg evaluator="json"
expression="$.runResponse.runReturn.item[3].value"/>
                  <arg evaluator="json"
expression="$.runResponse.runReturn.item[4].value"/>
                  <arg evaluator="json"
expression="$.runResponse.runReturn.item[5].value"/>
                  <arg evaluator="json"
expression="$.runResponse.runReturn.item[6].value"/>
                                  
               </args>
            </payloadFactory>/

*Generated API*

/            <payloadFactory media-type="json">
               <format>
                        {
                          "apiName": "$1",
                          "apiVersion": "$2",
                          "runResponse": 
                                {
                                        "runId": "$3",
                                        "runStart": "$4",
                                        "runEnd": "$5",
                                        "flowResponse": "$6",
                                        "flowResult": "$7" 
                                }
                        }                                       
                </format>
               <args>
                  <arg evaluator="xml"
expression="get-property('apiName')"/>
                  <arg evaluator="xml"
expression="get-property('apiVersion')"/>
                  <arg evaluator="json" expression=".runResponse[0].value"/>
                  <arg evaluator="json" expression=".runResponse[3].value"/>
                  <arg evaluator="json" expression=".runResponse[4].value"/>
                  <arg evaluator="json" expression=".runResponse[5].value"/>
                  <arg evaluator="json" expression=".runResponse[6].value"/>
               </args>
            </payloadFactory>/




--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/API-Manager-1-8-0-Help-with-velocity-template-file-tp111988.html
Sent from the WSO2 Development mailing list archive at Nabble.com.
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to