Class: Swagger::API
- Inherits:
-
SwaggerObject
- Object
- Hashie::Dash
- SwaggerObject
- Swagger::API
- Defined in:
- lib/swagger/api.rb
Overview
A common interface for building or loading Swagger documents of any version. See subclasses.
Direct Known Subclasses
Constant Summary
Constants inherited from SwaggerObject
SwaggerObject::CUSTOM_PROPERTY_PREFIX
Instance Attribute Summary
Attributes inherited from SwaggerObject
Attributes included from Attachable
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ API
constructor
A new instance of API.
Methods inherited from SwaggerObject
field, property?, required_field
Methods included from Attachable
#attach_parent, #attach_to_children, #root
Constructor Details
#initialize(hash) ⇒ API
Returns a new instance of API.
15 16 17 18 19 20 21 22 |
# File 'lib/swagger/api.rb', line 15 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_api(hash) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/swagger/api.rb', line 4 def self.build_api(hash) version = hash['swaggerVersion'] || hash['swagger'] major, _minor = version.to_s.split('.') case major when '2' Swagger::V2::API.new hash else fail ArgumentError, "Swagger version #{version} is not currently supported" end end |