Enabling and disabling the REST Discovery API

You might want to prevent Swagger from displaying your RESTful API in a web browser, especially in a production environment that is serving live traffic. By disabling the REST Discovery API, you can prevent your REST services from being retrieved and displayed in Swagger. Alternatively, you can enable the REST Discovery API to view and test your REST services with Swagger.

About this task

The availability of the REST Discovery API is controlled by the ApiDiscoveryEnabled property. You can change this property within the wc-component.xml file for the foundation component. For more information about updating wc-component.xml files, see Changing REST configuration properties in the component configuration file (wc-component.xml).

Notes:
  • HCL Commerce DeveloperThe ApiDiscoveryEnabled element is set to true (enabled) in HCL Commerce Developer environments by default.
  • In runtime environments, the ApiDiscoveryEnabled element is set to false (disabled) by default.

When you are updating your version of the wc-component.xml file, ensure that you include the ApiDiscoveryEnabled property, and set value to true or false. For example, the following code snippet sets the value for the property to false, which disables the REST Discovery API:

<!-- Determines if the REST API Discovery should be enabled. -->
    <_config:property name="ApiDiscoveryEnabled" value="false"/>

When the Discovery API is set to false, a user can still access Swagger in a web browser, but no REST API are displayed.

What to do next

Viewing the REST API using Swagger in pre-9.1.6 versions.