+ Start a Discussion
SandrineSandrine 

How to generate a swagger from Salesforce

Hello,

A third party application wants to read data from Salesforce.
So i will expose the salesforce.

They plan to read the data with POST.

How can i give the swagger to them ?
URL and sample JSON

Thank you in advance for suggestions
Best Answer chosen by Sandrine
SandhyaSandhya (Salesforce Developers) 
Hi,

You can refer to below salesforce document which has the steps for the same.

https://developer.salesforce.com/blogs/2018/04/connecting-to-swagger-backed-apis-with-clicks-or-code.html
 
   Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

You can refer to below salesforce document which has the steps for the same.

https://developer.salesforce.com/blogs/2018/04/connecting-to-swagger-backed-apis-with-clicks-or-code.html
 
   Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
This was selected as the best answer
Ken Koellner 7Ken Koellner 7
Doesn't the solution above provide how to all out from Apex to a out to a REST service defined by swagger?

Suppose you want to write a service in SF in APEX that is called from elsewhere into SF and you want the interface defined by swagger, and possibly do some code generation.  Is there any tooling to do that?

 
HerisonANDRIAMIHAJAHerisonANDRIAMIHAJA
I agree with Ken.
The purpose is: I have an Apex Class, REST Services. I want to generate the swagger file from that class.
Salesforce Developer 418Salesforce Developer 418
Turns out this is a feature coming this Spring
 
Spring 21 Release Notes Open API 3.0 Specification (Pilot) (https://help.salesforce.com/articleView?id=release-notes.rn_api_openapi_spec_pilot.htm&type=5&release=230)
Ken Koellner 7Ken Koellner 7

"I have an Apex Class, REST Services. I want to generate the swagger file from that class.'

"With this pilot, you can now generate an OpenAPI 3.0 specification that describes the four most commonly used sObject resources. The generated specification reflects your org’s unique endpoints and object customizations."  

That doesn't sound at all like what apex2wsdl does generating WSDL from a class.  It sounds more analogous to what generating the Enterprise WSDL does but only for four objects.  It sounds like what it will do is assuming you use SF's built-in REST services, you could get swagger for those four objects.  If you have some value-added layer written in Apex with REST annotarion, it doesn't sound like there's anything for that yet.  But if anyone knows more, feel free to respond with corrections.

For better-or-worse, SF likes to be a two-tiered system where the data is the API.  It wants you to talk to the objects directly.  The pros and cons of that paradigm, you could write books about it.