Saturday, December 27, 2014

How to retrieve all APIs docs published on WSO2 API Manager 1.7 environment


WSO2 API manager provides the necessary platform for creating, publishing and managing all aspects of an API and its life cycle. API Manager uses Swagger framework to provide interactive documentation support to help users to clearly understand and experience the APIs.
Hence, WSO2 API Manager stores the API definitions in registry.
       
These API definitions are compatible with Swagger version 1.2. In order to further learn about WSO2 API Manager, you can refer the documentation.

You can view the API documentation definition by logging in to API Store. You have to follow the following steps to achieve this.


  • Log in to API Store.  ( https://[HOST_NAME]:[PORT]/store )
  • It will display all the available APIs. 
  • You can click and visit to an API.
  • Navigate to "API Console".
  • Click on the "Download" link.
  • It will display the api-doc.json ( This compliance with swagger 1.1 ).
  • In order to navigate to API doc definition which compliance with Swagger 1.2, you have to replace the "api-doc.json" part of the URL (final part) with "1.2/default" part.



But in general, users might want to view the API docs by using private Swagger UI for various reasons. 

I have written a sample code on how to get all the API documentations get downloaded for both tenants and super-tenant.

All the API definitions are stored in registry. Only thing you have to do is to log in API Manager first and then next login to store by using admin services provided by WSO2 Carbon.
Next, you have to follow a REST URL provided to access the API definitions stored in registry.

URL formats used to access the API definitions differ based on either tenants or super-tenants.


  1. Super-tenants as API providers. 

             https://[HOST_NAME]:[PORT]/registry/resource/_system/governance/apimgt/
             applicationdata/api-docs/[NAME]-[VERSI0N]-[PROVIDER]/1.2/default 


      2.  Tenants as API providers.

            https://[HOST_NAME]:PORT]/t//registry/resource/_system/
            governance/apimgt/applicationdata/api-docs/[NAME]-[VERSI0N]-                                                 [PROVIDER]/1.2/default

      In abstract what we are  going to do vi program is
   
      [1] Log in to API Manager carbon home
      [2] Retrieve all the tenants.
      [3] Log in to API Store
      [4] Dynamically generate the URLs by using program.
      [5] Retrieve them by simple GET call.

       Source code can be downloaded from here.

No comments:

Post a Comment