After completing this section, you should be able to import OpenAPI standard API definitions into Red Hat 3scale API Management.
The OpenAPI Specification (OAS) is a way of describing REST APIs. It is an open source specification based on the Swagger Specification.
It offers the following benefits:
It provides a standard for documenting your APIs.
It allows API consumers to interact with your API from the documentation, for example for testing purposes.
It does not require any binding to a programming language or a programming framework.
It offers a way to generate clients and servers that comply with the OAS you define.
The OAS definition supports both YAML and JSON formats.
This specification is used by Red Hat 3scale API Management to provide interactive documentation for the Developer Portal. In 3scale API Management the OAS integration is called ActiveDocs.
You can manage your ActiveDocs definitions either by using the Admin Portal or the 3scale Toolbox CLI.
Also, by using the 3scale Toolbox CLI and the import command you can generate all the 3scale API Management objects needed to create an application based on the OAS definition.
You can create an ActiveDocs object either from the page or from a product page. If you create the ActiveDocs from a product page then the ActiveDocs are assigned to that product.
To select any product for the OAS definition, create the ActiveDocs from the page. For this you must navigate to , click , and complete the ActiveDocs form.
![]() |
The 3scale Toolbox CLI has the activedocs command, which offers several subcommands to manage ActiveDocs objects.
[user@host ~]$3scale activedocs -hNAME activedocs - activedocs super command USAGE 3scale activedocs <sub-command> [options] DESCRIPTION Manage your ActiveDocs SUBCOMMANDSapplyUpdate activedocscreateCreate an ActiveDocsdeleteDelete an ActiveDocslistList ActiveDocs
All these subcommands affect ActiveDocs objects exclusively. For example, you can use the delete subcommand as a way to delete ActiveDocs objects.
[user@host ~]$3scale activedocs delete \REMOTE\![]()
ACTIVE_DOCS
The 3scale Toolbox CLI offers a different way of creating ActiveDocs by importing the OAS definition.
For this, you must use the import command and the openapi subcommand.
You can get the OAS definition either from a file or from a URL.
This operation does more than creating the ActiveDocs object. It generates many 3scale API Management objects based on the OAS definition file. It creates:
A product with a name taken from the title attribute in the OAS file.
A backend with a name taken from the title attribute and a backend URL taken from the servers section in the OAS file.
Mapping rules and methods based on the paths section from the OAS file.
This is an example command with some of the available options:
[user@host ~]$3scale import openapi \ --target_system_name=SYSTEM_NAME\--destination=
REMOTE\--default-credentials-userkey=
ANONYMOUS_KEY![]()
OAS_FILE
This is the system name that is used as the system name for the product, the backend and the ActiveDocs objects. | |
The target tenant. | |
This option adds an | |
The OAS file in JSON or YAML. This option also accepts a URL that returns the OAS definition. |
After executing this command you must create an application plan and an application to make your API public.
To use the ActiveDocs interactive documentation you must add a CORS Request Handling policy and set the allow_origin to the Developer Portal domain.
The reason for this is that the ActiveDocs request is sent from the Developer Portal domain, which is different from your API domain.
When the domain from where the request is originated differs from the domain serving the request, the browser blocks the call unless you configure APIcast to allow it.
For more information, refer to the How to write an OpenAPI document for use as a 3scale OpenAPI spec chapter in the Red Hat 3scale API Management Providing APIs in the Developer Portal at https://access.redhat.com/documentation/en-us/red_hat_3scale_api_management/2.11/html/providing_apis_in_the_developer_portal/how-to-write-an-openapi-document-for-use-as-a-threescale-openapi-spec_creating-a-new-service-based-on-oas