为什么在任何点平台上都禁用了“从REST API生成流”选项?

时间:2019-03-23 20:16:50

标签: mule-studio anypoint-studio raml mulesoft

我正在尝试从API RAML文件创建新的API接口Mule配置。首先-我发布了一个API到Anypoint Exchange,然后将api从设计中心导入到Anypoint Studio项目。现在,当我右键单击API RAML文件并选择“ Mule”>“从REST API生成流”时,此选项已被禁用,我无法选择它。

我正在使用Mule 4和Anypoint Studio版本:7.3.2。我验证了API RAML文件,并且其中没有可见错误。是什么导致该选项被禁用,如何启用它?

下面是实际的API RAML文件。

#%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)."
            }

1 个答案:

答案 0 :(得分:0)

如果该选项不可用,则表示Studio无法解析RAML。

最近,Design Center在处理RAML中的示例节点方面发生了变化。

此处的详细信息:https://docs.mulesoft.com/design-center/design-modify-raml-specs-conform

在这种情况下,Design Center中的RAML是有效的,但是由于Studio中的错误,目前在Studio中它不被视为有效。

尝试在examples节点的RAML中使用命名示例。

examples:  
  myNamedExample: !include examples/accountsExample.raml