Sha256: 2d334f337065953e963469178a6bf3de52d6c89fbce2c9d626091c077b465f70

Contents?: true

Size: 803 Bytes

Versions: 3

Compression:

Stored size: 803 Bytes

Contents

module Swagger
  # A common interface for building or loading Swagger documents of any version. See subclasses.
  class API < SwaggerObject
    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

    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
  end
end

require 'swagger/v2/api'

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
swagger-parser-0.2.6 lib/swagger/api.rb
swagger-parser-0.2.5 lib/swagger/api.rb
swagger-core-0.2.3 lib/swagger/api.rb