Heretto API Docs
API Docs Overview
Learn how to use Heretto API Docs to publish API documentation for public and internal consumption within Heretto Portal, ultimately achieving a more streamlined and unified approach to full service documentation.
With API Docs, you can publish JSON files with API specifications to your Heretto Portal environment. API Docs includes built-in API testing which enables you to access and test your API documentation alongside your other content.
You store your JSON files with API endpoint definitions in Heretto CCMS which enables you to manage both product and API documentation centrally. Next to API endpoint definitions generated from JSON files, your API documentation can contain traditionally created content. For example, an API overview, information about API calls flow, security, and more.
To publish API specifications, you upload your JSON file(s) with API endpoint definitions to the CCMS, attach them to a map, and publish it to Heretto Portal. Upon publishing to the portal, JSON files are converted into help portal pages in Heretto Portal.
API documentation published to Heretto Portal enables users to:
-
Reference general information about the API
Reference API endpoint attributes and properties
-
Test parameter values by making API calls to a specified server
-
Generate a usable request sample rendered in commonly used programming languages with values provided through the pages
To see API Docs in action, see our Heretto Deploy API documentation at Deploy API Introduction.
API Docs Facts and Recommendations
- JSON File
-
-
Heretto API Docs are compatible with OpenAPI. The JSON file(s) with API endpoint definitions must conform to OpenAPI Specification. The earliest supported version is version 2.0 (former Swagger RESTful API Documentation Specification). We recommend using versions 3.0.1 - 3.0.3.
-
To send API calls to your servers or create usable request samples in Heretto Portal, each JSON file must have at least one server configured. JSON files can have multiple servers configured, and server URLs can differ between files. Endpoints only use servers from the JSON file in which they are added. If a JSON file does not have servers configured, you will not be able to send requests using endpoints defined in this file.
Ensure each endpoint has a
summary
parameter value specified. Values provided in that field are used as the navigation menu label and page title for each endpoint. Here is an example of asummary
value in a JSON file and how it is presented in the portal."paths": { "/org/{organizationId}/deployments/{deploymentId}/search": { "post": { "tags": [ "API Endpoint Specification" ], "summary": "Search pages",
-
- Map types
-
You can add JSON file(s) to maps, bookmaps, sitemaps, and custom (or specialized) maps.
- Map structure
-
-
A map can contain one or more JSON file(s).
-
You add JSON file(s) to a map in a topicref element. In the Content Editor, you can drag and drop JSON file(s) from the Content Library onto a map to add it to the map.
-
To render API Docs properly in Heretto Portal, apart from a JSON file, a map or a sitesection must contain at least one DITA topic. There should be at least one topicref in each sitesection.
-
- Chunk attribute
-
-
API Docs does not support adding the chunk attribute on a topicref element that points to a JSON file.
-
API Docs does not support adding JSON file(s) inside a structure that uses
chunk="to-content"
.
-
- Structure of content generated from JSON file(s)
-
-
Each unique value present in
tags
objects in the JSON file becomes a separate heading in the table of contents in Heretto Portal. -
Endpoints with identical
tags
values are grouped under one heading. -
Headings generated from
tags
appear in the same order as in the JSON file. To specify the value displayed in the TOC for each API method, ensure there is a
summary
parameter noted. If you do not include asummary
parameter, the TOC shows the API method path instead.
-
API Docs Map Structure Examples
Review examples of map structures valid for publishing your API specification with Heretto API Docs. A correct map structure and attributes are required to properly render content in JSON file(s) with API endpoint definitions.
A minimal map structure with one DITA and one JSON file.
<map id="ditamap-1111">
<topicref href="api-overview.dita"/>
<topicref format="json" href="api-reference.json" outputclass="openapi-reference"/>
</map>
A map structure with JSON files nested under DITA topics.
<map id="ditamap-2222">
<topicref href="api-overview.dita"/>
<topicref href="api-module-1.dita"/>
<topicref format="json" href="api-reference-1.json" outputclass="openapi-reference"/>
</topicref>
<topicref href="api-module-2.dita"/>
<topicref format="json" href="api-reference-2.json" outputclass="openapi-reference"/>
</topicref>
</map>
A sitemap structure with a few DITA topics and one JSON file.
<sitemap id="ditamap-3333">
<title>API Documentation</title>
<topicref href="api-overview.dita"/>
<topicref href="authentication.dita" chunk="to-content">
<topicref href="oauth.dita"/>
</topicref>
<topicref href="security.dita"/>
<topicref href="tokens.dita" chunk="to-content">
<topicref href="create-a-simple-token.dita"/>
<topicref href="create-a-jwt-token.dita"/>
</topicref>
<topicref href="api_reference.json" outputclass="openapi-reference"/>
</sitemap>
A sitemap structure with sitesections two DITA topics and three JSON files.
<sitemap id="ditamap-4444">
<title>API Documentation</title>
<sitesection>
<topicmeta>
<navtitle>Usage Data</navtitle>
</topicmeta>
<topichead>
<topicref href="extract--usage-data-from-database.dita"/>
<topicref href="api_reference-1.json" outputclass="openapi-reference"/>
</topichead>
</sitesection>
<sitesection>
<topicmeta>
<navtitle>User Management</navtitle>
</topicmeta>
<topichead>
<topicref href="api-user-management.dita"/>
<topicref href="api_reference-2.json" outputclass="openapi-reference"/>
<topicref href="api_reference-3.json" outputclass="openapi-reference"/>
</topichead>
</sitesection>
</sitemap>
Create a Map for API Documentation
Heretto API Docs enables you to use JSON files with API endpoint definitions to automatically create API endpoint documentation.
Make sure:
You have a valid JSON file conforming to OpenAPI Specification 3.0.1 - 3.0.3
-
Your map contains at least one
topicref
pointing to a DITA topic
The API endpoint documentation is published to your help site.
Edit Endpoint Headings in the JSON File
tags
objects in the JSON file(s) you attached to the map. To modify this structure, edit the JSON file(s). Each unique value of tags
creates a separate heading in the table of contents in Heretto Portal. Endpoints with identical tags
values are grouped under one heading.Testing API Calls in Heretto Portal
Heretto API Docs enables you to test API endpoints directly in Heretto Portal where you can set request parameters and send requests to servers previously defined in the JSON file(s) that contains your API endpoint specification. The request you send also appears as a request sample in a programming language of your choice. You can use request samples directly in your code.
Configure API Docs with Your Servers
To test API calls on your help portal, each JSON file that contains your API must have at least one address to a server that receives requests.
You can define multiple servers in one JSON file. The servers can be the same for all files, or differ between files. If a JSON file does not contain any servers, it is not possible to send requests with endpoints from this JSON file.
The server address appears in the request URL below the page title and in the request sample.
If a JSON file contains two or more servers, the server menu appears in the API test area of your help site. The server menu enables you to switch between servers.
Send API Requests
You can test API requests directly in Heretto Portal. You can then copy the request snippet in your chosen programming language and use it directly in your code.
-
Your JSON file with API endpoint specification must have defined one or more servers
-
You must have API endpoint documentation published to your help site
-
If your servers are secured, you must have valid credentials for making requests to your servers
Configure a CORS Proxy for API Docs
You can configure Heretto Portal to act as a cross-origin resource sharing (CORS) proxy for API Docs. A CORS proxy is a service that enables you to access resources from other websites without having to own that website.
Customize API Docs Styling
You can customize the layout of Heretto API Docs, similarly to the Heretto Portal.
API Docs use the same CSS file as Heretto Portal. For more information on styling, see: Customize Heretto Portal Styling.