如何用摇摇欲坠建立带有描述的模型?

时间:2018-09-19 07:06:15

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

我想像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

1 个答案:

答案 0 :(得分:0)

如果您只希望first_name对象使用字符串user,则应该为:

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