Search code examples
mule-studioanypoint-studioramlmulesoft

Why is "Generate Flows from REST API" option disabled in anypoint platform?


I am trying to create a new API interface Mule configuration from an API RAML file. First - I published an API to Anypoint Exchange and then imported api from the design center to Anypoint Studio project. Now, when I am right-clicking the API RAML file and selecting Mule > Generate Flows from REST API, this option is coming as disabled and I cannot select it.

I am using Mule 4 and Anypoint Studio Version: 7.3.2. I verified the API RAML file and there are no visible errors in it. What is causing this option to be disabled and how can I enable it?

Below is the actual API RAML file.

#%RAML 1.0
version: v1
title: Accounts API

types:
  Account: !include datatypes/account.raml
  AccountNoID: !include datatypes/accountNoID.raml

/accounts:
  get:
    description: Retrieves accounts based on the given query parameters.
    headers:
      Requester-ID:
        description: id of the person requesting the accounts information
        required: true
    queryParameters:
      country:
        required: false
        type: string
      name:
        description: The system will look for names that contain the given value in the name parameter.
        required: false
        type: string
      type:
        required: true
        type: string
        enum: ["personal", "business"]
    responses:
      400:
        body:
          application/json:
            example: {
              "message": "Error retrieving data from the Account database."
            }
      200:
        description: Returns an array of Account objects in JSON
        body:
          application/json:
            type: Account[]
            examples:  !include examples/accountsExample.raml
  post:
    description: Creates new accounts based on a given array of Account objects.
    headers:
        Requester-ID:
          description: id of the person requesting the accounts information
          required: true
    body:
      application/json:
        description: Payload should be an array of Account objects with all fields present for each Account object.
        type: AccountNoID[]
        examples: !include examples/accountsExampleNoID.raml
    responses:
      400:
        body:
          application/json:
             example: {
               "message": "Error creating accounts. Please check the JSON object and make sure it's valid."
             }
      201:
        body:
          application/json:
            example: {
              "message": "Accounts uploaded (but not really)."
            }


Solution

  • If the option is not available that means that Studio is not able to parse the RAML.

    Recently there was a change in Design Center on how it is dealing with the examples node in RAML.

    Details here: https://docs.mulesoft.com/design-center/design-modify-raml-specs-conform

    In this case the RAML in Design Center is valid but due to a bug in Studio this is not seen as valid in Studio at the moment.

    Try using Named Examples in your RAML for the examples nodes.

    examples:  
      myNamedExample: !include examples/accountsExample.raml