【发布时间】:2020-03-04 22:53:50
【问题描述】:
我的 HTTP 请求负载按照 jsonapi.org 准则构建:
{
"data": {
"type": "employee",
"attributes": {
"firstName": "John",
"lastName": "Doe",
}
}
}
然后我有这个有效载荷的OpenApi 规范(yaml):
employee:
type: object
required: [data]
properties:
data:
type: object
properties:
type:
type: string
enum: [employee]
attributes:
type: object
required: [firstName, lastName]
properties:
firstName:
type: string
example: 'John'
lastName:
type: string
example: 'Doe'
我想要的是根据规范(来自 Ruby/Rails)验证有效负载。
存在openapi3_parser gem,但它似乎只能验证规范,而不是实际的有效负载。
然后,有jsonapi.org payload deserializers,但似乎根本不关心 OpenApi 正式规范。
我使用 OpenApi 来描述有效负载,因为我通过 Swagger 免费获得了 http API 文档。
【问题讨论】: