Add and maintain authored API documentation and/or generated API documentation.
Note: For information about tagging API documentation for visibility by different audiences, see API Documentation Tagging.
You'll need to develop your API documentation outside the platform in your own HTML editor. Once your content is ready you can upload it to the site.
In Default Theme, you can upload documentation for a specific API if you are logged in and have one of the following roles:
API documentation for Simple Dev Theme must be uploaded by the Site Admin in Default Theme.
You can add documentation for your API to the API > Documents section in two ways:
If you add a new API version, you can update the existing documentation or create an entirely different set of documents. By default, all documentation files reside in the same folder.
Here are a couple of approaches you could take to maintain files from different versions within the same folder structure:
You can link to any external site from your API documentation. For example, if you already have a website established for your API and/or your documentation, you could upload a file with some introductory text and a link to direct users to your website for the information about your API.
Remember to use the "target="_blank" attribute on the link so that the documentation site opens in a new window rather than replacing the platform user interface. For examples, see Can I link to an external site?
The platform provides a detailed set of content development guidelines for API documentation, including publishing, editing, styles, content organization, file upload, testing, and updating. For details, see Content Development Guidelines.
You can upload HTML files and associated images, PDF files, or other content to the API > Documents section of the platform using the File Manager.
At minimum, you should provide the following files that are the entry point to your API documentation:
There are two approaches to file upload:
For Default Theme, the API Admin can upload the files following the procedure below.
For Simple Dev theme, the Site Admin must upload the files in Default Theme: Administration > Config > Resources > Content File Manager, in a folder below the content folder. The Site Admin must use or create a folder named documentation (so the path is content/documentation). As soon as the files are uploaded in Default Theme, they are immediately visible in Simple Dev theme. Just log in and click the Documentation page to view the API documentation. For more information, see Where do I upload API documentation for Simple Dev? (Site Admin help).
You can download a ZIP file of the documents directory for your API, including all files in the directory and all subfolders and their contents. You can download a ZIP of any content you are authorized to view and edit. Follow the instructions below.
If your API uses licenses, you must include the metadata.xml file with appropriate tagging. If you don't specify a metadata.xml file with permissions to your content, or if you include a metadata.xml file but don't add the information about your files, your users will not see your documentation, other than the properties file and any legal agreements. This includes a custom CSS file or any other assets associated with your documentation.
This is always true when the API uses licenses, even if the API is public.
You can modify your authored API documentation with a special tag so that when users are viewing the API documentation in the developer portal, they can access Test Client inline, in the context of the API documentation, to test out your API, each operation, with their app (or without any app context, if the API supports anonymous access).
To set this up, you'll need to:
Note: these instructions include procedures for both Simple Dev and Default themes.
If you want readers of your API documentation to be able to view and use Test Client inline in your authored API doc, you'll need to set up a config.js file, upload it to the platform with your documentation files, and reference it within the <head> section of any authored file in which you want to display inline Test Client.
Then, you can use special tags in your authored documentation file, and the API-specific, operation-specific Test Client will appear at runtime, inline in the authored HTML file.
Note that the file content is a little different depending on the theme you are using:
Note: The file is quite long, so the sample files below use only two operations. You can expand for multiple operations as needed. This example is based on a scenario where a platform API is set up to reference the Swagger Petshop API, and the sample files below reference two operations from that API, getPetById and addPet. The section for each operation is named profile_{operationname}. You can find these API definitions at http://petstore.swagger.io (external link).
window.MYAPP = { "profile_getPetById" : { "general" : { "showItText" : "Click here to try getting a pet with the Pet ID", "hideItText" : "Click here to close", "summary" : "Get pet by ID" }, "target" : { "apiVersion" : { "defaultValue" : "ae85330c-6562-4abc-86fd-1ea42f6d3f22.acmepaymentscorp" }, "environment" : { "display" : false, "defaultValue" : "Production" }, "operation" : { "display" : false, "defaultValue" : "getPetById" }, "headers" : { "display" : false, "Content-Type" : "None", "Accept" : "application/json", "items" : [{ "name" : "header1", "value" : "value1" }] }, "parameters" : { "display" : false, "items" : [{ "name" : "petId", "value" : "1434747602017", "nameIsChangeable" : false, "type" : "path" }, { "name" : "name1", "value" : "value1", "nameIsChangeable" : true, "type" : "query" }] } } }, "profile_addPet" : { "general" : { "showItText" : "Click here to try adding a pet", "hideItText" : "Click here to close", "summary" : "Add a pet to the petstore" }, "target" : { "apiVersion" : { "defaultValue" : "ae85330c-6562-4abc-86fd-1ea42f6d3f22.acmepaymentscorp" }, "environment" : { "display" : false, "defaultValue" : "Production" }, "operation" : { "display" : false, "defaultValue" : "addPet" }, "headers" : { "display" : true, "Content-Type" : "application/json", "Accept" : "application/json", "items" : [] }, "parameters" : { "display" : true, "items" : [{ "name" : "petId", "value" : "1", "nameIsChangeable" : false, "type" : "path" }, { "name" : "name", "value" : "fluffy puppy", "nameIsChangeable" : false, "type" : "form" }, { "name" : "status", "value" : "available", "nameIsChangeable" : false, "type" : "form" }] } } } };
window.MYAPP = { "profile_getPetById" : { "general" : { "showItText" : "Show: getPetById", "hideItText" : "Hide: getPetById", "summary" : "Get pet by ID" }, "target" : { "environment" : { "display" : false, "defaultValue" : "Production" }, "operation" : { "display" : false, "defaultValue" : "getPetById" }, "headers" : { "display" : false, "Content-Type" : "None", "Accept" : "application/json", "items" : [{ "name" : "header1", "value" : "value1" }] }, "parameters" : { "display" : false, "items" : [{ "name" : "petId", "value" : "1434747602017", "nameIsChangeable" : false, "type" : "path" }, { "name" : "name1", "value" : "value1", "nameIsChangeable" : true, "type" : "query" }] } } }, "profile_addPet" : { "general" : { "showItText" : "(Show) Adds a Pet", "hideItText" : "(Hide) Add a Pet", "summary" : "Adds a pet to the petstore" }, "target" : { "environment" : { "display" : false, "defaultValue" : "Production" }, "operation" : { "display" : false, "defaultValue" : "addPet" }, "headers" : { "display" : true, "Content-Type" : "application/json", "Accept" : "application/json", "items" : [] }, "parameters" : { "display" : true, "items" : [{ "name" : "petId", "value" : "1", "nameIsChangeable" : false, "type" : "path" }, { "name" : "name", "value" : "Armadillo", "nameIsChangeable" : false, "type" : "form" }, { "name" : "status", "value" : "available", "nameIsChangeable" : false, "type" : "form" }] } } } };
The above is your starter file. Within this file, you'll need to set up the specific values applicable to your API on the platform. The core values that you set up for the inline Test Client feature are explained below. The first two are key, because without them the feature will not work. The others are cosmetic, controlling the text your users will see when viewing the feature.
The examples below show where the text that you add will display to your users:
Default display before user clicks Show It. ShowitText and summary are visible.
Display when user clicks the Show It link. ShowitText and summary are visible, plus the inline Test Client.
Remember that you also need to reference the config.js file in your documentation file or file in order to view the above results. See How do I set up my authored API doc file to show inline Test Client? below.
Note: These instructions are valid for both Simple Dev and Default themes.
Once you have the config.js file set up with the correct values for your specific API, as explained in How do I set up the config.js file to show inline Test Client in my authored API doc? above, you'll need to modify your API documentation HTML files to correctly reference config.js to implement this functionality. In each file where you want to implement inline functionality, do these two things:
1: Adding <script> tags in the head of your API doc file
In the <head> tag, add the lines of code shown below.
<html lang="en" xmlns:soa="http://soa.com"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <!-- The css files below are needed for the inline testing feature to be displayed correctly --> <link rel="stylesheet" type="text/css" href="/resources/style/reset.css"/> <link rel="stylesheet" type="text/css" href="/resources/style/base.css"/> <!-- The script files below are needed for the inline testing feature to work correctly --> <script language="javascript" src="config.js" type="text/javascript"></script> <script language="javascript" src="/ui/apps/atmosphere/123/resources/console/SOA/console/common/tag_lib/dist/tag_lib.min.js"type="text/javascript"></script>
2: Including the soa:testclient tag in the body of the API doc file
In the part of the document where you want the generated documentation to appear, add something along the lines of the below, making sure you have the correct operation name in place of addPet below:
<div>
<soa:testclient config="{MYAPP.profile_addPet}">
</soa:testclient>
</div>
Once each file is updated as needed, get all the files uploaded, as explained in Where do I upload API documentation for Simple Dev? (Site Admin help).
Once you have your files set up, you can upload the files and test to make sure everything is correct and Test Client is now displayed inline in your authored API content.
The procedures below include all the steps you'll need to take to view the final product.
The processes for Simple Dev and Default Theme are slightly different.
To get the inline Test Client working correctly inline in your authored API documentation, you'll need to edit many of the values in the config.js file to match the values set up for your API. This includes such things as operation name, path, Content-Type (request header), Accept header (response header), and other values.
It's best to work with one operation first, and when you have that working, model the rest on that. The example given in How do I set up the config.js file to show inline Test Client in my authored API doc? has two operations.
The values at the top of the file determine how the inline Test Client feature is displayed, but the rest of the file content determines whether the inline Test Client actually works as expected.
Platform app developers have access to the Test Client tool, which allows them to test out different APIs. Test Client includes a drop-down list, where app developers can choose from a list of available APIs that the current app has a contract with.
In Simple Developer theme, an API-specific version of the new Test Client testing tool is available, to facilitate testing of an individual API from the API page of the Developer Portal. The API Admin can also use this to include an API-specific link to Test Client within the API documentation. When using Test Client in the context of a specific API, developers can invoke APIs that support anonymous access, use the credentials for one of their apps, or use a custom app identity.
The API-specific version of Test Client is not part of the standard user interface, but you can construct the URL and include it in your API documentation. App developers reading your API documentation can click through and test out your API. This API-specific version of Test Client does not give access to all the app developer's APIs, just the one that's in the URL.
The URL is:
{protocol}//{hostname}/#!apis/{APIID}/versions/{APIVersionID}/testclient
For example:
http://acmepaymentscorp.com/acmepaymentscorp/#!apis/12770263-e036-4222-b8eb-87d33676d3ad.acmepaymentscorp/ versions/9e3846ee-bbbf-4982-82ca-5a2411ec619b.acmepaymentscorp/testclient
To construct the URL for your specific API, follow the instructions below. You can then link to this page from your platform API documentation. For information on including links in platform API documentation, see How do I code links in Simple Dev?
http://acmepaymentscorp.com/acmepay/
http://acmepaymentscorp.com/#/api/21bfe816-5260-4444-ae77-bd2c047174f8.acmepaymentscorp/versions/ 7ba40d5f-3c22-4b8f-ac9d-317cbee4b83f.acmepaymentscorp/details
Once you have the URL, you can reference it with a direct inline link from your API documentation. To have the Test Client display in a separate browser tab, use the Target attribute _blank, as shown below.
<p>To test your app with our API, try out the <a href="{protocol}//{hostname}/{Tenantname}/#!apis/{APIID}/versions/{APIVersionID}/testclient" target="_blank"> Test Client testing tool</a>.</p>
To upload your file to the API documentation folder in Simple Dev theme, see Where do I upload API documentation for Simple Dev?
When you set up your API definition, either in the platform or by referencing an existing service in the API Gateway, the platform automatically generates API documentation based on your API definition.
Within the context of the platform in Default Theme, you and your users can test your API, in the context of an app (or anonymously if the API supports anonymous access).
This generated API documentation testing functionality is essentially the same as the Test Client feature, but Test Client is available inline, in the context of your API.
Some of the things you and your users can do with the generated API documentation:
You can use this feature to test and monitor the usability of your API; your developer audience can use it to discover the great capabilities of your API.
In Default Theme, after you've set up your API definition, you can view generated API documentation immediately: from your API Details page, click Documents on the left menu.
By default, if you haven't uploaded any authored API documentation, the generated API documentation is displayed.
However, If you upload authored documentation and add one of the files to the Documentation table of contents so that users will see that content (see How do I add a file to the API documentation table of contents? and subsequent topics), the generated API documentation is no longer displayed, by default.
In this scenario, you'll need to take a couple of extra steps to make sure that both authored and generated API documentation is visible to your users. You'll need to:
Now, both sets of documentation are accessible to your users on the Documentation Table of Contents.
For detailed instruction for working with File Explorer, refer to Using File Explorer.
If you upload authored HTML API documentation, the authored documentation is shown to users by default, in both themes. If you want to offer both types of documentation to your users, you'll need to take a couple of extra steps to make the generated API documentation available to your users.
To set this up, you'll need to:
For information on how to set these files up, refer to the topics below.
Note: these instructions include procedures for both Simple Dev and Default themes.
If you want readers of your API documentation to be able to see the generated doc for your API, inline within your authored documentation, you'll need to set up a config.js file, upload it to the platform with your documentation files, and reference it within the <head> section of any authored file in which you want to display generated API doc inline in the file.
Then, you can use special tags in your authored documentation file, and the generated API documentation will appear at runtime, inline in the authored HTML file.
As a starting point, create a file called config.js and paste the content as shown below.
Note that the file content is a little different depending on the theme you are using:
01 window.MYAPP = { 02 "tag1" : { 03 "general" : { 04 "showItText" : "Swagger Petstore API", 05 "hideItText" : "Swagger Petstore API", 06 "summary" : "summary text: Generated documentation for Swagger Petstore API" 07 }, 08 "target" : { 09 "apiVersion" : { 10 "defaultValue" : "ea61269e-8a8f-4949-970c-c4af5d7fb7c5.acmepaymentscorp" 11 } 12 } 13 } 14 };
01 window.MYAPP = { 02 "tag1" : { 03 "general" : { 04 "showItText" : "Swagger Petstore API", 05 "hideItText" : "Swagger Petstore API", 06 "summary" : "summary text: Generated documentation for Swagger Petstore API" 07 }, 08 } 09 };
The above is your starter file. Within this file, you'll need to set up the specific values applicable to your API on the platform. The values that you set up are listed and explained below. The first two are key, because without them the feature will not work. The others are cosmetic, controlling the text your users will see when viewing the feature.
The examples below show where the text that you add will display to your users:
Default display before user clicks Show It. ShowitText and summary are visible.
Display when user clicks the Show It link. ShowitText and summary are visible, plus the inline testing feature.
Remember that you also need to reference the config.js file in your documentation file or file in order to view the above results. See How do I reference the config.js file to include inline generated doc in my authored API doc content? below.
When your documentation files are ready, including any authored API documentation and the accompanying config.js file, you'll need to upload the files.
Get the Site Admin to upload it in Default Theme: Administration > Config > Resources > Content File Manager.
From here, there are two approaches to uploading the content:
As soon as the files are uploaded in Default Theme, they are immediately visible in Simple Dev theme. Just log in and click the Documentation page to view the API documentation with inline testing capability.
For more information, see Where do I upload API documentation for Simple Dev? (Site Admin help).
Navigate to API > Documents and use the File Explorer to upload the files.
Note: These instructions are valid for both Simple Dev and Default themes.
Once you have the config.js file set up with the correct API version and other values for your API, you'll need to modify your API documentation HTML files to correctly reference config.js to implement this functionality. In each file where you want to implement inline functionality, do these two things:
1: Adding <script> tags in the head of your API doc file
In the <head> tag, add the lines of code shown below.
<html lang="en" xmlns:soa="http://soa.com"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <!-- The css files below are needed for the inline testing feature to be displayed correctly --> <link rel="stylesheet" type="text/css" href="/resources/style/reset.css"/> <link rel="stylesheet" type="text/css" href="/resources/style/base.css"/> <!-- The script files below are needed for the inline testing feature to work correctly --> <script language="javascript" src="config.js" type="text/javascript"></script> <script language="javascript" src="/ui/apps/atmosphere/123/resources/console/SOA/console/common/tag_lib/dist/tag_lib.min.js"type="text/javascript"></script>
2: Including the generatedoc tag in the body of the API doc file
In the part of the document where you want the generated documentation to appear, add something along the lines of the below:
<h5>Try it!</h5> <div> <soa:generatedoc config="{MYAPP.tag1}"> </soa:generatedoc> </div>
Once each file is updated, get all the files uploaded, as explained in Where do I upload API documentation for Simple Dev? (Site Admin help).
Once you have your files set up, you can upload the files and test to make sure everything is set up correctly and the generated API documentation is now displayed inline in your authored API content.
The procedures below include all the steps you'll need to take to view the final product.
The processes for Simple Dev and Default Theme are slightly different.