I have created a WADL for import into SmartDocs (see below).
When I place the param elements inside of the representation element, I cannot see any parameters at all in SmartDocs.
With the version below (params appear outside of the method element), I can see the parameters in SmartDocs, but they are sent in the querystring, rather than in the request body. And the params that have a default value are not sent at all, not even in the querystring.
How do I get all the parameters to be sent as form data?
<resource path="oauth/v2/accesstoken"> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="grant_type" style="query" default="authorization_code"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="code" style="query"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="client_id" style="query" default="CxTsuE36CG0PVGnOhZiqJPw0x6uEAAiv"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="client_secret" style="query" default="YteFcBy4814u8vUC"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="redirect_uri" style="query" default="http://demo26-test.apigee.net/identity_app/callback"> </param> <method id="accesstoken" name="POST" apigee:displayName="Access Token"> <apigee:tags> <apigee:tag primary="true">Access Token</apigee:tag> </apigee:tags> <apigee:authentication required="false"/> <doc apigee:url="http://demo26-test.apigee.net/oauth/v2/accesstoken"> Returns an access token. </doc> <request> <representation mediaType="application/x-www-form-urlencoded"> <apigee:payload required="true"> <apigee:content> </apigee> </apigee> </representation> </request> </method> </resource>
Answer by Lee Grey · Jan 09, 2015 at 04:08 AM
I'm sure this is not the "right" way, but I was able to get a successful response using this. The SmartDocs experience of providing the value for code is definitely not the way it should be.
I would like to know how an expert would do this.
<resource path="oauth/v2/accesstoken"> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="grant_type" style="query" default="authorization_code"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="code" style="template"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="client_id" style="query" default="CxTsuE36CG0PVGnOhZiqJPw0x6uEAAiv"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="client_secret" style="query" default="YteFcBy4814u8vUC"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="redirect_uri" style="query" default="http://demo26-test.apigee.net/identity_app/callback"> </param> <method id="accesstoken" name="POST" apigee:displayName="Access Token"> <apigee:tags> <apigee:tag primary="true">Access Token</apigee:tag> </apigee:tags> <apigee:authentication required="false"/> <doc apigee:url="http://demo26-test.apigee.net/oauth/v2/accesstoken"> Returns an access token. </doc> <request> <representation mediaType="application/x-www-form-urlencoded"> <apigee:payload required="true"> <apigee:content> <![CDATA[grant_type=authorization_code&client_id=CxTsuE36CG0PVGnOhZiqJPw0x6uEAAiv&client_secret=YteFcBy4814u8vUC&redirect_uri=http://demo26-test.apigee.net/identity_app/callback&code={code}]]> </apigee:content> </apigee:payload> </representation> </request> </method> </resource>
@Lee Grey I'm trying to implement the same thing, however it did not work fine. while trying to import it it display the error:
WADL is invalid. Expected element 'response@http://wadl.dev.java.net/2009/02' instead of 'doc@http://wadl.dev.java.net/2009/02' here in element method@http://wadl.dev.java.net/2009/02
any idea of suggestion?
Answer by Lee Grey · Jan 09, 2015 at 03:55 AM
Here's a better code sample:
<resource path="oauth/v2/accesstoken"> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="grant_type" style="query" default="authorization_code"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="code" style="query"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="client_id" style="query" default="CxTsuE36CG0PVGnOhZiqJPw0x6uEAAiv"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="client_secret" style="query" default="YteFcBy4814u8vUC"> </param> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" name="redirect_uri" style="query" default="http://demo26-test.apigee.net/identity_app/callback"> </param> <method id="accesstoken" name="POST" apigee:displayName="Access Token"> <apigee:tags> <apigee:tag primary="true">Access Token</apigee:tag> </apigee:tags> <apigee:authentication required="false"/> <doc apigee:url="http://demo26-test.apigee.net/oauth/v2/accesstoken"> Returns an access token. </doc> <request> <representation mediaType="application/x-www-form-urlencoded"> </representation> </request> </method> </resource>
Answer by Lee Grey · Oct 20, 2015 at 11:21 PM
Hi, @simplea. It's been a while since I've used WADL; I'm focused on Swagger now, which I highly recommend. (You can create Swagger at http://apistudio.io )
I recall that I ran into an issue with the order of the elements, and the error message was similar to the one you posted. I found that I had to swap the order of the params and method elements within a resource for the API Console to be able to read the WADL. I'm not certain that this is related to what you are seeing, but I'm hoping that it might point you in the right direction.
If that hint is not helpful, I would suggest that you try to upload a simplified WADL here that recreates the problem.
any automate process for wadl/swagger? 2 Answers
Unable to import WADL 5 Answers
Getting error in request and response during the dev testing 2 Answers
How do you delete a smardocs model revision? 2 Answers
How does Smartdocs interact with Edge? 2 Answers