To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Routers
Cancel

The Web API Framework in DataFlex

Lesson 3 - Swagger UI

Swagger UI is a super handy tool that lets you visually explore and test your REST APIs right from your browser — no more switching between apps! It uses the OpenAPI spec (in JSON or YAML) to generate a sleek interface showing your API endpoints, return data, status codes, and even lets you try out requests. Here’s how to set it up and get started:

  1. Step 1: Understand Swagger UI Basics
    • Swagger UI renders your REST APIs using the OpenAPI specification.
    • It’s powered by the Swagger UI JavaScript library wrapped in a DataFlex custom control. 
    • This UI lets you see all your endpoints, response examples, and test the API without extra tools like Postman.
  2. Step 2: Create a Web View for Swagger UI
    • Start by creating an empty web view in your DataFlex application — this will be the container for Swagger UI.
    • You can also embed it inside existing views if needed.
  3. Step 3: Import the Swagger UI Class
    • Import the cSwaggerUI into your web view code so you can instantiate and configure it.
  4. Step 4: Instantiate and Configure Swagger UI
    • Create an instance of the cSwaggerUI class inside your web view.
    • Set important properties like:
      • For example: “/Api/OpenApi” (relative path). 
      • Column span and index: to control the layout and appearance of the UI.
  5. Step 5: Compile and Launch
    • Compile your application and open the web view in a browser.
    • You should now see your API endpoints beautifully rendered by Swagger UI.
  6. Step 6: Explore and Test Your APIs
    • Use the "Try it out" buttons on the endpoints to send real requests and see live responses — all within your browser!
    • Filters allow you to search by fields like description or unit price.
    • Check out example responses and status codes for success and error cases.
    • The interface works like a built-in Postman, so no need for extra tools.
  7. Step 7: Next Steps
    • Your Swagger UI setup is now ready to power API testing and development.

The next lesson will dive into routers, so stay tuned!