Contributor's GitHub alias: Kanchan-Wakchaure
Organization name: Contoso
This widget retrieves the html document from the Azure storage account and displays it's content in the developer portal page.
Sometimes, API descriptions can be long enough including additional information such as Invocation pre-requisites Best practices, Security, Troubleshooting, Parameter values etc. These additional details can be displayed in a separate page in the developer portal.
Additional details for the API are added to a HTML document and stored in the azure storage account. A custom widget (Document details
) is added to page in the developer portal where this HTML document content is rendered.
-
Store/Upload the html document containing additional details for an API into the azure storage account.
-
Keep the access level of this document as either
'Blob(anonymous read access for blobs only)' or 'Container(anonymous read access for containers and blobs)'.
Copy the document-details folder from /community/widgets
and paste in the /api-management-developer-portal
folder
- Copy the URL for html document stored in your storage account and assign it to the constant
'documentApiUrl'
incommunity/widgets/document-details/ko/runtime/document-details-runtime.ts
- Update the value of constant
defaultFileName
indocument-details/constants.ts
so that default content would be displayed in the portal when you add the widget.
Note: You can enter different file name in the editor once widget is added to the portal.
Register widget's modules in the portal's root modules by adding the following lines in the respective files:
-
src/apim.design.module.ts
- a module that registers design-time dependencies.import { DocumentDetailsDesignModule } from "../community/widgets/document-details/documentDetails.design.module"; ... injector.bindModule(new DocumentDetailsDesignModule());
-
src/apim.publish.module.ts
- publish-time dependencies.import { DocumentDetailsPublishModule } from "../community/widgets/document-details/documentDetails.publish.module"; ... injector.bindModule(new DocumentDetailsPublishModule());
-
src/apim.runtime.module.ts
- run-time dependencies.import { DocumentDetailsRuntimeModule } from "../community/widgets/document-details/documentDetails.runtime.module"; ... injector.bindModule(new DocumentDetailsRuntimeModule());
You're now ready to use the document-details widget in the developer portal.
-
Execute the command
npm start
. -
When the application loads, place the new widget on a page. You can find it under the name
Document details
in theCommunity
category in the widget selector. -
Save the page by pressing
Ctrl+S
(or⌘+S
on Apple computers).
Note: In design-time, you can still interact with the website by holding
Ctrl
(or⌘
) key.
You would be able to see the default file content in the portal page.
-
Select the document-details widget added to the page in the portal editor and click anywhere in the widget. You can see the text-editor block in the corner where you can enter the required file name.
-
Enter any file name (HTML document) stored in the storage account and it's content will be rendered in the page.
In real-time scenario, user would usually go to API list page in the portal and then go through the description of API and its documentation details.
In order to read the additional details for the API description in the portal, a link is provided in the API description which would redirect to additional details page in the same developer portal. The custom widget Document details
is added to this page which would render the additional details for the respective API in the portal page.

-
Page name in the portal which would render the additional details(HTML file content from the storage account).
-
Name of the file (HTML document stored in the storage account for the respective API)
For example: If a page 'documentation'
is created in the portal which would render the document 'sample_document.html'
for the API 'Echo API'
then the link in the description of 'Echo API' would be updated as follows:
<a href="documentation#fileName=sample_document.html&&api=Echo API">Click here</a> for the additional details of this API.
2. Add method getFileName()
in src/routing/routeHelper.ts
to get the file name dynamically in the portal
/**
* Returns ARM resource name of the html file specified in hash parameter of the current route, e.g. "sample_document.html".
*/
public getFileName(): string {
return this.getHashParameter("fileName");
}
If you want to replace the file name in documentation details page to API name, then replace the text variable fileName
in the file document-details/ko/runtime/document-details-runtime.html
to `api'.
<h1><span data-bind="text: api"></span></h1>
<p data-bind="html: sessionDescription"></p>