Sha256: 7617236370cc0025d1f74bcc6a82654f7227f4a7e8ea01f8255db2dae83cd8c6

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module OasParser
  class AbstractAttribute
    include OasParser::RawAccessor

    def enum
      raw['enum'] || (schema ? schema['enum'] : nil)
    end

    def array?
      type == 'array'
    end

    def object?
      type == 'object'
    end

    def collection?
      array? || object?
    end

    def properties
      return convert_property_schema_to_properties(raw['properties']) if object?
      return convert_property_schema_to_properties(items) if array?
      nil
    end

    def has_xml_options?
      raw['xml'].present?
    end

    def is_xml_attribute?
      return false unless has_xml_options?
      raw['xml']['attribute'] || false
    end

    def is_xml_text?
      # See: https://github.com/OAI/OpenAPI-Specification/issues/630#issuecomment-350680346
      return false unless has_xml_options?
      return true if raw['xml']['text'] || false
      raw['xml']['x-text'] || false
    end

    def has_xml_name?
      return false unless has_xml_options?
      xml_name || false
    end

    def xml_name
      raw['xml']['name']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oas_parser-0.8.1 lib/oas_parser/abstract_attribute.rb