【问题标题】:MuleSoft Importing RAML Specification into Anypoint Studio With RAML FragmentsMuleSoft 使用 RAML 片段将 RAML 规范导入 Anypoint Studio
【发布时间】:2018-12-07 17:33:27
【问题描述】:

我们已升级到 Crowd Release 平台,现在正在创建 API 规范,这些规范使用 MuleSoft 推荐的片段。但是,我们可以导入 RAML,但不能生成流。没有错误 - 没有警告 - 没有。

我已经举了一个例子。

api.raml

#%RAML 1.0
version: v1
title: api
types:
  contactDetails: !include library/types/contactDetails.raml

/contact:
  post:
    body: 
      application/json:
        type: contactDetails

types-library.raml

#%RAML 1.0 Library

types:
  telephoneNumber: !include ../exchange_modules/fragment-flows-problem-fragment/1.0.0/telephone-number.raml

contactDetails.raml

#%RAML 1.0 DataType
uses:
  contactDetails: ../types-library.raml

properties:
  name:
    type: string
  telephone:
    type: contactDetails.telephoneNumber

电话号码.raml(片段)

#%RAML 1.0 DataType

description: |
  **includes validation applicable to a contact telephone number**
  ***
  - Minimum length 9
  - Maximum length 15

type: string
displayName: Telephone Number
minLength: 9
maxLength: 15
pattern: ^[\d ]+$
examples:
  telephoneNumber1: "01433000000"
  telephoneNumber2: "01433 000000"

我只是补充一点,RAML 在设计中心和 Exchange 中都有效。

补充一句,如果我们去掉contactDetails.raml中的uses语句,那么contactDetails数据类型就无法识别了。

如果有人在这里指出问题或解释 Anypoint Studio 如何导入使用非常有用的片段的规范。

谢谢。

【问题讨论】:

    标签: raml


    【解决方案1】:

    这是一个迟到的回复,但我今天碰巧遇到了这个问题,我的搜索让我想到了你的问题。

    我的问题是contactDetails.raml 文件中缺少!include。我在 Anypoint Studio 中遇到了同样的问题,我的解决方法是:

    #%RAML 1.0 DataType
    uses:
      contactDetails: !include ../types-library.raml
    
    properties:
      name:
        type: string
      telephone:
        type: contactDetails.telephoneNumber
    

    很遗憾,Anypoint Studio 没有提供任何关于为什么会出现 RAML 错误的有用信息,而只是告诉您出了点问题。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 2014-11-18
    • 2018-12-04
    • 2017-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多