Skip to content

Commit

Permalink
Merge pull request #43 from jonanderricchiuti/bugfix/object-items
Browse files Browse the repository at this point in the history
Allow objects inside items.
  • Loading branch information
fotinakis committed Mar 7, 2016
2 parents 99b1517 + 97d1dd2 commit 2ba0fca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/swagger/blocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,13 @@ class ExampleNode < Node; end

# v1.2:
# v2.0:
class ItemsNode < Node; end
class ItemsNode < Node
def property(name, inline_keys = nil, &block)
self.data[:properties] ||= Swagger::Blocks::PropertiesNode.new
self.data[:properties].version = version
self.data[:properties].property(name, inline_keys, &block)
end
end

# v1.2: http://goo.gl/PvwUXj#524-parameter-object
# v2.0: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameter-object
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/swagger_v2_api_declaration.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@
"type": "string"
}
}
},
"arrayOfObjects": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/swagger_v2_blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ class PetV2
key :type, :string
end
end
property :arrayOfObjects do
key :type, :array
items do
key :type, :object
property :name do
key :type, :string
end
property :age do
key :type, :integer
end
end
end
end
end
end
Expand Down

0 comments on commit 2ba0fca

Please sign in to comment.