我有raml文档,并尝试将新的 API 文档添加到该文档中。
我浏览了基本的 RAML 文档。
我有 raml 文件。
#Filename: base.raml
title: Test RAML
documentation:
- title: Test RAML docs first time :)
content: This is RAML testing
baseUri: https://myportal.com/{version}/scriptmanagement
version: v1.0
mediaType: application/json
protocols: [ HTTPS ]
/test:
!include raml/test.raml
实际的 raml 内容在test.raml
#Filename: test.raml
displayName: Test RAML Inheritance
description: Testing for RAML inheritance for responses.
get:
description: Get all TEST
headers:
name:
description: name required in each request
example: testname
required: true
responses:
200:
description: SUCCESS
body:
application/json:
example: |
{}
400:
description: BAD REQUEST
body:
application/json:
example: |
{"error": "Bad Request"}
500:
description: INTERNAL ERROR
body:
application/json:
example: |
{"error": "Internal Error"}
post:
description: Get all TEST
headers:
name:
description: name required in each request
example: testname
required: true
responses:
200:
description: SUCCESS
body:
application/json:
example: |
{"message": "Created"}
400:
description: BAD REQUEST
body:
application/json:
example: |
{"error": "Bad Request"}
500:
description: INTERNAL ERROR
body:
application/json:
example: |
{"error": "Internal Error"}
/{test_id}:
description: TEST DETAILS
get:
description: Retrieve resource own by x-user-name
headers:
name:
description: name required in each request
example: testname
required: true
responses:
200:
description: SUCCESS
body:
application/json:
example: |
{"message": "Details"}
400:
description: BAD REQUEST
body:
application/json:
example: |
{"error": "Bad Request"}
500:
description: INTERNAL ERROR
body:
application/json:
example: |
{"error": "Internal Error"}
在上面的 RAML 中,400
响应500
很常见,name
标头很常见。
我怎样才能写一次并添加到所有资源中?我试过了traits
,<<:
但都不起作用。