我有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