Sha256: 20a14f18ca98b0447db1fb557dd84bb216df9055e8314786ab40940b82cf4a81

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

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(format), name, definition)
        end
      end
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oas_parser-0.21.0 lib/oas_parser/request_body.rb