richhollis / swagger-docs

Generates swagger-ui json files for Rails APIs with a simple DSL.
MIT License
750 stars 150 forks source link

Param as an array of swagger_model object? #71

Closed rvindas-gap closed 10 years ago

rvindas-gap commented 10 years ago

Hi, in a Ruby on Rails application, we have a swagger_model called Disk and the following is the parameter I am specifying in the corresponding swagger_api entry:

param :body, :disks, :Disk, :optional, "An array of disks"

How could I make this parameter an array in order to behave like this example: http://petstore.swagger.wordnik.com/#!/user/createUsersWithArrayInput ?

Thanks in advance

beydogan commented 10 years ago

Have you found any solution?

rvindas-gap commented 10 years ago

I ended up having the swagger_api entry as follows:

  swagger_api :create do
    summary "Creates a new Machine"
    param :path, :client_id, :integer, :required, "Client ID"
    param :body, :machine, :Machine, :required, "The Machine resource to create"
    response :unauthorized
    response :not_acceptable
  end

where Machine is a complex type as follows:

  swagger_model :Machine do
    description "A Machine object."
    property :name, :string, :optional, "Name"
    ...
    property :disks, :array, :optional, "A list of disks", { "items" => { "$ref" => "Disk" } }
    ...
  end

where Disk is another swagger_model with its own properties. Hope it helps

itsmatthu commented 9 years ago

how to set name property under Model Machine an default value?