如何在swagger中建立带描述的模型?

问题描述 投票:0回答:1

我想在image [json]中像swagger一样建造带有描述的模型,我有像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
ruby-on-rails ruby api swagger-ui
1个回答
0
投票

如果你只想为first_name对象使用字符串user,那么它应该是:

parameter name: :user, in: :body, schema: {
  type: :object,
  required: [:first_name],
  properties: {
    first_name: { type: :string }      
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.