REST Connect Connector Generator | MuleSoft Documentation (2024)

  1. Homepage
  2. Exchange
  3. Consume an API
  4. REST Connect Connector Generator

The Exchange backend uses REST Connect to transparently convert a REST API specification to a Mule 3 and Mule 4 connector. You can use this connector as you would any other in Anypoint Studio.

The Anypoint Exchange Download button lets you download the Mule 3 or Mule 4 Connector.

REST Connect does not currently support custom TLS configurations.

Access Generated Connectors

In Exchange, you can download the Mule 3 or Mule 4 connector from the Download menu:

After deploying a REST asset to Exchange, refresh your screen to ensure that all download options are available.

The Mule 3 connector downloads as a zip file, and the Mule 4 connector downloads as a JAR file.

API Specification Format Support

REST Connect has support for these API specification formats:

  • OAS 3 - JSON

  • OAS 3 - YAML

  • OAS 2 - JSON

  • OAS 2 - YAML

  • RAML 1.0

Security Scheme Support

REST Connect supports these security schemes:

  • Basic Authentication

  • OAuth 2.0 Client Credentials

  • OAuth 2.0 Authorization Code

  • Pass Through

  • Digest Authentication

If you publish an API specification with another authentication type, you may receive an alert email. To have an auto-generated connector, update your API specification to use one of these supported security schemes.

If the operations defined in your API specification support multiple security schemes, the one that comes first in the list of supported schemes is selected.

Basic Authentication Example:

#%RAML 1.0title: Dropbox APIversion: 1baseUri: https://api.dropbox.com/{version}securitySchemes: basic: description: | This API supports Basic Authentication. type: Basic Authentication

OAuth 2.0 Client Credentials Example:

#%RAML 1.0version: v1title: Deadlines APIbaseUri: http://localhost/deadlinessecuritySchemes: oauth_2_0: description: Deadlines API supports OAuth 2.0 for authenticating all API requests. type: OAuth 2.0 describedBy: headers: Authorization: description: Sends a valid OAuth 2 access token. type: string responses: 401: description: Bad or expired token. 403: description: Bad OAuth request. settings: accessTokenUri: https://api.example.com/1/oauth2/token authorizationGrants: [ client_credentials ]/deadlines: get: securedBy: [oauth_2_0] displayName: Get deadlines. description: Get a list of all registered deadlines. responses: 200: body: application/json: example: '[ { "rest-connect": "2017-03-13" } ]'

OAuth 2.0 Authorization Code Example:

#%RAML 1.0version: v1title: Github APIbaseUri: https://api.github.comsecuritySchemes: oauth_2_0: description: | OAuth2 is a protocol that lets external apps request authorization to private details in a user's GitHub account without getting their password. This is preferred over Basic Authentication because tokens can be limited to specific types of data, and can be revoked by users at any time. type: OAuth 2.0 describedBy: headers: Authorization: description: | Used to send a valid OAuth 2 access token. responses: 404: description: Unauthorized settings: authorizationUri: https://github.com/login/oauth/authorize accessTokenUri: https://github.com/login/oauth/access_token authorizationGrants: [ authorization_code ] scopes: - "user" - "user:email" - "user:follow" - "public_repo" - "repo" - "repo_deployment" - "repo:status" - "delete_repo" - "notifications" - "gist" - "read:repo_hook" - "write:repo_hook" - "admin:repo_hook" - "admin:org_hook" - "read:org" - "write:org" - "admin:org" - "read:public_key" - "write:public_key" - "admin:public_key"

Pass-through Example:

#%RAML 1.0title: Customer APIversion: 1baseUri: https://api.customer.com/v2securitySchemes: passthrough: description: | This API supports Pass Through Authentication. type: Pass Through describedBy: headers: api_key: type: string

Change an Auto-Generated Connector Name

REST Connect generates the names of operations based on operationName, displayName, and endpoint in that order. To modify a generated name, you can point to the REST Connect library and use the operationName annotation from a method such as GET, POST, and DELETE, or you can change the text in displayName under the method.

Example with displayName:

#%RAML 1.0title: Sample APIbaseUri: https://jsonplaceholder.typicode.comversion: 0.1mediaType: application/json ... /{postId}: uriParameters: postId: integer get: displayName: Get a post by ID. responses: 200: body: type: Post

Example with REST Connect library:

#%RAML 1.0title: Sample APIbaseUri: https://jsonplaceholder.typicode.comversion: 0.1mediaType: application/jsonuses: rest-connect: exchange_modules/org.mule.connectivity/rest-connect-library/1.0.0/rest-connect-library.raml ... /{postId}: uriParameters: postId: integer get: (rest-connect.operationName): Retrieve a post by id displayName: Get a post by ID. responses: 200: body: type: Post

REST Connect generates metadata for each operation based on your schema definition in the request and response for each method in your RAML. REST Connect cannot generate metadata based on examples in the RAML.

Because only one input/output type is supported for each operation, REST Connect selects the first one that was declared. You can change this behavior by using the 'default' property from the REST Connect library.

Example with REST Connect library:

#%RAML 1.0title: Sample APIbaseUri: https://jsonplaceholder.typicode.comversion: 0.1mediaType: application/jsonuses: rest-connect: exchange_modules/org.mule.connectivity/rest-connect-library/1.0.0/rest-connect-library.raml ... /{postId}: uriParameters: postId: integer get: displayName: Get a post by ID. responses: 200: body: application/json: type: string application/xml: (rest-connect.default): //this sets application/xml response by default type: string

Reserved Keywords

Valid identifiers for REST Connect must not match any of the reserved Java keywords or reserved Mule keywords.

The following list shows the reserved Java keywords to avoid when naming valid identifiers for REST Connect:

  • abstract

  • assert

  • boolean

  • break

  • byte

  • case

  • catch

  • char

  • class

  • const

  • continue

  • default

  • do

  • double

  • else

  • extends

  • false

  • final

  • finally

  • float

  • for

  • goto

  • if

  • implements

  • import

  • instanceof

  • int

  • interface

  • long

  • native

  • new

  • null

  • package

  • private

  • protected

  • public

  • return

  • short

  • static

  • strictfp

  • super

  • switch

  • synchronized

  • this

  • throw

  • throws

  • transient

  • true

  • try

  • void

  • volatile

  • while

The following list shows the reserved Mule keywords to avoid when naming valid identifiers for REST Connect:

  • friendlyName

  • name

  • operationName

  • target

  • targetValue

OAuth2 in Design Center for REST Connect

  1. Define an API with OAuth2 - Authorization Code and one operation in Design Center. You can use the following GitHub API example:

    #%RAML 1.0version: v1title: Github APIbaseUri: https://api.github.comsecuritySchemes: oauth_2_0: description: | OAuth2 is a protocol that lets external apps request authorization to private details in a user's GitHub account without getting their password. This is preferred over Basic Authentication because tokens can be limited to specific types of data, and can be revoked by users at any time. type: OAuth 2.0 describedBy: headers: Authorization: description: | Used to send a valid OAuth 2 access token. responses: 404: description: Unauthorized settings: authorizationUri: https://github.com/login/oauth/authorize accessTokenUri: https://github.com/login/oauth/access_token authorizationGrants: [ authorization_code ] scopes: - "user" - "user:email" - "user:follow" - "public_repo" - "repo" - "repo_deployment" - "repo:status" - "delete_repo" - "notifications" - "gist" - "read:repo_hook" - "write:repo_hook" - "admin:repo_hook" - "admin:org_hook" - "read:org" - "write:org" - "admin:org" - "read:public_key" - "write:public_key" - "admin:public_key"/search: /issues: get: displayName: Get Issues queryParameters: q: displayName: Query description: | The search terms. type: string required: true sort: displayName: Sort description: | The sort field. Can be comments, created, or updated. Default: results are sorted by best match. type: string required: false order: displayName: Order description: | The sort order if a sort parameter is provided. One of asc or desc. Default: desc type: string required: false responses: 200: description: | Successful call body: application/json: type: string
  2. Create a new API specification project named Github API in Design Center, and copy and paste the example above. From the API Designer, click Publish to Exchange:

    REST Connect Connector Generator | MuleSoft Documentation (1)

  3. Create a simple Mule application in Design Center of an HTTP Listener, the Github API, and a Logger. This app listens to https://my-app.cloudhub.io/getIssues and returns the results based on your search term.

    REST Connect Connector Generator | MuleSoft Documentation (2)

  4. Configure OAuth 2.0 with authorization code for a connector. Most of the fields are auto-populate based in the GitHub API specification.

    REST Connect Connector Generator | MuleSoft Documentation (3)

  5. Get the Client ID and Client Secret for your GitHub Account. You can find your Client ID and Client Secret if you go to Settings > Developer settings in GitHub. If you don’t have an OAuth App in GitHub, you can create one with the New OAuth App.

  6. Because GitHub API’s base URL is api.github.com, you can put “/” in the Base Path.

  7. Match and modify your external callback URL. The callback URL receives an access token from GitHub. By default, the connector shows http://my-app.cloudhub.io/callback, but you need to modify it specific to your app. The demo app’s callback URL should be http://githubapp-smky.cloudhub.io/callback so I need to replace “my-app” with “githubapp-smky.” You can find this information to go to the menu and select the copy link in Design Center.

    REST Connect Connector Generator | MuleSoft Documentation (4)

  8. After you get your external callback URL, specify the same URL in your GitHub settings.

    REST Connect Connector Generator | MuleSoft Documentation (5)

  9. You are ready to retrieve an access token from GitHub. In this case, go to http://githubapp-smky.cloudhub.io/authorize in a browser, your case would be http://my-app.cloudhub.io/authorize - replace my-app.cloudhub.io with the one you get with Copy link. When you reach this URL, your browser asks you to log into GitHub.

  10. When your access token is issued properly, you can get issues related to Salesforce from GitHub by using http://my-app.cloudhub.io/getIssues - my-app.cloudhub.io should be replaced with the one you get with Copy link.

Known limitations

  • Anypoint platform, including REST Connect, does not support API fragments for OAS.

As an expert in API integration and MuleSoft technologies, I bring a wealth of knowledge and hands-on experience in designing, developing, and implementing robust API solutions. My expertise spans various aspects, including RESTful APIs, connector generation, API security, and integration with Anypoint Studio. Allow me to delve into the details of the concepts mentioned in the provided article.

Exchange and Connector Generation:

The Exchange platform facilitates the sharing and discovery of assets like connectors. In the context of REST Connect, it utilizes REST Connect to seamlessly convert a REST API specification to a Mule 3 or Mule 4 connector. This connector, once generated, can be downloaded from the Anypoint Exchange using the Download button.

REST Connect and API Specification Support:

REST Connect supports multiple API specification formats, including OpenAPI Specification (OAS) 3 in JSON and YAML formats, as well as OAS 2 and RAML 1.0. This means you can describe your API using any of these industry-standard formats.

Security Schemes in REST Connect:

Security is a crucial aspect, and REST Connect provides support for various security schemes, such as Basic Authentication, OAuth 2.0 Client Credentials, OAuth 2.0 Authorization Code, and Pass Through Authentication. These security schemes ensure the protection and authentication of API endpoints.

Examples of Security Schemes in RAML:

The article provides examples of how to define security schemes in RAML for Basic Authentication, OAuth 2.0 Client Credentials, OAuth 2.0 Authorization Code, and Pass-through Authentication. These examples demonstrate the versatility of securing APIs based on different authentication mechanisms.

Connector Naming and Metadata Generation:

REST Connect automatically generates connector names and metadata for each operation based on the schema definition in the request and response. The article explains how to change the auto-generated connector name using the REST Connect library and how metadata generation is influenced by the RAML definitions.

Reserved Keywords:

To ensure compatibility and avoid conflicts, valid identifiers for REST Connect must not match reserved Java or Mule keywords. The article provides a comprehensive list of these reserved keywords, both for Java and Mule, that developers should steer clear of when naming identifiers.

OAuth2 in Design Center for REST Connect:

The article guides users on how to define an API with OAuth2 - Authorization Code using the Design Center. It provides a detailed example of a GitHub API with OAuth 2.0 Authorization Code, including security schemes, authorization URIs, and scopes.

Mule Application Configuration:

The article concludes with practical steps on configuring a Mule application in Design Center, incorporating an HTTP Listener, the GitHub API, and a Logger. It further explains how to configure OAuth 2.0 with authorization code for a connector, obtain Client ID and Client Secret from GitHub, and set up the external callback URL.

Known Limitations:

The article also highlights a known limitation of the Anypoint platform, stating that it does not support API fragments for OpenAPI Specification (OAS).

In summary, this article provides a comprehensive guide to using REST Connect, creating secure APIs, generating connectors, and integrating with external services using MuleSoft's Anypoint platform. The depth of knowledge demonstrated here ensures a thorough understanding of API integration best practices and MuleSoft technologies.

REST Connect Connector Generator | MuleSoft Documentation (2024)

FAQs

What is the purpose to create a connector using REST connect? ›

REST Connect generates metadata for each operation based on your schema definition in the request and response for each method in your RAML. REST Connect cannot generate metadata based on examples in the RAML. REST Connect supports only one input/output type and uses the first one declared in the API specification.

How does a MuleSoft connector work? ›

You can use connectors to connect a Mule app to specific software applications and to perform actions on the connected application. For example, you can use Anypoint Connector for SAP (SAP Connector) to automate sales order processing between SAP ERP and your customer relationship management (CRM) software.

How to use salesforce connector in Mule 4? ›

Add the Connector to Your Mule Project
  1. In the Mule Palette view, click (X) Search in Exchange.
  2. In Add Modules to Project, type salesforce in the search field.
  3. Click the connector name in Available modules.
  4. Click Add.
  5. Click Finish.

What are the different types of connectors in Mule? ›

In the world of MuleSoft, connectors are generally categorized into two types: operations-based connectors and transport-based connectors. Operations-based connectors, such as the Salesforce Connector, Database Connector, and the HTTP Connector, provide a set of operations that act as a client for an external system.

What are the two functions of a connector? ›

 1 0 .
  • What are the TWO functions of a connector?
  • Simplifies Application Support.
  • Prohibits typos.
  • Increases response speed.
May 21, 2024

Why use an API connector? ›

Integration applications use connectors to connect into systems via the APIs that those systems expose. Connectors make it easier for the creator of the integration application to work with those APIs since they don't have to program directly against those APIs.

How does a connector work? ›

When a connector is twisted onto the stripped and twisted-together ends of wires, the wires are drawn into the connector's metal spring and squeezed together inside it. Electrical continuity is maintained by both the direct twisted wire-to-wire contact and by contact with the metal spring or insert.

How many MuleSoft connectors are there? ›

Anypoint Connectors are the center of connectivity and MuleSoft Exchange has 250+ out-of-the-box connectors to many popular SaaS, Cloud, and traditional applications. In the ever-expanding software application landscape you may not find an out-of-the-box Connector for your favorite application.

What is the difference between Mule and MuleSoft? ›

Introduction: Defining Mule and MuleSoft

Mule: An ESB and integration platform for connecting applications and data sources. MuleSoft: A company that provides a suite of tools and services for API-led connectivity.

When to use Salesforce Connect? ›

A common use for Salesforce Connect is integrating external orders with a fulfillment system for complex orders. Salesforce Connect lets you define external objects mapped in the order and order detail objects within that system. (It uses customer IDs as a common identifier between Salesforce and the external system.)

How to build a Salesforce connector? ›

In the Lightning app, select Account Engagement Settings and then Connectors.
  1. Click + Add Connector.
  2. Click Salesforce.
  3. Click Create Connector.
  4. Log in to Salesforce using the connector user's credentials.
  5. After you're logged in, click Allow to give the connector user access to your business unit.
Jul 5, 2024

How to fetch data from Salesforce using MuleSoft? ›

First, go to File -> New -> Mule Project then go to the Mule Palette. Add the HTTP module to your project, and drag the HTTP Listener into your flow. Set the port to 8081, the path to: /salesforce. Next, go to the Mule Palette, and add the Database Module to your project.

What are the 3 types of connectors? ›

Electrical connectors are classified into three types based on their termination ends: board-to-board connectors, cable/wire-to-cable/wire connectors, and cable/wire-to-board connectors.

What is DataWeave in Mule 4? ›

DataWeave is a programming language designed by MuleSoft for accessing and transforming data that travels through a Mule application. Mule runtime engine incorporates DataWeave in several core components like Transform and Set Payload, which enable you to execute DataWeave scripts and expressions in your Mule app.

What does MuleSoft do for Salesforce? ›

MuleSoft enables you to leverage reusable integrations with Universal API Management (including pre-built integration templates), and even MuleSoft Composer, a tool that enables admins to create integrations using clicks not code.

Why do we need to use connectors? ›

Their purpose is to join information together within a sentence. By using them, the writer adds additional useful detail to the sentence. They can be used to perform many different functions in the sentence.

What is the purpose of a connector in Exchange Server? ›

Connectors enable mail flow in both directions (to and from Microsoft 365 or Office 365). You can enable mail flow with any SMTP server (for example, Microsoft Exchange or a third-party email server). The diagram below shows how connectors in Exchange Online or EOP work with your own email servers.

What is the role of a connector? ›

A connector is a well known person connected to multiple groups in an organisation. The maven knows lots of important stuff, but the connector knows lots of people. Because they circulate in different worlds with different crowds they can connect them and join the dots between any silo.

What is connector used for? ›

Connectors are used to join subsections of circuits together. Usually, a connector is used where it may be desirable to disconnect the subsections at some future time: power inputs, peripheral connections, or boards which may need to be replaced.

Top Articles
A contractor's guide to Profit and Loss accounts
AMM vs Order Book: Understanding the Core of Modern Crypto Trading - Snap Innovations
Uti Hvacr
The UPS Store | Ship & Print Here > 400 West Broadway
Asian Feels Login
How To Be A Reseller: Heather Hooks Is Hooked On Pickin’ - Seeking Connection: Life Is Like A Crossword Puzzle
San Diego Terminal 2 Parking Promo Code
According To The Wall Street Journal Weegy
41 annonces BMW Z3 occasion - ParuVendu.fr
Kostenlose Games: Die besten Free to play Spiele 2024 - Update mit einem legendären Shooter
Pollen Count Central Islip
Hssn Broadcasts
Buying risk?
Alexandria Van Starrenburg
iLuv Aud Click: Tragbarer Wi-Fi-Lautsprecher für Amazons Alexa - Portable Echo Alternative
Niche Crime Rate
E22 Ultipro Desktop Version
Weepinbell Gen 3 Learnset
Indystar Obits
Allybearloves
Craigslist Northfield Vt
Which Sentence is Punctuated Correctly?
Stihl Dealer Albuquerque
Harrison County Wv Arrests This Week
Random Bibleizer
New Stores Coming To Canton Ohio 2022
UCLA Study Abroad | International Education Office
3 Ways to Drive Employee Engagement with Recognition Programs | UKG
HP PARTSURFER - spare part search portal
031515 828
Vlacs Maestro Login
APUSH Unit 6 Practice DBQ Prompt Answers & Feedback | AP US History Class Notes | Fiveable
Grandstand 13 Fenway
2487872771
Bt33Nhn
Weekly Math Review Q4 3
Trebuchet Gizmo Answer Key
Blue Beetle Movie Tickets and Showtimes Near Me | Regal
Watchseries To New Domain
Mta Bus Forums
Stanley Steemer Johnson City Tn
About My Father Showtimes Near Amc Rockford 16
Gasoline Prices At Sam's Club
Hazel Moore Boobpedia
VPN Free - Betternet Unlimited VPN Proxy - Chrome Web Store
Bekah Birdsall Measurements
814-747-6702
Az Unblocked Games: Complete with ease | airSlate SignNow
Dontrell Nelson - 2016 - Football - University of Memphis Athletics
Diccionario De Los Sueños Misabueso
Coleman Funeral Home Olive Branch Ms Obituaries
Round Yellow Adderall
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated:

Views: 6305

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.