Sha256: 1fbd473a70911bd1a039d45e05b65a810e165094db81330fe5ebd6c2b416dbd3

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 Bytes

Contents

module OasParser
  class RequestBody < Payload
    include OasParser::RawAccessor
    raw_keys :description, :required, :content

    attr_accessor :endpoint, :raw

    def initialize(endpoint, raw)
      @endpoint = endpoint
      @raw = raw
    end

    def properties_for_format(format)
      s = schema(format)
      s = handle_all_of(s)
      s['properties'].map do |name, definition|
        OasParser::Property.new(self, s, name, definition)
      end
    end

    def split_properties_for_format(format)
      split_schemas(format).map do |schema|
        schema = handle_all_of(schema)
        schema['properties'].map do |name, definition|
          OasParser::Property.new(self, schema, name, definition)
        end
      end
    end

    def handle_all_of(schema)
      if schema['allOf']
        schema['allOf'].each do |p|
          schema.deep_merge!(p)
        end
        schema.delete('allOf')
      end
      schema
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oas_parser-0.23.0 lib/oas_parser/request_body.rb
oas_parser-0.22.4 lib/oas_parser/request_body.rb