Once you add a Swagger asset, which is associated with a lively available REST service to WSO2 Governance Registry, you can invoke it using the in-built Swagger UI in WSO2 G-Reg by copying its URL to Clipboard as explained below.
Adding the Swagger file
Follow the steps below to add the underlying Swagger file of then sample publicly available live REST Service that we use in this guide, to WSO2 G-Reg. For more information on adding a REST Service to WSO2 G-Reg, see Adding a REST Service.
- Log in to the G-Reg Publisher using the following URL and admin/admin credentials: https://<G-REG_HOST>:<G-REG_PORT>/publisher
- Click the main menu button of the G-Reg Publisher, and then click Swaggers as shown below.
- Click the following ADD button:
- Select Upload Swagger from a file as shown below.
- Click Browse to select the Swagger file to upload it, and then specify its version as shown below.
- Click Create.
- Refresh the screen to view the new Swagger artifact you added as shown below.
-
Viewing the dependencies of the added Swagger
Follow the steps below to view how the added REST Service, Swagger, and Endpoint are created and linked together using the provided dependency view. For more information on viewing dependencies between assets, see Viewing Dependencies of Artifacts.
- Click the Swagger artifact which you created above.
- Click the following Show Dependency button:
You view the dependencies of the selected artifact as shown below.
Invoking the Service using the in-built Swagger UI
Follow the steps below to invoke the added service using the in-built Swagger UI.
- Click the following Go to Store button in the top right hand corner of the G-Reg Publisher Home Page, to access the G-Rg Store:
- Log in to the G-Reg Store using the following URL and admin/admin credentials: https://<G-REG_HOST>:<G-REG_PORT>/store
- Click Swaggers in the main menu as shown below.
- Click the Swagger which you added as shown below.
- Click the following Swagger UI button, to invoke the Service using the in-built Swagger UI:
- Click the pet link in the Swagger UI, and then click on the GET /pet/{petId} box to expand it as shown below.
- Enter a value for petId, and click the Try it out! button as shown below, to make an invocation.
Click the icon next to the address bar of your browser, and then click Load unsafe scripts (if you are using Google Chrome) as shown below.
This step is required to enable scripts from unauthenticated sources since by default they are blocked in Web browsers as a standard. Hence, if your page supports http, it will not allow to load content which uses the https protocol and vice versa. You will view different message pop-ups depending on the Web browser you use. For more information on this, see Chrome and Firefox: Blocked Mixed (HTTPS and HTTP) Content.
- Repeat steps 6 and 7 above. You view the response of the Service invocation as shown below.