Skip to main content

Swagger is a powerful interface for exploring and testing the OpCon API. It allows users to interact with API endpoints directly from a browser, making it ideal for learning, debugging, and validating API calls.

🔐Accessing Swagger

To access the Swagger interface, use the following URL format:

https://<YourServername>/api/doc/index-html

 Replace <your-server> with the actual server name hosting your OpCon environment. This URL opens the Swagger documentation and testing interface for the OpCon API.

🌠Features of Swagger

Swagger provides the following capabilities:

  • Browse available API endpoints grouped by functionality.
  • View detailed request and response formats.
  • Authenticate using tokens to test secure endpoints.
  • Execute API calls directly from the browser

✅Authenticating in Swagger

To test endpoints that require authentication, use the 'Authorize' button in Swagger. When prompted, enter your token prefixed with the word 'Token' followed by a space.

Token <your-token-here>

Ensure there is a space between 'Token' and your actual token value. This format is required for successful authentication.

Example: Get API Version

One of the simplest endpoints to test is the version endpoint. It does not require authentication and returns the current API version.

GET /version

 

To test this endpoint in Swagger:

  1. Scroll to the 'version' section.
  2. Click on the endpoint to expand it.
  3. Click 'Try it out' and then 'Execute'.
  4. View the response to see the API version.

💡Tips for Using Swagger

  • Use Swagger to validate request formats before scripting.
  • Check response codes and messages for debugging.
  • Use the built-in 'Try it out' feature to experiment with different inputs.
     
Be the first to reply!

Reply