首页 文章

Rails:记录使用swagger-blocks消耗json params的post endpoint?

提问于
浏览
1

在rails中使用swagger-block,我会记录一个消耗单个json主体的post endpoints ,例如:

{ "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

1 回答

  • 0

    JSON似乎在语法上是正确的,除非您尝试创建时默认情况下应自动生成"id" . 您可以检查此specification是否存在违规行为 .

相关问题