Loading...

Salesforce REST API lets you integrate Salesforce into the External system. With REST API

we can expose our salesforce org data to an external system or we can fetch data from an external system into the Salesforce org.

Now if we have created any API in our system then we have to test it if it is working fine for users. Several methods exist for testing APIs, but Swagger is a popular one.

Swagger is one of the tools for documenting API. You can test your API right in the documentation using Swagger. JSON or YAML can be used to define Swagger definitions.

So here in this blog, we tried to let you know how to configure your org so that you can test your APIs using swagger. Let’s begin

Complete guide to test APIs using Swagger

Here we are using a “httpget” request to make you familiar with how we can use the swagger API tool for exposing salesforce org data to an external system.

In this scenario, we hit a get request in the swagger editor and it will give us the order list in the form of JSON.

Here are the steps:

Step 1. First, make your apex class available for the Rest web services by using a global specifier for both class and method.

Code of APEX class

Step 2. Now in Setup go to the quick find box and type sites

Complete guide to test APIs using Swagger

Step 3. If you are not having any sites please create one and if you are having sites please select any site. Here we will permit the external user to access our class.

Complete guide to test APIs using Swagger1

Step 4. After selecting the sites click on “Public Access Settings”.

Complete guide to test APIs using Swagger2

   Step 5. Here click on “Enabled Apex Class Access”

Complete guide to test APIs using Swagger3

Step 6. Here we are going to add the apex class so click on edit.

Complete guide to test APIs using Swagger4

Step 7. Select the apex class which you have created as an API and add it

Complete guide to test APIs using Swagger5

Step 8. Now after adding the class to the site user we still have to add the swagger site to CORS so that the swagger website is able to access our org. So go to the quick find box and type CORS

Complete guide to test APIs using Swagger6

Step 9. Click on the New button

Complete guide to test APIs using Swagger7

Step 10. Add this Url to CORS

Complete guide to test APIs using Swagger8

Step 11.Create a Swagger file

Here we are done with our setting now we have to create a Swagger file for this go to this link and create a new file.

(i) Here first we have swagger as a starting element and its version must be not more than 2.0.
(ii) now in info define any version and title of your choice.
(iii) In the host tag define your org URL while in the path tag defines your base path and add /service/apexrest as it is necessary to hit APEX APIs.
(iv) after that in path define the URL/path that you have mentioned in your class. And start coding

As per the need of your class.

Complete guide to test APIs using Swagger9

Swagger Code:

Step 12. Once your swagger code is complete, on the right side you will get the UI to work on.

Here just for testing purposes paste our code and you will get a list of orders from our org. Click on GET Button and you will get the result.

Complete guide to test APIs using Swagger10

Step 13. Click on Execute Button and it will hit the API whose URL is provided in the swagger method.

Complete guide to test APIs using Swagger11

Step 14. Here you will get the response depending on the response body you have sent by your apex class.

Complete guide to test APIs using Swagger12

Conclusion

So, here it is, a complete guide on using Swagger to test APIs in salesforce.

We’d love to hear about your experience with the solution. Keep an eye out for more interesting Salesforce development solutions on our blogs and Stay tuned for the next one. Happy Learning!

No Data Found.

Related Articles
Design and Implementation of Salesforce Jira Task Integration 1 1

Businesses have been using Salesforce for CRM operations and Jira for Agile project tracking. However, without integration, teams manually update both systems, leading to data inconsistency and inefficiency.This mechanism establishes a real-time integration between Salesforce and Jira, allowing seamless synchronization of tasks and agile board statuses.  A custom Salesforce dashboard was developed that replicates Jira-style […]

Read More
Dark Mode in Salesforce Enabling It and Creating Theme Ready Lightning Web Components with SLDS 2.0 1 1

With the Winter ’26 release, Salesforce introduced Dark Mode in Lightning Experience. Dark Mode has been introduced as a beta feature in Winter ’26, and at first it was available only for Starter Edition orgs. It is now rolling out further with Spring ’26 to Professional, Enterprise, and Developer editions. To use Dark Mode, Salesforce […]

Read More
How to Merge and Brand PDF Files in Salesforce Using LWC Visualforce PDF LIB 1

Salesforce developers frequently encounter document automation requirements that go beyond standard Apex-based PDF generation. From merging multiple ContentVersion files to dynamically applying branding like watermarks and headers, traditional server-side approaches often hit Salesforce heap size limits (6MB/12MB), creating performance and scalability challenges. This guide presents a heap-limit-safe PDF merging architecture in Salesforce using Lightning Web […]

Read More
Building a Reusable Popup Modal Architecture in Salesforce LWC 02 1

Modern Salesforce applications frequently rely on popup modals for confirmations, warnings, access control decisions, and destructive actions. However, building modal logic separately inside every Lightning Web Component often leads to duplicated code, inconsistent user experiences, and growing technical debt. This blog introduces a flexible popup modal architecture in Lightning Web Components (LWC) that centralizes modal […]

Read More
How to Add a Lookup Recipient in a Sign Template

This step-by-step guide will provide you with quick steps on how to add a lookup recipient inside a sign template in just a few easy steps. This process improves your eSignature for Salesforce workflow by pulling recipients directly from related records. Whether you rely on Salesforce digital signature features or any eSignature integration, adding lookup […]

Read More
Agentforce VS code

As Salesforce continues to move toward AI-assisted development, Agentforce is emerging as a powerful tool that helps developers interact with their org metadata, objects, and configurations using intelligent prompts. When combined with Visual Studio Code (VS Code) and the Salesforce CLI, Agentforce enables a faster, more context-aware way to explore and build on the Salesforce […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818