在rails中使用swagger-block,我会记录一个消耗单个json体的post端点,例如:
{
"id":"1",
"name": "bill",
"age":"22"
}
无论我做什么,我的测试都说我的设置不是Swagger 2.0 JSON架构。
以下是我用来生成文档的代码:
swagger_path '/list/add' do
operation :post do
key :summary, 'Add person to list'
parameter name: :id, in: :body, required: true, type: :string
parameter name: :name, in: :body, required: true, type: :string
parameter name: :age, in: :body, required: true, type: :string
response 200 do
key :description, 'Successfully added to list'
end
end
end