在 RAML 中将 JSON 布尔类型定义为 RESTful 主体类型

Define JSON boolean type as RESTful body type in RAML

我有一个 RAML 文件,其中包含自定义 BooleanValue json 架构作为方法的 return 类型。

BooleanValue.json:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Boolean value",
    "description": "If lookup or update in success",
    "type": "boolean"
}

Service.raml 片段:

#%RAML 1.0
title: Service API
version: 1.0
mediaType: application/json
schemas:
  - BooleanValue:  !include model/BooleanValue.json

<... snip ...>

/resource:
  /{name}:
    patch: 
      responses: 
        200:
          body:
            schema: BooleanValue
            example: true 

我确信不需要定义 BooleanValue 模式,但我找不到其他示例来说明 JSON 布尔类型是 return 值。

这能做到吗?怎么样?

使用 RAML 1,您可以这样做:

#%RAML 1.0
title: Service API
version: 1.0
mediaType: application/json
/resource:
  /{name}:
    patch: 
      responses: 
        200:
          body:
            description: If lookup or update in success
            type: boolean
            example: true