【问题标题】:How to build model with description in swagger?如何用大摇大摆的描述建立模型?
【发布时间】:2018-09-19 07:06:14
【问题描述】:

我想用 image [json] 那样的招摇来构建模型,我有类似 this 的东西。我想在块内有描述标题和数据。下面是代码:

require 'swagger_helper'
describe 'Users API' do
  path '/register/first_step' do
    post 'First step of Registration' do
      tags 'registration'
      consumes 'application/json', 'application/xml'
      parameter name: :user, in: :body, schema: {
          type: :object,
          properties: {
              first_name: {   
              properties: 
              {
                  type: :string,
                  id: :integer
              }    
                },
          }, required: [ :first_name ]
      }
    end
  end
end

【问题讨论】:

  • 你能添加一个实际用户 JSON 应该是什么样子的示例吗?
  • 我上传了图片

标签: ruby-on-rails ruby api swagger-ui


【解决方案1】:

如果您只希望first_name 对象为user 对象,那么它应该是:

parameter name: :user, in: :body, schema: {
  type: :object,
  required: [:first_name],
  properties: {
    first_name: { type: :string }      
  }
}

【讨论】:

    猜你喜欢
    • 2015-08-08
    • 1970-01-01
    • 2018-11-29
    • 2014-07-19
    • 2015-12-14
    • 1970-01-01
    • 2018-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多