Sha256: 2c9dcb3535aa22070616f117d9296073045d34e54c7f57cb782bf59ccdab8bfa
Contents?: true
Size: 947 Bytes
Versions: 4
Compression:
Stored size: 947 Bytes
Contents
module Swagger module V2 # A class to represent example objects in the Swagger schema. # Usually used to represent example request or responses. # Provides access to both the raw example or a parsed representation. class Example extend Forwardable def_delegator :@raw, :to_s, :inspect # The example as it appears in the Swagger document. # @return Object the example attr_reader :raw def initialize(sample) @raw = sample end # The example after it has been parsed to match the +media_type+. # @param media_type [String] the target media_type # @return [Object] an object according to the +media_type+ def parse(media_type = 'application/json') return @raw unless @raw.is_a? String parser = Swagger::MimeType.parser_for(media_type) parser.parse(@raw) end def inspect @raw.inspect end end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
swagger-parser-0.2.6 | lib/swagger/v2/example.rb |
swagger-parser-0.2.5 | lib/swagger/v2/example.rb |
swagger-core-0.2.3 | lib/swagger/v2/example.rb |
swagger-core-0.2.2 | lib/swagger/v2/example.rb |