我有一个RAML 1.0规范,其中我定义了多个资源。每个资源都有相同的标题集。
我需要使用RAML的哪些构造来一次声明头并在各种资源定义中重用它们?
例如:
/read/records:
post:
description: api for reading records
queryParameters:
table_name: string
headers:
Authorization:
displayName: Authorization
description: Basic authentication base 64 encoded string
type: string
required: true
Tenant-Id:
displayName: Tenant-Id
description: Tenant id for multi-tenant environments
type: string
required: true
Content-type:
displayName: Content-type
description: either xml or json
type: string
required: true
/adjust/records:
post:
description: api for editing records
headers:
Authorization:
displayName: Authorization
description: Basic authentication base 64 encoded string
type: string
required: true
Tenant-Id:
displayName: Tenant-Id
description: Tenant id for multi-tenant environments
type: string
required: true
Content-type:
displayName: Content-type
description: either xml or json
type: string
required: true谢谢!
发布于 2017-04-07 12:22:24
您可以使用traits:
#%RAML 1.0
traits:
hasHeaders:
headers:
Authorization:
displayName: Authorization
description: Basic authentication base 64 encoded string
type: string
required: true
Tenant-Id:
displayName: Tenant-Id
description: Tenant id for multi-tenant environments
type: string
required: true
Content-type:
displayName: Content-type
description: either xml or json
type: string
required: true
/read/records:
post:
is: ["hasHeaders"]
description: api for reading records
queryParameters:
table_name: string
/adjust/records:
post:
is: ["hasHeaders"]
description: api for editing records发布于 2017-04-07 16:41:55
特征必须表示一种行为,它是通过路线和动词来应用的。对于我来说,标头适用于任何路由/动词,您可以定义资源类型:
#%RAML 1.0 ResourceType
get?:
headers:
Authorization:
displayName: Authorization
description: Basic authentication base 64 encoded string
type: string
required: true
Tenant-Id:
displayName: Tenant-Id
description: Tenant id for multi-tenant environments
type: string
required: true
Content-type:
displayName: Content-type
description: either xml or json
type: string
required: true
post?:
headers:
Authorization:
displayName: Authorization
description: Basic authentication base 64 encoded string
type: string
required: true
Tenant-Id:
displayName: Tenant-Id
description: Tenant id for multi-tenant environments
type: string
required: true
Content-type:
displayName: Content-type
description: either xml or json
type: string
required: truehttps://stackoverflow.com/questions/43273475
复制相似问题