Class: Swagger::APIDeclaration
- Inherits:
-
DefinitionSection
- Object
- Hashie::Dash
- DefinitionSection
- Swagger::APIDeclaration
- Defined in:
- lib/swagger/api_declaration.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from DefinitionSection
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ APIDeclaration
constructor
A new instance of APIDeclaration.
Methods inherited from DefinitionSection
Methods included from Attachable
#attach_parent, #attach_to_children, #root
Constructor Details
#initialize(hash) ⇒ APIDeclaration
Returns a new instance of APIDeclaration.
14 15 16 17 18 19 20 21 |
# File 'lib/swagger/api_declaration.rb', line 14 def initialize(hash) @vendor_extensions = {} hash.each do |k, v| @vendor_extensions[k] = v if k.to_s.start_with? 'x-' end # HACK: There's got to be a better way, but Dash wasn't working well with strings super(Hashie::Mash.new(hash).to_hash(symbolize_keys: true)) end |
Class Method Details
.build(hash) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/swagger/api_declaration.rb', line 3 def self.build(hash) version = hash['swaggerVersion'] || hash['swagger'] major, _minor = version.to_s.split('.') case major when '2' Swagger::V2::APIDeclaration.new hash else fail ArgumentError, "Swagger version #{version} is not currently supported" end end |