Jerrod Horton
Jerrod Horton

Reputation: 1692

APEX Rest API - Swagger

I am a bit new to the whole APEX service plugins but I was wondering if Salesforce has native support for Swagger, or any similar REST description language, for the REST api's that I create in the APEX service platform?

For example:

@RestResource(urlMapping='/v1/users/*')
global with sharing class UserRestService {
  ...
  @HttpGet
  global static List<Member__c> doGet(....)
  {
     ...
  }
}

I would like the ability to return the swagger json, a WADL document, or something for this REST service (and all other REST services I have in there). Does anyone know of a way I can do this?

Thanks in advance!

Upvotes: 1

Views: 1327

Answers (2)

Nicolas Despr&#233;s
Nicolas Despr&#233;s

Reputation: 1517

There is a free tool called SF Explorer that do this. Disclaimer: I am the author of this tool

Upvotes: 0

Modular
Modular

Reputation: 81

There is no built in support at this time. I was interested in seeing what could be done via currently available public APIs. The first thing I ran into is the grammar does not seem to like parameters to HttpGet methods. That right there will make it challenging since the only way to get input parameters appears to be via the Request entity which means you would have to parse the actual code. In other words, there does not appear to be declarative input binding.

Further, in looking at the tooling API which let's me get some amount of "reflective" information about the class, there is not always sufficient information to render a response payload (in your case, it just shows LIST but not what's in the list)

Again, it looks like one would have to rely on a parser (there is at least one Antl grammar floating around).

(this is getting some internal attention but I can't say any more at this time)

Upvotes: 1

Related Questions