我有raml文档,并尝试将新的API文档添加到该文档。如何在raml资源中包含常见的响应
我经历了基本的RAML文档。
我有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
和<<:
都不行。
性状适合我! – Sachin
@Sachin你可以给你的“特质”例子吗? – Nilesh