Contact Us 1-800-596-4880

Design and Publish the American Flights API Specification

Design the American Flights API specification in Anypoint Code Builder, test it with the built-in mocking service, and publish it to Anypoint Exchange so other team members can find and implement it.

Before you begin, complete the setup in Build an API from Start to Finish with Anypoint Code Builder.

Create the API Specification

Start creating the American Flights API spec:

  1. In the activity bar, click the (Anypoint Code Builder) icon.

    Anypoint Code Builder icon in the VS Code activity bar
  2. From Create, click Design an API.

  3. Configure your API spec project using these values:

    Field Name Field Value

    Enable this API for Topics and Actions

    Select this checkbox to add the applicable agent topic metadata and apply centralized governance rulesets to the project. See Enabling an API Project for Topics and Agent Actions for more information.

    Project Name

    American Flights API

    Project Location

    Your home directory is selected by default. This is the root folder of your project, which acts as your workspace. Don’t select a different project directory for this API spec. See Adding Folders to Your Home Directory for more information.

    API Type

    REST API

    API Specification Language

    OAS 3.0 (YAML)

    Business Group

    Select the business group to use for this project.

  4. Click Create Project to generate the American Flights API project file: american-flights-api.yaml.

    The file name is based on the project name you provide.

  5. Configure the agent topic metadata and instructions by setting these values:

    Field Name Field Value

    Topic Label

    American Flights API

    Classification Description

    Use the API description.

    Scope

    Your job is only to book, update, or retrieve flight information.

    Instruction

    If a user asks to retrieve flight details, use the get flight operation to retrieve information using the booking ID.

    If you don’t see the Agent Topics after creating the project, you must trust the workspace folder. You can do so by clicking Manage then Trust from the notification that shows.

    The workspace trust notification with Manage and Trust options
    If you closed the notification, or it doesn’t show, see: Trusting a workspace for instructions.
  6. Click Apply to save your changes.

  7. Open MuleSoft Vibes from the toolbar.

    If you don’t see the MuleSoft Vibes icon, click Additional Views to expand the toolbar.

    Additional Views menu with MuleSoft Vibes highlighted
  8. Enable auto-approve by clicking the Auto-approve section at the end of the MuleSoft Vibes window, and then select:

    • Read project files

    • Edit project files

    • Execute safe commands

    • Use MCP Servers

      Auto-approve panel with Read project files, Edit project files, Execute safe commands, and Use MCP servers checkboxes selected

      With auto-approve enabled, MuleSoft Vibes automatically applies changes to your project without prompting you for confirmation. See MuleSoft Vibes for Anypoint Code Builder for more information.

  9. Enter this prompt, and then send your message:

    Create an OAS 3.0 API specification example for the American Flights API that returns flight information from a MySQL database. The API must define:
    1. A GET /flights endpoint that retrieves all flights.
    2. A GET /flights/(flightId) endpoint that retrieves a single flight by its flightId path parameter. The flightId must match the pattern ^[A-Z]{2}[0-9]{1,4}$.
    3. Both endpoints must return flight objects with this exact structure: ID (integer), code (string), price (number), departureDate (string), origin (string), destination (string), emptySeats (integer), and a nested plane object with type (string) and totalSeats (integer).

    MuleSoft Vibes generates the spec and saves it to your file.

    The american-flights-api.yaml file open in the editor showing the generated OAS 3.0 specification

    If you get an API streaming failed error, click Resume Task to retry creating the spec.
    If you see this message: The model has determined this command requires explicit approval., click Run Command.

Mock and Test the API

Next, use MuleSoft Vibes and the built-in mocking service in the API Console to test the API before you publish it.

Send this message to MuleSoft Vibes:

Test the API using the built-in mocking service in API console.

Alternatively, you can open the API Console and manually test the endpoints:

  1. In the project explorer, open your API spec YAML file.

  2. Open the Command Palette.

    Show me how
    • Use the keyboard shortcuts:

      • Mac: Cmd+Shift+p

      • Windows: Ctrl+Shift+p

    • Select View > Command Palette.

  3. Provide this command:

    MuleSoft: Show API Console
  4. Click GET in any of the endpoints.

    The american-flights-api.yaml file next to the API Console showing the Get all flights and Get a flight by ID endpoints
  5. Click Try it and then Send.

    The API Console shows an example response.

Your API spec is now ready to publish to Anypoint Exchange.

Publish the API Spec to Exchange

Publish the American Flights API spec to Exchange so that other team members can find and implement it.

  1. In the project explorer, open your API spec YAML file.

  2. Click Publish API Project to Exchange.

    Publish API Project to Exchange icon
    • Alternatively, provide this command in the command palette:

      MuleSoft: Publish API Project to Exchange
  3. If prompted, click Allow, and follow the prompts to sign in to Anypoint Platform.

  4. If you haven’t selected a business group, select one now in Select a Business Group.

  5. Enter the asset version: 1.0.0.

  6. Enter the API version: v1.

  7. Confirm the asset ID in the project metadata: american-flights-api.

  8. Click Publish.

    The status bar shows the progress after the API is published successfully to Exchange.

  9. When prompted to implement the API now, select No to avoid scaffolding the American Flights API spec into your integration.

    Selecting Yes scaffolds the API spec into your project. Instead of scaffolding now, you scaffold the API in Implement the American Flights API.

Locate Your API in Exchange

After publishing your API spec, you can find it in Anypoint Exchange:

  1. Navigate to Anypoint Exchange.

    Show me how
  2. Type american in the search bar and press Enter.

  3. Notice that your API spec is listed as an asset.

    You can select the API, navigate through its summary, and see all the endpoints you defined in the previous tasks.