Sha256: 6108fc43b092e1259632a7e4e0ad5f01843f5b897dab4186ce97ee3ae1dcaabe

Contents?: true

Size: 577 Bytes

Versions: 14

Compression:

Stored size: 577 Bytes

Contents

require "json_test_data"

module Rambo
  module RamlModels
    class Body

      attr_reader :body, :type

      def initialize(raml)
        @body = raml
      end

      def content_type
        body.content_type
      end

      def example
        @example ||= body.example || generate_from_schema || {}.to_json
      end

      def schema
        @schema ||= body.schema
      end

      private

      def generate_from_schema
        return nil unless body.schema
        JSON.pretty_generate(JsonTestData.generate!(body.schema, ruby: true))
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rambo_ruby-0.7.1 lib/rambo/raml_models/body.rb
rambo_ruby-0.7.0 lib/rambo/raml_models/body.rb
rambo_ruby-0.6.0 lib/rambo/raml_models/body.rb
rambo_ruby-0.5.0 lib/rambo/raml_models/body.rb
rambo_ruby-0.4.0 lib/rambo/raml_models/body.rb
rambo_ruby-0.3.3 lib/rambo/raml_models/body.rb
rambo_ruby-0.3.2 lib/rambo/raml_models/body.rb
rambo_ruby-0.3.1 lib/rambo/raml_models/body.rb
rambo_ruby-0.3.0 lib/rambo/raml_models/body.rb
rambo_ruby-0.2.3 lib/rambo/raml_models/body.rb
rambo_ruby-0.2.2 lib/rambo/raml_models/body.rb
rambo_ruby-0.2.1 lib/rambo/raml_models/body.rb
rambo_ruby-0.2.0 lib/rambo/raml_models/body.rb
rambo_ruby-0.1.0 lib/raml_models/body.rb