Contact Us 1-800-596-4880

Iteratively Design and Implement APIs

logo cloud IDE Cloud IDE

logo desktop IDE Desktop IDE

Open Beta Release: The cloud IDE and AsyncAPI implementation support are in open beta. Any use of Anypoint Code Builder in its beta state is subject to the applicable beta services terms and conditions, available from the IDE.

Using Anypoint Code Builder, you can scaffold an API specification into a new integration project without first publishing the API to Anypoint Exchange. As you make changes, you sync changes in the project by re-scaffolding the spec. For example, after adding a new endpoint to your API spec, you re-scaffold to add a new flow for that endpoint to the configuration XML file.

Anypoint Code Builder does not support the scaffolding of AsyncAPI, OAS, or JSON schema fragment files that are referenced from API specs. The scaffolder does not 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 are not affected by this limitation.

For AsyncAPI specifications, iterative design and implementation is not supported at this time.

After syncing the API spec and related Mule project, you can modify the API specification and implement changes simultaneously.

By using this method to implement the API, you reflect your changes to your API design directly into the interface in your Mule project. Iterating between API design and implementation tasks speeds up the development process.

When you’re ready, publish your API specification to Exchange and deploy your Mule project.

When you scaffold your API specification into a new integration project, Anypoint Code Builder creates a configuration XML for your implementation.

Multi-Root Workspace Considerations

When you scaffold an API, Anypoint Code Builder creates a multi-root workspace in VS Code with both the API spec and integration projects and keeps them synchronized.

VS Code uses a file with the extension .code-workspace to store your multi-root workspace. This file maps the folders for your API spec and implementation projects.

For your projects to work properly, the .code-workspace file must not reside within either project folder.

In addition, Anypoint Code Builder permits only one pair of iterative design and implementation project folders per multi-root workspace.

For more information, see Multi-root Workspaces in the VS Code documentation.

Scaffold an API Spec into a New Implementation Project

To scaffold the current API spec into a new implementation project:

  1. Click the (Implement this local API) icon in the activity bar:

    Implement this local API icon in the activity bar

    Alternatively, use the Command Palette.

    Show me how
    1. Open the Command Palette

      • Use the keyboard shortcuts:

        • Mac: Cmd+Shift+p

        • Windows: Ctrl+Shift+p

      • In the desktop IDE, select View > Command Palette.

      • In the cloud IDE, click the (menu) icon, and select View > Command Palette.

    2. Select the following command:

      MuleSoft: Implement this Local API
  2. At the prompt, click OK:

    Prompt: *We’ll create a workspace to keep your API specification and Mule project in sync.*

    After the workspace is created, Anypoint Code Builder builds and packages the API specification, and publishes it to a local Maven repository as a snapshot.

  3. Navigate to a directory for your new project, and click Save.

    Anypoint Code Builder starts creating a multi-root workspace with your API specification and Mule project.

    In the multi-root workspace, you can work with both your API specification and Mule project folders at the same time.

    Do not accept the default location.

    Save your .code-workspace file in a directory outside of your project folder, not within your API spec folder.

  4. When prompted, provide project configuration details:

    1. Provide a name for your Mule project.

    2. Navigate to a folder for your Mule project, and click Select target folder.

    3. Select a Mule runtime version for the project.

    4. Select a Java version for the project.

      Anypoint Code Builder scaffolds your local API specification into a new Mule project and displays a message when complete:

      Scaffolding process ended message

      Both the API spec and the Mule project open in your IDE, for example:

      API spec and implementation project in Explorer view
      1 API spec
      2 Implementation project
  5. In the Explorer view, open the configuration XML file for your interface.

  6. Click the (Show Mule graphical mode) icon in the activity bar to open the canvas UI if it doesn’t open automatically.

    Notice that the new Mule project includes flows for each endpoint, a built-in XML-based router, and error handlers, which you then implement within a Mule application.

    You can switch between the spec and the implementation project in the Explorer view.

To close your multi-root workspace, see Close a Multi-Root Workspace.

Re-Scaffold the API Spec

After making changes to your API spec, such as adding a new endpoint, re-scaffold the spec to update your Mule project:

  1. In the Explorer view, navigate to the API spec file.

  2. Open the Command Palette.

    Show me how
    • Use the keyboard shortcuts:

      • Mac: Cmd+Shift+p

      • Windows: Ctrl+Shift+p

    • In the desktop IDE, select View > Command Palette.

    • In the cloud IDE, click the (menu) icon, and select View > Command Palette.

  3. Select the following command:

    MuleSoft: Re-scaffold this local API

    After you see the message that your project was rescaffolded successfully, navigate to your implementation XML file, and notice the new flow was added.

Close a Multi-Root Workspace

To close the workspace:

  1. Open the Command Palette.

    Show me how
    • Use the keyboard shortcuts:

      • Mac: Cmd+Shift+p

      • Windows: Ctrl+Shift+p

    • In the desktop IDE, select View > Command Palette.

    • In the cloud IDE, click the (menu) icon, and select View > Command Palette.

  2. Select the following command:

    Workspaces: Close Workspace

After closing, you can reopen a synchronized project from the workspace that you created when implementing the API. See Open a Multi-Root Workspace.

Open a Multi-Root Workspace

To open a multi-root workspace from the .code-workspace file:

  1. Open the Command Palette.

    Show me how
    • Use the keyboard shortcuts:

      • Mac: Cmd+Shift+p

      • Windows: Ctrl+Shift+p

    • In the desktop IDE, select View > Command Palette.

    • In the cloud IDE, click the (menu) icon, and select View > Command Palette.

  2. Select the following command:

    File: Open Workspace from File...
  3. Navigate to your home directory and double-click the .code-workspace file for the workspace.

    The projects open in the Explorer view, and the folder name for the multi-root workspace includes (WORKSPACE), for example:

    A multi-root workspace in Explorer view