Publish your APIs

Publish APIs to your portal to make them available for consumption by app developers, as described in the following sections.

Overview of API publishing

The process of publishing APIs to your portal is a two-step process:

  1. Select the API product that you want to publish to your portal.
  2. Render API reference documentation from a snapshot of your OpenAPI Specification to enable app developers to learn about your APIs. (For more information about snapshots, see What is a snapshot of an OpenAPI Specification?

When you publish an API to your portal, the following updates are made to your portal automatically:

  • SmartDocs API reference documentation is added to your portal
    The SmartDocs API reference documentation is rendered from a snapshot of your OpenAPI Specification. The SmartDocs UI is based on angular material, a state-of-the-art UI components library.

    Developers can review your SmartDocs API reference documentation and use the Try this API panel to make an API request and view the output. Try this API works with unsecured endpoints or secured endpoints using Basic, API Key, or OAuth Authentication, based on the security method defined in your OpenAPI Specification. For OAuth, the following flows are supported: authorization code, implicit, password, and client credentials.

    Note: You cannot edit the contents of this page directly; it does not appear in the list of pages in your portal.

    Click to expand the Try this API panel. The expanded panel enables you to view the curl call and HTTP request information, as shown below.

  • A link to the API Reference page is added to the APIs page
    The APIs page (included with the sample portal) provides a list of all APIs published to your portal with links to the respective API reference documentation for more information. You can customize the image displayed for each API card.

    Note: You cannot edit the contents of this page directly; it does not appear in the list of pages in your portal. You can edit the styling of the page when customizing your theme.

What is a snapshot of an OpenAPI Specification?

Each OpenAPI Specification serves as the source of truth throughout the lifecycle of an API. The same specification is used at each phase in the API lifecycle, from development to publishing to monitoring. When you modify a specification, you need to be cognizant of the impact the changes have on your API through other lifecycle phases, as described in What happens if I modify a specification?

When you publish your API, you take a snapshot of the OpenAPI Specification to render API reference documentation. That snapshot represents a specific version of the specification in the spec store. If you modify the OpenAPI Specification using the spec editor, you may decide to take another snapshot of the specification in order to reflect the latest changes in the API reference documentation.

About callback URLs

If your apps require a callback URL, such as when using the OAuth 2.0 authorization code grant type (often referred to as "three-legged OAuth"), you can require developers to specify a callback URL when they register their apps. The callback URL typically specifies the URL of an app that is designated to receive an authorization code on behalf of the client app. For more information, see Implementing the authorization code grant type.

Note: The callback URL is stored as a custom attribute in the corresponding Edge app entity. If you are using a third-party identity provider, you are responsible for syncing the callback URL metadata.

You can configure whether or not to require a callback URL during app registration when adding an API to your portal. You can modify this setting at any time, as described in Manage the callback URL for an API.

When registering an app, developers must enter a callback URL for all APIs that require it, as described in Register apps.

Add CORS support to your API proxies

Before publishing your APIs, you'll need to add CORS support to your API proxies to enforce client-side cross-origin requests.

CORS (Cross-origin resource sharing) is a standard mechanism that allows JavaScript XMLHttpRequest (XHR) calls executed in a web page to interact with resources from non-origin domains. CORS is a commonly implemented solution to the "same-origin policy" that is enforced by all browsers. For example, if you make an XHR call to the Twitter API from JavaScript code executing in your browser, the call will fail. This is because the domain serving the page to your browser is not the same as the domain serving the Twitter API. CORS provides a solution to this problem by allowing servers to "opt-in" if they wish to provide cross-origin resource sharing.

For information about adding CORS support to your API proxies before publishing the APIs, see Adding CORS support to an API proxy.

Explore the APIs page

To view the APIs published to your portal:
1. Select Publish > Portals and select your portal.
2. Click APIs on the portal home page.

 Alternatively, you can select **APIs** in the portal drop-down menu in the top navigation bar.

The list of APIs is displayed.

API reference

As highlighted in the previous figure, the APIs page enables you to:

Add an API to your portal

To add an API to your portal:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Click + API.

    The Add API Product to Portal dialog displays.

  4. On the Select Product tab, select the API product that you want to add to your portal.

  5. Click Next.

  6. Configure the API reference documentation content and its visibility on the Documentation tab:

    Field Description
    Spec source Select the source to use for the snapshot. Select a specification from the drop-down menu or select Choose a different spec to select or upload a new specification. Alternatively, you can select No spec and add one later after the API has been added, as described in Manage the snapshot of the specification.
    PublishedSelect the Published checkbox to publish the API to your portal. Deselect Published if you are not ready to publish the API. You can change the setting later, as described in Publish or unpublish an API on your portal.
    Audience

    Select one of the following options:

    • Anonymous users to allow all users to view the API product.
    • Registered users to allow only registered users to view the API product.

    You can manage the audience later, as described in Manage the audience for an API on your portal.

    Note: If you have enrolled in the Beta release of the developer team and audience management features, the Audience section is not available. In this case, to manage audience visibility, see Manage the visibility of an API in your portal.

    Image Select an image to display in the API card on the APIs page. From the image drop-down, you can select an existing image, upload a new image, or provide the URL of an external image. You can add an image later, as described in Manage the image for an API card on your portal.

    Note: The size of the API card image is defined in the default theme as 344px x 192px. Be sure to select an image with a relative size. Alternatively, you can modify the image size for the API card, as described in Customize the appearance of the API card on the APIs page.

  7. Configure the title and description for the API reference documentation on the Customize tab:

    Field Description
    TitleUpdate the title of your API. By default, the API product name is used.
    DescriptionUpdate the description of your API. By default, the API product description is used.
    Callback URLSelect Require app owners to specify a callback URLif you want to require that app developers specify a callback URL. You can add or update the callback URL later, as described in Manage the callback URL for an API.
  8. Click Finish.

Manage the snapshot of the specification

After you publish your API, at any time you can take a new snapshot of the OpenAPI Specification to update the API reference documentation that is published on your portal.

To manage the snapshot of the OpenAPI Specification:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position the cursor over the API for which you want to take a snapshot to display the actions.

  4. Click Snapshot icon.

    Note: A message is displayed if your snapshot is current with the source specification selected.

  5. Select an existing specification from the Snapshot Source drop-down or select Choose a different spec to select or upload a new specification to use for generating documentation for the API.

    Alternatively, you can select No spec to remove the current specification.

  6. Click Update Snapshot (or Remove Snapshot, if you have selected No Spec).

API reference documentation is rendered from the specification and added to the API Reference page.

Publish or unpublish an API on your portal

To publish or unpublish an API on your portal:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position the cursor over the API that you want to publish or unpublish.

  4. Click Settings icon.

  5. Select the Enabled checkbox to publish the API on your portal. Deselect Enabled to unpublish the API.

  6. Click Save.

Manage the audience for an API on your portal

Manage the audience for your API on your portal by allowing access to:

  • All users
  • Registered users only

To manage the audience for an API on your portal:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position the cursor over the API for which you want to take a manage the audience to display the actions.

  4. Click Settings icon.

  5. Under Audience, select one of the following options:

    • Anonymous users to allow all users to view the API product.
    • Registered users to allow only registered users to view the API product.
  6. Click Save.

Manage the visibility of an API in your portal (Beta)

Manage the visibiliy of an API in your portal by allowing access to:

  • All users (public)
  • Specific audiences

If you select Specific audiences, the API will not be indexed by search engines.

You create and manage the audiences for your portal, as described in Manage the audience for your portal.

To manage the visibility of an API in your portal:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position the cursor over the API for which you want to take a manage the visibility to display the actions.

  4. Click

  5. Select one of the following options:

    • Public to allow all users to view the API product.
    • Restricted access to allow only specific audiences to view the API product. Select All authenticated users or select one or more specific audiences from the list.
  6. Click Submit.

Manage the callback URL for an API

Manage the callback URL for an API. See About callback URLs.

To manage the callback URL for an API:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position the cursor over the API for which you want to manage the callback URL to display the actions.

  4. Click Settings icon.

  5. Update the callback URL for the authenticated APIs, as required.

  6. Click Save.

Manage the image for an API card

Manage the image that appears with an API card on the APIs page by adding or changing the current image.

To manage the image for an API card:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position the cursor over the API for which you want to manage the image to display the actions.

  4. Click Settings icon.

  5. Under Image:

    • Click Remove to remove the current image.
    • Click Select to select or upload an image.
  6. Click Save.

Edit the API details

To edit the API details:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position the cursor over the API that you want to edit.

  4. Click Settings icon.

  5. Edit the fields, as required.

  6. Click Save.

Remove an API from your portal

To remove an API from your portal:

  1. Select Publish > Portals and select your portal.
  2. Click APIs on the portal home page.

    Alternatively, you can select APIs in the portal drop-down menu in the top navigation bar.

  3. Position your cursor over the API in the list to display the actions menu.

  4. Click Delete.

Troubleshoot issues with your published APIs

When using Try this API, if the TypeError: Failed to fetch error is returned, consider the following possible causes and resolutions:

  • For mixed content errors, the error may be caused by a known swagger-ui issue. One possible workaround is to make sure that you specify HTTPS before HTTP in the schemes definition in your OpenAPI Specification. For example:

     schemes:
       - https
       - http
    
  • For CORS (Cross-origin resource sharing) restriction errors, ensure that CORS is supported for your API proxies. CORS is a standard mechanism that enables client-side cross-origin requests. See Adding CORS support for an API proxy. Ensure CORS in enabled in your browser, as well.