Sha256: 6370c14e48bc323439457522fdcae52ccdfd2f6bc5870d5e3c8da46e410f0b16

Contents?: true

Size: 698 Bytes

Versions: 4

Compression:

Stored size: 698 Bytes

Contents

require_relative '../swagger/property'

module Swaggard
  module Parsers
    module Property
      def self.run(yard_object)
        name = yard_object.name.dup
        options_and_description = yard_object.text&.dup || ''

        options_and_description.gsub!("\n", ' ')
        options, description = options_and_description.match(/\A(\[.*\])?(.*)\Z/).captures
        options = options ? options.gsub(/\[?\]?\s?/, '').split(',') : []
        description = description.strip
        required = name.gsub!(/^!/, '')
        type = Parsers::Type.run(yard_object.types.first)

        Swaggard::Swagger::Property.new(name, type, description, required.present?, options)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
swaggard-1.5.1 lib/swaggard/parsers/property.rb
swaggard-1.5.0 lib/swaggard/parsers/property.rb
swaggard-1.4.0 lib/swaggard/parsers/property.rb
swaggard-1.3.0 lib/swaggard/parsers/property.rb