Import and Implement an API Specification from Exchange
Import an AsyncAPI, OAS, or RAML API spec into a new or existing Mule project.
If you’re using Mule runtime engine (Mule) 4.1.3 and earlier, or if you prefer to import an API specification that isn’t available in Exchange, you can import an API spec from a local file or from Design Center.
If you can’t access Exchange from your work environment, you can import an API specification from your local Maven installation.
Import and Implement an API Specification from Exchange Into a New Project
-
In the taskbar, select File > New > Mule Project.
-
Type a name for your project.
-
In the Runtime section, select the Mule runtime version appropriate for your project:
-
Select a Mule runtime engine version 4.1.4 or later for an OAS or RAML API spec.
-
select a Mule runtime engine version 4.5.0 or later for an AsyncAPI spec.
-
-
In the API Specification section, select the From Exchange or Maven tab.
-
Click the Add icon (), and select From Exchange.
-
Select your Anypoint Platform username.
If you’re not logged in, click Add Account to add your Anypoint Platform account.
-
From the list of available APIs, select one or more and click Add.
To list all available APIs, type a
*
character in the search bar and press Enter. -
To select the version of the API to import, use the Selected Modules table.
-
Click Finish.
Studio scaffolds your API specification. If you choose not to create flows out of your API specification, unselect Scaffold Flows From These API Specifications.
Manage the API specifications linked to Exchange in your project from the API specification project management view by clicking the Manage Mule Project APIs icon () in the task bar.
Import and Implement an API Specification from Exchange Into an Existing Project
-
Right-click on your project in the Package Explorer, select Mule, and then select Manage APIs.
-
Click the Add icon (), and select From Exchange.
-
Select your Anypoint Platform username.
If you’re not logged in, click Add Account to add your Anypoint Platform account.
-
Select the API from the list of available APIs and click Add.
You can choose more than one API to import.
To list all available APIs, type a
*
character in the search bar and press Enter.You can select the version of the API to import in the Selected Modules table.
-
Click Finish.
Studio scaffolds your API specification. If you choose not to create flows out of your API specification, unselect Scaffold Flows From These API Specifications.
Manage the API specifications linked to Exchange in your project from the API specification project management view by clicking the Manage Mule Project APIs icon () in the task bar.
If you want Studio to list your API when searching in Exchange, you must mark your API specification published as an asset as stable. |
Rescaffold an API Specification in a Mule Project
After changing your API spec, such as adding a new endpoint, rescaffold the spec to update your Mule project.
-
Right-click on the XML file of your Mule project.
-
Select API Specs, the name of your Mule project, and Generate Flows.
If the rescaffolding process of your project is successful, your implementation XML file includes a new flow.
Implement AsyncAPI Specifications
Studio supports the implementation of AsyncAPI 2.6 specs. When creating an implementation project, Studio imports and scaffolds an AsyncAPI spec hosted on Exchange into an API interface that you can implement.
For supported protocols, see Supported Message Brokers in APIkit for AsyncAPI Module Reference.
Access AsyncAPI Implementation Features
-
Open Anypoint Code Builder landing page on your Anypoint Platform cloud host (US or EU).
You must sign in. The Terms & Conditions button is available to the organization administrator only.
-
If the message AsyncAPI Beta is now available in Anypoint Code Builder and Anypoint Studio appears on the page, ask your organization administrator to join the Beta program by:
-
Clicking Join Beta from the Anypoint Code Builder landing page
The Join Beta button is available only to your organization administrator.
-
Reviewing the terms and conditions of the beta program
-
Clicking Get Access
When the AsyncAPI feature is available for your organization, the Anypoint Code Builder landing page provides the following notification:
AsyncAPI Implementation Beta for Anypoint Code Builder and Studio is enabled for your organization.
-
You must have access to a supported AsyncAPI specification hosted on Anypoint Exchange. If your AsyncAPI specification isn’t published to Exchange, see design-center::design-publish.adoc. To create an AsyncAPI specification before publishing to Exchange, see design-center::design-async-api.adoc in the Design Center documentation. |
Scaffolding Fundamentals for AsyncAPI Implementations
When scaffolding an AsyncAPI specification into a Mule project, Studio:
-
Introspects the AsyncAPI specification
-
Considers one spec at a time
-
Treats the imported spec as a modification of an existing spec and evaluates it for rescaffolding
-
Creates a new Mule project with a separate flow for each
publish
operation in the specification -
Produces the configuration properties
file dev-properties.properties
file in thesrc/main/resources
directory of your Mule project -
Makes the APIkit for AsyncAPI module available for use in the project
The module provides the following operations:
-
Publish (
<apikit-asyncapi:publish/>
): AsyncAPIsubscribe
operations in the specification are available for configuration as AsyncAPI Publish operations. -
Message Listener (
<apikit-asyncapi:message-listener/>
): AsyncAPIpublish
operations in the specification are configurable Message Listener (not Publish) operations.The scaffolder transforms each
publish
operation into a Message Listener operation.
-
-
Generates a
global-configs.xml
file with connection configurations for Message Listener and Publish operations in the AsyncAPI module and for any connectors that the module depends on.
Errors can occur during the scaffolding process:
-
If no channels are defined in the specification
-
If unsupported message broker protocols are used
For supported protocols, see Supported Message Brokers in APIkit for AsyncAPI Module Reference.
Studio doesn’t support the scaffolding of AsyncAPI, OAS, or JSON schema fragment files that are referenced from API specs. The scaffolder doesn’t add these fragments as project dependencies when you import the specification from Exchange. However, you can scaffold and reference fragments that are specified inline, within the spec. RAML fragments imported from Exchange aren’t affected by this limitation. |