Reputation: 2050
Are there plans for enabling PAW to generate code from the JSON response? Or exponse a javascript API to do that? I would like to generate obj-c or swift classes based on the response.
Upvotes: 5
Views: 430
Reputation: 3481
It's true that no code generator does that, but the JavaScript API exists, you can see here the Overview of what's possible and here's the full API Reference. Here's also a quick tutorial on how to make a code generator in Paw.
Here's a snippet on how to get JSON from the latest HTTP response of a given request:
var MyCodeGenerator = function() {
this.generate = function(context) {
var responseBody = context.getCurrentRequest().getLastExchange().responseBody;
var responseObject = JSON.parse(responseBody); // JSON object
return JSON.stringify(responseObject); // just an example
};
}
MyCodeGenerator.identifier = "com.mycompany.MyCodeGenerator";
MyCodeGenerator.title = "My Code Generator";
Upvotes: 0