首页 > 解决方案 > 您可以参考 RAML 中的示例和架构吗

问题描述

我正在使用 Mule 4 和 Anypoint Studio 7。

我目前正在编写 RAML,并希望将模式(验证)和示例(API 控制台中的模拟响应)添加到我的 RAML 中的资源,但我遇到了一般性错误。

#%RAML 1.0 Trait
responses: 
  200:
    body: 
      application/json:
        schema: mySchema
        example: example/mySchema.json

是否可以对资源同时使用模式和示例?

谢谢

标签: muleanypoint-studioraml

解决方案


这是一个例子

#%RAML 1.0
version: v1
title: something.raml

mediaType:
  application/json

uses:
  ResultsRS: path/StudentResultRS.raml


/students:
    /results/get:
      post:
        description: get the results of a student
          body:
            application/json:
              type: ResultsRS.tudentResultRS.raml
              examples: !include path/examples/studentresults_RS.raml

您需要确保已正确定义类型和示例。


推荐阅读