Sha256: 189735367a3653dbf44fb4c81f7bce6b16af3a180ed73acacd6a0b6104ed3b3a

Contents?: true

Size: 659 Bytes

Versions: 8

Compression:

Stored size: 659 Bytes

Contents

require "json-schema"

class Swagalicious
  class ExtendedSchema < JSON::Schema::Draft4
    def initialize
      super
      @attributes["type"] = ExtendedTypeAttribute
      @uri                = URI.parse("http://tempuri.org/swagalicious/extended_schema")
      @names              = ["http://tempuri.org/swagalicious/extended_schema"]
    end
  end

  class ExtendedTypeAttribute < JSON::Schema::TypeV4Attribute
    def self.validate(current_schema, data, fragments, processor, validator, options={})
      return if data.nil? && current_schema.schema["null"] == true
      super
    end
  end

  JSON::Validator.register_validator(ExtendedSchema.new)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
swagalicious-0.4.4 lib/swagalicious/extended_schema.rb
swagalicious-0.4.3 lib/swagalicious/extended_schema.rb
swagalicious-0.4.2 lib/swagalicious/extended_schema.rb
swagalicious-0.4.1 lib/swagalicious/extended_schema.rb
swagalicious-0.4.0 lib/swagalicious/extended_schema.rb
swagalicious-0.3.1 lib/swagalicious/extended_schema.rb
swagalicious-0.3.0 lib/swagalicious/extended_schema.rb
swagalicious-0.2.0 lib/swagalicious/extended_schema.rb